# Model Router A plugin for Claude Code that makes the main session hand work to agents and keeps each agent's model and effort within the limits you set.

version 0.2.4 Claude Code 2.1.329 or later Python 3.9 or later dependencies: none, standard library only license: Apache-2.0 Discord: join the chat

Model Router tells the main session that it coordinates and that agents do the work, and where its mod runs it reminds Claude to hand work over once the session has done a lot of it itself, then refuses the next work call until an agent starts. Claude names a `model` and `effort` on each Agent call, from a short table Model Router adds at session start: Haiku at `medium` for finding and reading, Haiku at `high` for writing and fixing to a brief that settles the approach, and Opus at `high` for work with an open approach or no check to run, such as a design, a review or a rewrite. The note also says an agent's report is a claim: work no check ran on gets a review by a second agent before it counts. Model Router holds those choices to your limits, fills in what a call leaves out, routes around a model that fails, and runs a call marked "Redo:" one step higher. That is `delegation` at `strict`, the default. It keeps the session's own context small and puts a second look on work no check ran, and it costs more on small jobs: on five quick tasks with an Opus session and a brief sent as it is, a stock session cost 34% less per solved task than the plugin at `strict` with its reviews on Sonnet (26% less per run at the median), and every setup solved 10 of 10 ([the rounds](docs/BENCHMARKS.md#decision-rounds)). No round here measured a long coordinating session or the correctness of its output. Set `delegation` to `off` for small jobs done in the main session, which keeps the routing table and drops the rest, or to `on` for the paragraph and a reminder without the refusal. With `delegation` off, the plugin cost 13% more per run at the median than a stock session on the same tasks (20 runs). Model Router is an independent project, not made or endorsed by Anthropic. ## Install ```text /plugin install model-router --marketplace crisnahine/claude-code-model-router ``` From a shell, `claude plugin install` takes the same arguments. `claude plugin update model-router@claude-code-model-router` updates it. The [guide](docs/GUIDE.md#install-update-and-uninstall) covers scopes and uninstalling. ## Requirements Claude Code 2.1.329 or later, `sh`, and Python 3.9 or later as `python3` or `python` on your `PATH`. Without Python the hooks do nothing, and the mod only holds a model a call names to `max_tier` and `min_tier`. ## How a call's model is chosen A model named on the call comes first, unless `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` pins every subagent's model. Then come a per-agent rule, the agent's own `model` (`inherit` means the parent's), `CLAUDE_CODE_SUBAGENT_MODEL`, and last a level from the agent's tools: `lookup` for one that can't edit, write or run commands, else `standard`. Unless an environment variable set it, Model Router holds the model to your cap, your floor and the usable models, raises it to a rule's `level`, and gives it that level's effort when nothing sets one. A call left on its parent's model gets no effort. The [guide](docs/GUIDE.md#who-decides-the-model) has the full order and [the levels](docs/GUIDE.md#the-ladder). ## Redo Claude marks a redo by starting the call's `description` with "Redo:". It climbs from the latest run of the same agent and description that finished in this session in the last 30 minutes, else from what the call would run at unmarked: one effort step up while that run was below `high`, else the next stronger usable model, started one effort level below that run and never below `medium`, else one more effort step. A redo that names more than that run runs as named. Workflow stages are never redone. ## The check before a turn ends When Claude or a subagent changed a project file with Edit, Write or NotebookEdit and no test runner, linter or type checker ran since, the `Stop` hook asks Claude once to run the work's own check. A project file an agent's shell changed counts as an edit too, and so does one Claude itself wrote through a shell heredoc or, in PowerShell, a here-string. When an agent made the change, the ask says its report is the only word on the work, and for work with no check to run (a document, an analysis, code no test covers) it asks for a review by `model-router:reviewer`. An agent whose name says it reviews, such as `model-router:reviewer`, counts as the check when it started after the edit and read files. It never asks while background work runs. When an agent's shell command changed a project file, the plugin tells the main session which files, beside the agent's report when it comes back. A helper that rewrites a page as a side effect then shows to the main session even when the report leaves it out, and the agent isn't sent back to write its report again. When an agent's work comes back and no check has run on it, the plugin says so beside the result, so the check or the review starts before Claude writes its closing reply. ## In a session Where its mod runs and a person is at the prompt, a line under the prompt shows the state, such as `auto · mod · cap opus · 14 calls · 5 changed · 2 redos`: the routing mode, the path that routed the latest call, the cap, the floor (`floor sonnet`, when set), and this session's subagent calls, changes and redos. When such a session starts below the setups Model Router recommends for the main session (Opus or Fable at `medium` effort or higher, Sonnet at `high` or higher), it asks once, before your first prompt, which model and then which effort to run on, or to stay. A pick runs Claude Code's `/model` and `/effort`, which Claude Code keeps as your default for new sessions (`max` lasts this session only). It never asks once the conversation has a prompt in it. ## Options In `/config`: - `routing_mode`: `auto` (default), or `off` to leave every call as it is, with no session note, no check before a turn ends and no session check. - `max_tier`: `none` (default), `haiku`, `sonnet`, `opus` or `fable`, the strongest model a subagent may run on. - `min_tier`: `none` (default), `sonnet`, `opus` or `fable`, the weakest model a subagent may run on. A weaker one is raised to it, at the same level and effort. A `max_tier` weaker than `min_tier` wins. - `verify_gate`: `true` (default) or `false`, the check before a turn ends. - `session_check`: `ask` (default) or `off`, the question at session start. - `delegation`: `strict` (default), `on` or `off`, how hard the plugin pushes the main session to hand work to agents ([delegation](docs/GUIDE.md#delegation)). Per-agent rules go in `~/.claude/model-router.json`, or in a project's `.claude/model-router.json`, which can only raise ([rules files](docs/GUIDE.md#rules-files)). ## Commands - `/model-router [on | off | check on | check off]`: the status line, the session's model and effort, and how to switch. `on` and `off` switch routing for this session only; `check on` and `check off` set `session_check`. It answers with no model turn. - `/model-router:route [task]`: which model and effort fit a task, and what a call would run on. - `/model-router:models [reset]`: which models are in use, capped, below your floor, blocked or routed around. `reset` clears what it learned about them. - `/model-router:usage [days]`: calls per agent with levels and models, redos, tokens per model and Claude Code's cost estimate per subagent (default 7 days). Its five agents are `model-router:scout` and `verifier` on Haiku at `medium`, `implementer` on Haiku at `high`, and `architect` and `reviewer` on Opus at `high`. ## What it stores Its state is in the plugin's data folder, readable only by you on macOS and Linux. The ledger keeps what each call ran on and why, and each subagent's tokens and cost estimate, for 30 days and at most 4 MiB. It stores no prompt, brief or description, and makes no network call of its own. ## What it can't do - It never changes the main conversation's model or effort on its own, and never changes which agent a call runs. - It leaves forks alone, and an agent whose definition it can't find unless the call or your rule names a model. - A cloned repository's `.claude/model-router.json` can raise its agents up to your `max_tier`, and can't leave one below your `min_tier`. - It retries no failed call. After two model errors on a model, or two runs on another model, it routes around that model for a day. - Each hook starts Python ([performance](docs/PERFORMANCE.md)). - Without its mod, a `PreToolUse` hook routes Agent calls, and there is no workflow routing, token count, cost estimate, status line, `/model-router` or session check. ## Benchmark A judged round on 2026-11-25 ran 16 fixed tasks headless from `bench/`, 5 times each, under three setups, with Model Router at version 0.2.0 (tag `v0.2.0`). Each task's own check grades a run. Cost is Claude Code's list-price estimate per solved task. Every prompt tells the session to delegate, so the defaults were told to delegate too. This build ran its `complex` level on Sonnet at `high`, and the shipped build runs it on Opus, so the costs below are for 0.2.0 and the shipped build costs more where that level runs. With `delegation` off, the plugin started no agent in 10 runs on five quick tasks with an Opus session and cost 13% more per run at the median than a stock session on the same tasks (20 runs, [the rounds](docs/BENCHMARKS.md#decision-rounds)). | Session on Opus, 80 runs per setup | Solved | Cost per solved task | | :- | :- | :- | | Model Router | 80 of 80 | $0.183 | | Claude Code's defaults (subagents on the session model) | 80 of 80 | $0.361 | | Every subagent forced onto Haiku at `high` | 78 of 80 | $0.139 | Against the defaults that is a win by the benchmark's rule, fixed before the runs: cheaper per solved task beyond noise, at an equal pass rate. It is a cost result. These tasks can't tell a cheap model from a strong one, so it says nothing about quality. Model Router was slower: on Opus a run took 129 s of wall time on average, against 81 s for the defaults. Against all-Haiku the plugin costs more beyond noise: $0.020 to $0.079 more per solved task (95% interval), and more per run on 15 of the 16 tasks. Its pass-rate interval, 8 points behind to 12 ahead, is too wide for the rule to call that a loss, so the rule's label for this comparison is "no difference shown". As measured, all-Haiku cost less per solved task and solved two fewer runs. What the plugin's complex level and its redo step add over all-Haiku is still unmeasured. A smaller batch on a Fable session (4 tasks, 20 runs per setup) shows no difference against either baseline. In its defaults setup the `Explore` agent ran on Opus, not the session model, for 13% of that setup's cost. Its figures are reported as measured, with no claim: Model Router solved 19 of 20 at $0.319 per solved task, the defaults 18 of 20 at $0.857, and all-Haiku 20 of 20 at $0.292. [docs/BENCHMARKS.md](docs/BENCHMARKS.md) has every table, the method and the limits, and the raw rows are in [`bench/results/`](bench/results/). The 300 runs were paid with an API key. ## Documentation [Guide](docs/GUIDE.md), [questions](docs/FAQ.md), [architecture](docs/ARCHITECTURE.md), [security](docs/SECURITY.md), [performance](docs/PERFORMANCE.md), [Claude Code docs](docs/CLAUDE_CODE_DOCS.md), [changelog](CHANGELOG.md), [contributing](CONTRIBUTING.md), and [every page](docs/README.md). Bugs: [GitHub issues](https://github.com/crisnahine/claude-code-model-router/issues). ## License Apache-2.0. See [LICENSE](LICENSE). Copyright 2026 Cris Nahine.