Model Router  ·  Documentation  ·  Previous: Performance  ·  Next: Benchmarks

# Built on the Claude Code docs Each row is a rule from the Claude Code or Claude platform docs or Claude Code's types, where the plugin follows it, and the test that holds it. Python names are in `plugins/model-router/scripts/modelrouter/`, and Node tests in `tests/mod/router.test.ts`. | The docs say | Where the plugin follows it | Test | | :- | :- | :- | | A subagent's model comes from the call's `model`, the agent's `model` (`inherit` included), `CLAUDE_CODE_SUBAGENT_MODEL`, then the conversation's, and a mod's `agent.spawn` model takes the call's place; the variable alone doesn't change the built-in Explore and Plan ([sub-agents](https://code.claude.com/docs/en/sub-agents.md#choose-a-model)) | `router.decide` keeps that order and moves a model only for the cap, the floor, an unusable model, a rule, a teammate or a redo, and in place of the conversation's names the level the agent's tools put it at, for Explore and Plan under the variable too | `test_the_users_environment_settings_win`, `test_a_call_that_names_no_model_runs_at_the_level_its_agents_tools_put_it`, `test_rules_in_override_files`, `InheritingAgents.test_an_agent_that_inherits_runs_on_the_parents_model_and_gets_no_pick` | | The Agent tool sets `effort` "ONLY when the user, or instructions such as CLAUDE.md or a skill, explicitly ask" (the Agent tool's type in `claude-code-tools/index.d.ts`; [sub-agents](https://code.claude.com/docs/en/sub-agents.md#choose-an-effort-level)) | `hooks._rules` and the `route` skill give a model and an effort for each kind of work and ask every call to name both | `test_session_start_explains_automatic_routing`, `test_each_eval_case_routes_as_expected` | | An agent's `tools` is a comma list or YAML list and inherits every tool when omitted; `disallowedTools` removes tools from it, and an entry with a specifier removes the whole tool. Explore and Plan have read-only tools ([frontmatter](https://code.claude.com/docs/en/sub-agents.md#frontmatter-reference), [built-in subagents](https://code.claude.com/docs/en/sub-agents.md#built-in-subagents)) | `agents.parse` reads both lists in each form YAML gives them (comments, a flow list over several lines, `- item` lines at any indent), and `agents.read_only` counts an agent as read-only when Edit, Write, NotebookEdit, Bash, PowerShell and Monitor are all out of reach. A list it can't read with confidence counts as every tool | `AgentTools.test_the_tool_lists_are_read_in_every_frontmatter_form`, `AgentTools.test_a_tool_list_that_cant_be_read_with_confidence_counts_as_every_tool`, `AgentTools.test_an_agent_reads_only_when_it_can_edit_write_or_run_nothing` | | Project subagents are found walking up from the working directory to the repository root, the closest winning, they outrank `~/.claude/agents`, and each folder is scanned recursively ([subagent scope](https://code.claude.com/docs/en/sub-agents.md#choose-the-subagent-scope)) | `agents.find` searches `config.project_folders`, nearest first, then the user's folder, each walk at most 10 folders deep and 20,000 entries | `ProjectFromASubfolder.test_inside_a_submodule_its_agent_comes_before_the_users_as_claude_code_takes_it`, `AgentFoldersARepositoryControls.test_the_walk_stops_at_its_depth_and_its_entry_count` | | An agent's `model` takes an alias or a full ID ([frontmatter](https://code.claude.com/docs/en/sub-agents.md#frontmatter-reference)) | `agents.parse` reads it and keeps an explicit `inherit` apart from a missing field, reads `model: null` and `model: ~` as no model, reads a file with CRLF line ends as one with LF, and `router.decide` keeps it within the cap and the floor and never swaps an ID the agent names | `test_agents_that_name_a_model_keep_it_within_the_cap`, `NewestOnProviders.test_a_version_the_caller_or_the_agent_names_is_left_alone`, `AgentFilesThatAreRead.test_the_line_ends_of_a_file_make_no_difference_to_its_model` | | Teammates and workflow agents take their model in the subagent order, with a mod's `agent.spawn` model first ([agent teams](https://code.claude.com/docs/en/agent-teams.md#specify-teammates-and-models), [workflows](https://code.claude.com/docs/en/workflows.md#cost)) | `mod.spawn` routes both like subagents, and `spawn.facts` never redoes a workflow stage | `Mod.test_workflow_stages_and_teammate_roles_without_a_file_are_routed`, `Mod.test_a_workflow_stage_is_never_redone` | | A subagent or teammate on the main conversation's model with no other level runs at the session's level ([model configuration](https://code.claude.com/docs/en/model-config.md#effort-level-of-subagents-and-teammates)) | `router._session_floor` never sets less there. The mod reads the level from the main loop's `turn.step`, the fallback from `effort.level` (`spawn.facts`) | `test_an_agent_on_the_sessions_own_model_runs_at_least_at_the_sessions_effort`, `test_the_sessions_effort_counts_only_for_a_call_from_the_main_conversation`, Node "the main loop's effort reaches mod-spawn, and the agent steps at the effort the CLI decided" | | `CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL` runs every workflow agent on one model. Only the changelog lists it, in the notes for 2.1.296 ([changelog](https://code.claude.com/docs/en/changelog.md)); the environment variables page doesn't | `router.decide` sets only the effort of a workflow agent whose script names no model | `MachineReadable.test_a_workflow_model_pin_keeps_its_model_and_the_router_sets_only_effort` | | Claude Code skips a project or user agent file with no `name`, with a `name` that starts with `-`, contains `:` or is longer than 256 characters, or with no `description`, and a plugin agent with no `name` loads under its filename ([subagent files Claude Code skips](https://code.claude.com/docs/en/sub-agents.md#subagent-files-claude-code-skips)). An empty `description`, or a `name` or `description` that YAML reads as no text, such as `5` or `true`, counts as none, observed on Claude Code 2.1.329 and 2.1.332 | `agents.parse` reads no agent from such a file, so `agents.find` goes on to the next source | `SkippedAgentFiles.test_a_project_file_with_no_name_is_skipped_so_a_user_agent_of_its_stem_is_found`, `SkippedAgentFiles.test_a_file_whose_name_claude_code_refuses_or_that_has_no_description_is_skipped` | | A fork has its parent's model and history ([forks](https://code.claude.com/docs/en/sub-agents.md#fork-the-current-conversation)) | `router.decide` keeps a fork, and the mod passes forks and resumed runs through | `test_fork_is_never_touched`, Node "forks and resumed runs pass through with no CLI call" | | An agent's `effort` overrides the session's, and a call can pass its own ([effort level](https://code.claude.com/docs/en/sub-agents.md#choose-an-effort-level)) | `router._effort_decided`: an effort is set only when the call, the agent, `CLAUDE_CODE_EFFORT_LEVEL` and `CLAUDE_CODE_SUBAGENT_EFFORT` set none. A "Redo:" call climbs past the agent's own (`router._redo`) | `test_an_agents_own_effort_and_a_callers_effort_are_kept`, `test_a_redo_of_the_architect_climbs_past_its_own_model_unless_the_call_names_one` | | `CLAUDE_CODE_SUBAGENT_EFFORT` doesn't apply to forks, forked skills or teammates ([environment variables](https://code.claude.com/docs/en/env-vars.md#variables)) | `router._env_effort` skips it for a teammate | `test_the_subagent_effort_variable_does_not_reach_a_teammate` | | A `maxEffortLevel` cap still applies under `CLAUDE_CODE_EFFORT_LEVEL` ([environment variables](https://code.claude.com/docs/en/env-vars.md#variables)) | `router.capped` holds each effort it sets to the lowest cap of any settings source (`allowlist.Allowlist.effort_cap`) | `Mod.test_a_max_effort_level_holds_every_effort_the_router_sets`, `Allowlist.test_max_effort_level_caps_each_family_at_the_lowest_source` | | Start Haiku 5.5 at `medium` for most work, agentic coding included, Sonnet 5.5 at `medium` for well-specified agentic coding and `high` for harder or longer work, and Fable 5.2 at `high` ([effort](https://platform.claude.com/docs/en/build-with-claude/effort)) | `ladder.effort_on` gives a named model with no effort its lowest level's: `medium` on Haiku and `high` on Sonnet, Opus and Fable | `test_the_shipped_ladder`, `test_a_model_named_on_the_call_is_kept_and_gets_its_rungs_effort` | | When quality falls short, restore lowered effort, else try the next tier up at its default effort ([cost and intelligence](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#start-here)), and start the next model up at a lower effort level than the smaller one ran at ([which model to build with](https://claude.dev/blog/which-claude-model-should-you-build-with)) | `router._redo`: one effort step while the run it redoes was below `high`, else the next stronger usable model one effort level below that run's and at least `medium`, else one more step | `test_a_redo_raises_effort_below_high_and_moves_model_from_high`, `Router.test_a_redos_stronger_model_starts_one_effort_level_below_the_run_and_never_below_medium` | | Switching the conversation's model makes the next request read the whole history uncached ([prompt caching](https://code.claude.com/docs/en/prompt-caching.md#switching-models)) | No hook changes the conversation's model, and the mod's `turn.step` changes effort only for a subagent. The session check runs `/model` only for a setup the person picks, once per session, and only while the conversation has no prompt in it | Node "a main-loop turn's start in the session the layers went to asks the runtime nothing, and its effort is left alone", Node "a first turn that starts before the question is on screen keeps it away for the session", `SessionCheck.test_it_asks_once_per_session` | | `updatedInput` replaces the whole tool input ([PreToolUse](https://code.claude.com/docs/en/hooks.md#pretooluse-decision-control)) | `fallback._rewritten_input` keeps every field and changes only `model` and `effort`, and `hooks.pre_agent` rewrites no call whose input didn't parse | `test_a_rewrite_changes_two_fields_and_approves_nothing`, `test_an_agent_call_whose_input_does_not_parse_is_left_alone` | | Exit code 2 blocks, and any other failure lets the action go ahead unless the hook sets `onFailure: "block"`, which these hooks don't. On Windows without Git Bash a failing shell-form `PreToolUse` hook can block instead. These hooks are exec form, `command` plus `args` ([exit codes](https://code.claude.com/docs/en/hooks.md#exit-code-output)) | `scripts/model-router.sh` ends a hook with 0, or 1 on an error, never 2, and 0 when no Python runs; `cli.main` exits 1 on an exception a handler raised, so Claude Code shows a hook error notice | `Launcher.test_a_hook_command_never_exits_2`, `NoPython.test_every_hook_exits_0_and_a_command_explains`, `test_hooks_never_break_on_garbage`, `SpawnAnswer.test_a_handler_that_raises_exits_1_naming_only_its_type_and_place`, `Shipped.test_hooks_call_existing_commands` | | The Stop input's `background_tasks` lists tasks in flight, unknown types included ([Stop input](https://code.claude.com/docs/en/hooks.md#stop-input)) | `gates.still_running` holds the check while any task is listed | `test_background_work_still_running_holds_the_check_and_keeps_the_ask`, `test_the_check_waits_for_any_background_task` | | A Stop hook gives guidance through `additionalContext` ([Stop decision control](https://code.claude.com/docs/en/hooks.md#stop-decision-control)) and can enforce a check ([best practices](https://code.claude.com/docs/en/best-practices.md#give-claude-a-check-to-run)) | `hooks.stop` returns the ask as `additionalContext`, once per batch of project edits no check followed (`gates.before_stop`). It runs nothing itself | `test_the_ask_is_guidance_for_any_kind_of_work_and_names_no_reviewer`, `Gates.test_asks_once_when_work_changed_and_nothing_checked_it` | | Internal agents fire `SubagentStop` with an empty `agent_type` unless the session runs as an agent (`--agent` or the `agent` setting), and a matcher that can't match "" skips them ([SubagentStop](https://code.claude.com/docs/en/hooks.md#subagentstop)) | `hooks/hooks.json` matches `.` | `Shipped.test_agent_hooks_match_the_agent_tool_and_skip_internal_agents` | | A `SubagentStop` hook's output goes to the subagent, and context for the parent session after a subagent returns comes from a `PostToolUse` hook on the `Agent` tool ([SubagentStop](https://code.claude.com/docs/en/hooks.md#subagentstop)). A `UserPromptSubmit` hook's `additionalContext` is wrapped in a system reminder and inserted where the hook fired ([add context for Claude](https://code.claude.com/docs/en/hooks.md#add-context-for-claude)), and that hook fires for a background agent's notification (measured on 2.1.332) | `hooks.agent_stopped` blocks nothing. It keeps a line about the project files the subagent's shell changed, and the main conversation gets it from `hooks.post_agent`, `hooks.user_prompt` or `hooks.stop`, whichever runs first. The line that no check has run on an agent's work goes the same two ways | `SubagentChecks.test_the_main_conversation_is_told_once_about_a_file_an_agents_shell_changed`, `SubagentChecks.test_a_note_waits_for_whichever_hook_of_the_main_conversation_comes_first`, `SubagentChecks.test_an_agents_work_comes_back_with_a_line_that_no_check_has_run_on_it` | | In auto mode a subagent delivers its report through `SubagentHandback` before it stops, and a `PreToolUse` hook matched on that tool gets the call ([SubagentStop](https://code.claude.com/docs/en/hooks.md#subagentstop)) | `hooks.handing_back` keeps the line at that call and lets the call through, and `hooks.agent_stopped` adds nothing once a report is back | `SubagentChecks.test_an_agent_that_hands_its_report_back_is_noted_at_the_hand_back` | | `agent_type` is present on the main thread of a session started with `--agent` ([common input fields](https://code.claude.com/docs/en/hooks.md#common-input-fields)), and a teammate in a terminal pane of its own is such a session (measured on 2.1.332: its `SessionStart` input carries its agent type) | `hooks._delegating` leaves delegation out of that session, and `mod.check` asks it nothing | `Notes.test_a_session_that_runs_as_an_agent_is_not_told_to_hand_its_work_out`, Node "a session that runs as an agent says so to the runtime at its start and at the session check" | | An Agent result reports `resolvedModel`, and `modelsUsed` when the model was swapped ([hooks](https://code.claude.com/docs/en/hooks.md)) | `hooks.post_agent` records the model that ran (`health.ran`), and a swapped run counts as no evidence (`calls.models_used`) | `test_results_teach_the_registry_which_models_really_run`, `Health.test_a_swapped_run_is_no_evidence` | | The type files Claude Code writes for your build are the ones to trust ([types](https://code.claude.com/docs/en/plugins/mods/create.md#get-type-definitions-for-your-version)) | Each event and field `hooks/router.ts` reads outside `tool.call` is checked against those types, and in CI against Claude Code's published ones (`tests/mod/typecheck.sh`) | `ModApiTypes.test_router_ts_uses_only_events_and_fields_the_types_declare`, `Workflows.test_the_type_check_also_runs_the_mod_field_check_on_the_types_it_downloads` | | `agent.spawn` takes a model through `next` ([subagent starts](https://code.claude.com/docs/en/plugins/mods/reference.md#subagent-starts)), and `turn.step` takes a model ([follow a turn](https://code.claude.com/docs/en/plugins/mods/events.md#follow-a-turn)) and an effort (mod API types `TurnStepInput`) | `hooks/router.ts` sets a spawn's model in `agent.spawn` and its effort in `turn.step` | Node "a spawn passes the pick model to next" and "a routed agent steps at the pick effort" | | Plugins' `PreToolUse` hooks run after the last mod calls `next` ([order](https://code.claude.com/docs/en/plugins/mods/events.md#where-settings-hooks-run-in-the-order)) | The mod's `tool.call` hook marks each `Agent` call it will route, and the fallback stands down only for a marked call (`mod.routes`) | `Mod.test_the_settings_hook_stands_down_only_for_a_call_the_mod_marked`, Node "an Agent call is marked for the fallback only while the runtime answers" | | `$.agent.list()` gives each subagent's tokens per model and a client-side cost estimate, and lists no workflow agent (mod API types `AgentInfo`, `SessionCost`; [mods reference](https://code.claude.com/docs/en/plugins/mods/reference.md)) | `agentUsage` in `hooks/router.ts` sends those figures at a subagent's turn end, and `/model-router:usage` labels the dollars an estimate | Node "a subagent's turn end sends Claude Code's own figures for it, and the main loop's sends nothing", `Reports.test_usage_report` | | A `tool.call` hook answers a call with `{ deny: reason }` and no `next`, and Claude reads the reason as the tool's result; it fires for a subagent's calls too ([guard or change a tool call](https://code.claude.com/docs/en/plugins/mods/events.md#guard-or-change-a-tool-call)) | Under `delegation: strict`, the mod's second `tool.call` hook refuses a main-conversation work call once the total reaches the threshold, and skips every call with an `agentId`, so a subagent's own calls are never counted or refused | Node "strict: the first call after the total reaches after is refused without running, until an agent starts" | | Where a session uses the built-in `web-fetch` subagent, Claude reads a web page with an `Agent` call for it and the main conversation has no `WebFetch` tool of its own. The subagent runs on Haiku, or on the conversation's model where `availableModels` leaves Haiku out, and other subagents still call `WebFetch` themselves ([the web-fetch subagent](https://code.claude.com/docs/en/tools-reference.md#which-model-the-web-fetch-subagent-runs-on), [sub-agents](https://code.claude.com/docs/en/sub-agents.md#built-in-subagents)) | The mod counts an `Agent` call for `web-fetch` as a work call, and its start sets no total back, so a page read is no hand-off. Under `strict` a refused one is told to give the page to another agent. The router finds no definition for it and leaves its model alone | Node "the built-in web-fetch agent reads a page for the conversation: its call is work, and its start resets nothing", `ModStartRules.test_mod_start_answers_the_delegation_the_mod_enforces`, `Router.test_the_built_in_web_fetch_agent_is_left_on_claude_codes_own_model` | | `engines`, `network` and `userConfig` are manifest fields ([manifest](https://code.claude.com/docs/en/plugins/manifest-reference.md#fields)) | `plugin.json` requires Claude Code 2.1.329 or later, declares no `network` hosts and offers six options | `Shipped.test_the_claude_code_floor_is_the_version_the_manifest_and_teammate_effort_need`, `SecurityClaims.test_nothing_shipped_opens_a_connection`, `Shipped.test_the_cli_takes_every_option_plugin_json_declares` | | Options reach hooks as `CLAUDE_PLUGIN_OPTION_` and skill content as `${user_config.KEY}` ([user configuration](https://code.claude.com/docs/en/plugins/manifest-reference.md#reference-a-saved-value)) | `settings.resolve` reads the variables, and for `delegation` also `EVAL_MODEL_ROUTER_DELEGATION`, ahead of the option, since a plugin eval case passes only `EVAL_*` variables. It reads that one only when the plugin's own files run from outside a plugin cache, so an installed plugin ignores it. The `route` and `models` skills pass `${user_config.*}` as flags, and one left unsubstituted keeps its default (`cli.main`) | Node "plugin options reach the CLI env", `Options.test_an_eval_variable_beats_the_delegation_option_unless_it_is_empty`, `Options.test_an_installed_plugin_ignores_the_eval_variable`, `test_each_skill_command_that_reads_the_options_passes_them_all`, `test_a_line_with_an_option_left_unsubstituted_still_runs_on_the_defaults` | | `plugin validate --strict` treats warnings as errors ([CLI reference](https://code.claude.com/docs/en/plugins/cli-reference.md#plugin-validate)) | CI's `validate` job runs it on the manifest's floor and on `latest` | `Workflows.test_validate_runs_on_the_engines_floor_and_latest` | | Users get a new copy only when the plugin's computed version differs ([host a marketplace](https://code.claude.com/docs/en/plugins/host-marketplace.md)) | CI's `version` job fails a plugin change that keeps a version the base branch has carried since its first release (`tools/plugin_version.py`) | `PluginVersion` tests, `Workflows.test_the_version_job_runs_the_version_check` | | `allowed-tools` grants tools without asking ([skills](https://code.claude.com/docs/en/skills.md#frontmatter-reference)) | Each skill grants only the launcher commands it runs | `SkillGrants.test_each_skill_may_run_its_own_commands_and_nothing_that_writes_files` | | `autoCompactWindow` in a subagent's frontmatter makes it compact earlier, at a token count of `100000` or more, and needs Claude Code v2.1.296 or later ([auto-compact window](https://code.claude.com/docs/en/sub-agents.md#set-the-auto-compact-window-for-one-subagent)). Haiku 5.5 charges 5 times more per token once a prompt passes 100,000 tokens ([long context pricing](https://platform.claude.com/docs/en/about-claude/pricing#long-context-pricing)) | `scout`, `verifier` and `implementer`, the Haiku agents, set `autoCompactWindow: 100000`. The manifest's floor, 2.1.329, is above 2.1.296 | `Shipped.test_the_haiku_agents_compact_at_the_documented_minimum_and_no_other_agent_sets_a_window` | | `tools` limits what an agent can use ([frontmatter](https://code.claude.com/docs/en/sub-agents.md#frontmatter-reference)) | `architect`, `reviewer`, `scout` and `verifier` list their `tools`, and each description says it writes nothing or doesn't fix code | `Shipped.test_read_only_role_agents_say_they_write_nothing` | | A hook's `updatedInput` with no `permissionDecision` can be denied in auto mode ([auto mode](https://code.claude.com/docs/en/hooks.md#pretooluse-updatedinput-in-auto-mode)) | `fallback._guard` passes a refused rewrite through untouched the next time, or denies it with the model to use when its untouched model is over `max_tier`, or under `min_tier` for a raise that didn't take. Nothing approves a call | `RepeatGuard.test_refused_rewrites_never_count_against_the_model`, `RepeatGuard.test_the_cap_holds_even_when_a_lowering_rewrite_did_not_take`, `MinTier.test_a_refused_raise_is_denied_like_a_refused_lowering`, `SecurityClaims.test_it_never_approves_a_tool_call` | | A managed `availableModels` applies alone, other lists are joined, and `deniedModels` counts only in managed settings ([restrict model selection](https://code.claude.com/docs/en/model-config.md#restrict-model-selection)) | `allowlist.from_layers`, on the settings layers the mod sends | `test_a_managed_list_applies_alone_else_the_other_sources_are_concatenated`, `Allowlist.test_denied_models_count_only_in_policy_and_block_a_family_only_by_name` | | A blocked family alias moves to the newest permitted version only on the Anthropic API and Claude Platform on AWS ([restrict model selection](https://code.claude.com/docs/en/model-config.md#restrict-model-selection)) | Elsewhere `allowlist.Allowlist.permitted` counts a family only when the version its alias runs, or the ID the mod sends instead, is permitted | `test_a_blocked_alias_counts_only_where_it_moves_or_a_permitted_version_runs` | | With `availableModelsMatch` set to `exact`, a model ID entry permits the version it names and its dated ID, a family alias still permits its family, and `best`, `opusplan` and `default` entries are ignored ([availableModelsMatch](https://code.claude.com/docs/en/settings-reference.md#availablemodelsmatch)) | `Allowlist.lists_permit` matches an exact entry to itself and to itself plus a hyphen and 8 digits, and `allowlist.from_layers` drops the three entries from an exact list | `test_an_exact_entry_permits_its_dated_id_and_nothing_longer`, `test_an_exact_list_ignores_best_opusplan_and_default_entries` | | Any `[1m]` suffix is stripped from both an `availableModels` entry and the requested model before matching ([pin models for third-party deployments](https://code.claude.com/docs/en/model-config.md#pin-models-for-third-party-deployments)) | `allowlist.Allowlist.lists_permit` drops the suffix from each allow entry and from the ID, on every provider, and checks a deny entry against the ID with and without it | `OneMillionSuffix.test_a_requested_id_with_the_suffix_matches_an_entry_without_it_and_the_reverse`, `OneMillionSuffix.test_a_deny_entry_catches_a_request_with_the_suffix_as_well_as_without_it`, `OneMillionSuffix.test_a_deny_entry_with_the_suffix_blocks_that_variant_only` | | `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1` removes `CLAUDE_CONFIG_DIR` from the environment of a hook ([what the scrub removes](https://code.claude.com/docs/en/env-vars.md#what-the-subprocess-environment-scrub-removes)) | `store.claude_home` reads the config folder from `CLAUDE_PLUGIN_DATA` when it ends in `plugins/data/`. A hook still has `CLAUDE_PLUGIN_DATA` with the scrub on, measured on Claude Code 2.1.332 (the docs do not say so). | `ClaudeHomeWhenHooksLoseTheConfigFolder.test_the_folder_above_plugins_is_read_from_the_data_path`, `ClaudeHomeWhenHooksLoseTheConfigFolder.test_another_data_path_shape_falls_back_to_the_default` | | `effortLevel`, at the top level of a settings file or in a `modelSettings` entry, takes `low` to `xhigh`, and `max` isn't accepted in either ([adjust effort level](https://code.claude.com/docs/en/model-config.md#adjust-effort-level)) | `allowlist._layer` and `allowlist._caps` read an `effortLevel` of `max` as unset and keep `max` for `maxEffortLevel` | `test_an_effort_level_of_max_is_unset_while_a_max_cap_still_counts` | | A `fallbackModel` chain moves a subagent off an unavailable model for the current turn ([fallback model chains](https://code.claude.com/docs/en/model-config.md#fallback-model-chains)) | `health.failed` adds memory across turns: two model errors route a model around for a day | `Health.test_two_model_errors_route_a_model_around_for_a_day_and_never_longer` | | Aliases resolve per provider, and on Bedrock `sonnet` and `haiku` can be older versions. Mantle alone has a row of its own: `sonnet` is Sonnet 5 and `haiku` is Haiku 4.5 ([model aliases](https://code.claude.com/docs/en/model-config.md#model-aliases)) | Where an alias lags, `mod._newest` sends the family's newest ID (`Registry.newest_id`), and where it can't, the router's own pick moves one family up (`Registry.past_lag`). `settings._provider` reads Mantle alone as `mantle`, with that row in `older_aliases` for the session check and the older-model reading, but Mantle serves only some versions, so `ALIAS_ONLY` keeps its aliases going through with no newer ID and no pick moved. A host-managed provider, or Mantle with another provider, gets aliases only | `NewestOnProviders.test_each_lagging_alias_gets_its_familys_newest_id`, `test_the_shipped_ids_belong_to_their_families`, `test_mantle_keeps_its_alias_row_but_sends_no_newer_id_and_moves_no_pick`, `test_the_provider_comes_from_the_documented_switches`, `test_a_lagging_pick_moves_one_family_up_at_most`, `test_a_host_managed_provider_sends_only_aliases` | | Set `model: haiku` on a subagent whose work is simple ([best practices](https://code.claude.com/docs/en/best-practices.md#know-what-subagents-cost)) | `scout` and `verifier` set `haiku`, and the session note pairs Haiku with finding, reading and listing | `Shipped.test_the_role_agents_carry_their_model_and_effort`, `test_session_start_explains_automatic_routing` | | `$.ui.status(text)` pins one line under the prompt, one per plugin, until the next call replaces it (mod API types; [mods API](https://code.claude.com/docs/en/plugins/mods/api.md#show-something-without-starting-a-turn)) | `report.status` builds the line, under 100 characters, and `shown` in `hooks/router.ts` pins it | `StatusLine.test_it_stays_under_100_characters`, Node "the status line follows each spawn and each main-loop turn, with the setup its request carried" | | A command from `$.command.register` runs its `command.run` hook with no Claude turn, and `isTextDisplayOnly` keeps an idle run's text out of requests (mod API types `CommandSpec`, `CommandRunResult`; [mods overview](https://code.claude.com/docs/en/plugins/mods/overview.md#what-a-mod-can-do)) | `/model-router` in `hooks/router.ts` answers from `mod-status` | Node "/model-router prints the runtime state for the person alone", Node "/model-router off and on switch routing for this session and redraw the line" | | `session.start`'s `isInteractive` is false for a `-p` run and the SDK (mod API types `SessionStartInput`) | The mod draws, asks and registers its command only when it is true | Node "a headless run registers, draws and asks nothing, and routes as before" | | `session.start` fires again each time a mod reloads ([write a mod yourself](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself)). A change to a plugin's options reloads it (mod API types `Register`; no docs page says it, so the `config.set` hook and its tests rely on the types alone) | `session.check` marks the session checked in `switches.json` before it answers, so a reload asks nothing | `SessionCheck.test_it_asks_once_per_session` | | `$.command.run` runs a slash command as typed, and rejects inside a hook the session's start waits on (mod API types) | The session check starts from `$.clock.after` once `session.start` has returned | Node "an interactive start registers the command, shows the status line and asks only after the hook returned" | | `$.ui.ask` takes 2 to 4 labels and resolves to the one picked or to typed text, and rejects when dismissed (mod API types `AskOptions`) | `session.check` offers at most four, and `walk` in `hooks/router.ts` acts only on a label it sent | `SessionCheck.test_step_one_offers_each_usable_model_then_stay`, Node "a dismissal or free text at either step changes nothing" | | Typing `/model ` or `/effort ` saves the pick as the default for new sessions, the same as `Enter` in the picker. `s` in the picker applies it to this session only. `max` lasts the session only unless `CLAUDE_CODE_EFFORT_LEVEL` sets it ([setting your model](https://code.claude.com/docs/en/model-config.md#setting-your-model), [effort level](https://code.claude.com/docs/en/model-config.md#adjust-effort-level)) | The session check's questions and labels say so | `SessionCheck.test_step_two_offers_each_familys_efforts` | | The session's effort comes from `CLAUDE_CODE_EFFORT_LEVEL` (`auto` or `unset` sends none, so the API's default applies, or Claude Code's default lowered to a `maxEffortLevel` cap; its value is read in any letter case, observed on Claude Code 2.1.329 and 2.1.332), a pick in the session, `--effort`, then the settings files, a model's `modelSettings` level over its file's `effortLevel` and a user file's top-level `effortLevel` not counting for Opus 5.5 and later, then the model's default, `medium` on the current models ([model configuration](https://code.claude.com/docs/en/model-config.md#adjust-effort-level), [modelSettings](https://code.claude.com/docs/en/settings-reference.md#modelsettings)) | `session.effort_on` and `Allowlist.saved_effort` estimate it before the first request (`saved_effort` skips a user file's top-level `effortLevel` for every model, so a session on an older one is estimated without it), with `--effort` read from the session's command line by `launchEffort` in `hooks/router.ts`; the main loop's `turn.step` gives it after | `SessionCheck.test_the_effort_estimate_follows_claude_codes_order`, `SessionCheck.test_an_effort_flag_at_launch_counts_ahead_of_the_settings_files`, `SessionCheck.test_an_effort_left_to_the_api_is_estimated_at_the_api_default`, `SessionCheck.test_an_effort_left_to_the_api_under_a_cap_is_estimated_at_the_cap`, `SessionCheck.test_a_request_records_the_exact_setup`, Node "an effort flag at launch reaches the session check, and nothing else of the command line does" | | `availableModels` makes Claude Code reject a `/model` it blocks, and `maxEffortLevel` runs a higher level at the cap ([restrict model selection](https://code.claude.com/docs/en/model-config.md#restrict-model-selection), [maxEffortLevel](https://code.claude.com/docs/en/settings-reference.md#maxeffortlevel)) | The session check leaves out a blocked family and holds the efforts it offers | `SessionCheck.test_the_recommended_and_strongest_marks_follow_what_is_usable`, `SessionCheck.test_max_effort_level_holds_the_efforts_and_drops_a_family_below_its_floor` | | A plugin's `/config` row is keyed `.` and has `isLocked` true when a trusted source owns it, and `$.config.set` answers `{ deny }` when it can't write (mod API types `ConfigRow`, `ConfigSetResult`) | `setCheck` in `hooks/router.ts` writes `model-router.session_check` and reports a `{ deny }`, naming managed settings when the row is locked; `locked` tells the session check whether it may offer the write | Node "/model-router check off and on write the option, unless managed settings own it" | | `config.set` fires for a `/config` row about to change, from the menu or another plugin's `$.config.set` but not the plugin's own, and `{ deny }` leaves the row as it was with the reason shown; `$.agent.list()` gives each subagent and teammate its `status` (mod API types `ConfigSetInput`, `ConfigOrigin`, `ConfigSetResult`, `AgentInfo`) | The `config.set` hook in `hooks/router.ts` refuses a change to `model-router.*` while a main-loop turn runs or an agent whose effort it set is working (an idle teammate holds nothing), and `/model-router check` checks the same before its own write | Node "a change to this plugin's options in /config is refused while Claude works or an agent the router set the effort of runs", Node "/model-router check on or off while Claude works or a routed agent runs writes nothing, since an option change reloads the mod" | | `$.session.model()` returns the main loop's model (mod API types) | The mod confirms a switch by the family it returns before it sets an effort | Node "a switch that fails says so and stops, and one Claude Code did not take says the session stayed" | | `session.end` carries the ending session's id, a `/clear` ends one (mod API types `SessionEndInput`), and Claude Code 2.1.333 also fires it when Claude Code restarts itself, as on `/tui`, and with the reason `unload` when the mod's plugin is turned off or uninstalled ([changelog](https://code.claude.com/docs/en/changelog.md)) | `mod-end` drops that session's switch and check (`settings.forget`) on a `/clear` only; any other end leaves them, and a write to the switches file drops an entry that is a day old, since the same session can follow it | `ModCommands.test_check_answers_the_question_and_end_forgets_the_session`, Node "a session switched off leaves a call whose round trip fails as named, and a clear forgets the switch", Node "an end that is not a clear, a reason the plugin does not know included, sends no mod-end and keeps a /model-router off switch for the same session" |