Crate: agent-doc-model-tier
Spec
- Defines
Tier: a harness-agnostic complexity bucket (Auto,Low,Med,High) used to classify task complexity and gate model selection. TierderivesPartialOrdsuch thatAuto < Low < Med < High. Gating is a simple>comparison: a task whose effective tier exceeds the running model's tier should prompt the user to switch.- Defines
ModelConfig(under[model]in the global TOML config) andTierMap(per-harness tier→model name resolution under[model.tiers.<harness>]). detect_harness()reads environment variables (CLAUDE_CODE_SESSION,CLAUDE_CODE,CLAUDECODE,CODEX_SESSION,CODEX_THREAD_ID,CODEX_CLI,OPENCODE_CLIENT,OPENCODE) to identify the active agent harness, falling back to"default".resolve_tier_to_model(tier, harness, config)maps aTierto the concrete model name configured for the given harness, falling back to built-in defaults for theclaude-code,codex,opencode, anddefaultharnesses.tier_from_model_name(name, harness, config)is the reverse lookup: given a concrete model name (e.g.,"opus"), find the tier it belongs to in the harness mapping.Tier::FromStraccepts case-insensitiveauto | low | med | high.
Agentic Contracts
- Total ordering:
TierimplementsPartialOrddeterministically; gating logic is a single comparison and can be safely executed by any model tier. - Auto is the lowest:
Tier::Autorepresents "no preference" and compares less thanLow. Theeffective_tiercomposition treatsAutoas "fall through to next source." - Built-in defaults: when no
[model.tiers.<harness>]section is present, the resolver falls back to compiled-in maps for known harnesses. This means a fresh install needs zero config for the common case. - Reverse lookup is partial:
tier_from_model_namereturnsNoneif the model name doesn't appear in any tier slot for the harness. Callers should treatNoneas "unknown — leave tier as Auto."
Evals
tier_ordering:Auto < Low < Med < Highholds for<,>,<=,>=.tier_from_str_case_insensitive:"LOW","low","Low"all parse toTier::Low.tier_from_str_invalid: unknown strings returnErr.harness_detection_default: with no env vars set,detect_harness()returns"default".resolve_builtin_claude_code:resolve_tier_to_model(Tier::High, "claude-code", &Config::default())returnsSome("opus")(the deferred Claude Code opus alias).resolve_unknown_harness_uses_default: an unknown harness falls through to the"default"built-in map.tier_from_model_name_roundtrip:tier_from_model_name("opus", "claude-code", ...)returnsSome(Tier::High).