adminandClaude Opus 5.5 c88884c54a Fix #7: non-dev roles (test-design) are never treated as a dev (0.5.1)
A test-design brief (Pipeline-Role: test-design, Clone: ... (Role: test-design))
that mentioned the dev clone was read as a dev in that clone: it got a T number
and a "no verification: dev ran on Opus" line, also after a resume.

- Role comes from Pipeline-Role:, then (Role: ...) on the Clone: line, then
  the folder name, which must end in -dev, -review or -test. Any other role,
  or a Clone: line the router cannot place, is a non-dev role.
- A non-dev Pipeline-Role never falls back to other clone paths in the brief.
- Non-dev roles and the 0.5.0 gate types (test-designer, release-reviewer):
  named model kept, never Haiku, Opus when none; no hand-back line, no
  verification, no savings record. A gate agent type is never a dev, whatever
  clone paths its brief names.
- T numbers for dev agents only; other agents get A1, A2, ...
- /router log shows the role as written (test-design, test-designer).
- 0.5.0 test updated: a -design clone is now a non-dev role, not "no role".

102 tests; 16 mutations of the new rules, all caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdqPWvuDpbpRvDEdURoAwo
2026-11-17 21:47:25 +01:00
2026-11-06 23:46:30 +00:00
2026-11-06 23:46:30 +00:00

model-router

A Claude Code plugin that picks a model for every subagent, checks dev work on a second model before it reaches a PR, and estimates what that saved compared with running everything on Opus.

What it does

Step Behaviour
Route Dev agents run on Sonnet when the brief decides the approach (Expected / acceptance criteria), on Opus when the design is still open. Review and test agents keep the model they are given (Opus when none). Other non-dev agents (a test-design role, or the test-designer / release-reviewer agent types) do too, but never Haiku. None of them get a hand-back line or verification.
Rerun reported files With testFileCommand set, every file the full run reports as TIMEOUT or FAIL is rerun alone in the clone. A file that still fails or times out alone runs again on the base branch, in a worktree next to the clone (<clone>-verifier-base, removed afterwards). The verifier gets a table: a file that passes alone does not count, one that also fails on base is not caused by the change.
Later instructions Every message sent to a dev agent after its brief (a SendMessage, or the message that resumes it) reaches the verifier as part of the task, so scope added later is judged as in scope. A resumed agent keeps its task number, routing and failure count.
Verify When a dev agent below Opus finishes a round, the router diffs its clone against the merge base, runs the test command in that clone, and has Opus judge the change.
Hand-back line Only dev agents get T numbers and lines; other agents are logged as A1, A2, ... Every dev hand-back gets one line at once: [model-router] Tn verifying on Opus... (a verdict follows), or [model-router] Tn no verification: dev ran on Opus. Go straight to review. Only the real hand-back counts: an interim stop while the dev waits on its own background work (e.g. a long test suite) posts nothing and starts no verifier. Decided by the model the run actually used, not only the routing choice; a difference is shown as (routed to X, ran on Y).
On FAIL 1st: resume the same agent with the issues. 2nd: a new agent one model up, in the same clone. After that: handed back to the manager.
Not verified A test timeout, a test command that cannot run, a missing clone or merge base, or a verdict that cannot be read even after asking once more: reported as NOT VERIFIED, never as a FAIL.
Savings /router savings prices every run on the model it ran on and compares it with the same tokens on Opus 5.5.

Briefs

Every pipeline brief carries these lines:

Pipeline-Role: dev
Clone: /home/homelab/projects/goodwe/clones/<TICKET>-dev/

The role comes from Pipeline-Role: first, then (Role: ...) on the Clone: line, then the folder name (which must end in -dev, -review or -test). Any other role (test-design, ...) is never a dev, whatever other clones the brief mentions; neither is a test-designer or release-reviewer agent. With a ## Test plan section, the verifier checks that every T-id and N-id is covered. Tickets with extra parts (OPT-11-P4) are fine. Name the base branch (Base branch: release/1.0).

Install

/plugin marketplace add <this repo's git URL>
/plugin install model-router@model-router

Or for development: claude --plugin-dir /path/to/model-router.

Settings (/config)

Setting Default Notes
testCommand empty Run in the agent's clone; output goes to the verifier
testTimeoutSec 1800 Wrapped in GNU timeout --verbose; a timeout is NOT VERIFIED
testFileCommand empty Runs one file, {file} replaced by a reported file name; only names of letters, digits, _ . - / are run
testFileTimeoutSec 900 Limit per rerun file
testRerunJobs 6 Reruns at a time
testRerunMax 40 Most files rerun per round
testIssuePattern ^(TIMEOUT|FAIL)\s+(\S+) Group 1 the kind, group 2 the file
defaultBaseBranch release/1.0 After the PR lookup and the brief's own base branch
prBaseCommand empty Optional command that prints the PR's base branch
maxRewrites 2 Failed verdicts before handing back
safetyPatterns control loop, rs485, ... Marks tasks as critical in the log
respectExplicitModel false Keep a named model on agents without a role
allowFable false Rewrite on Fable after Opus fails
prices empty JSON price overrides, USD per MTok

Commands

  • /router: recent decisions, verdicts and savings
  • /router savings [Tn]: the full savings table, or one task
  • /router clear: reset log, records and costs

Tests

claude plugin validate .
claude plugin test .

102 tests. Every routing, verification, cost and timeout rule was also checked by breaking it on purpose (66 mutations in v0.4.4, plus 13 for the verdict reader in v0.4.5 12 for the hand-back line in v0.4.6 10 for interim stops in v0.4.7 14 for resumes, later instructions and rewrites in v0.4.8 23 for file reruns in v0.4.9 and 16 for non-dev roles and gate agent types in v0.5.1; all caught by a test).

Known limits

  • Savings are an upper bound: Opus may need fewer tokens than the cheaper model did.
  • timeout stops the docker client, not the container: name the container and remove it in a trap in the test command.
  • An Opus rewrite is not verified; the PR review covers it.
S
Description
No description provided
Readme
298 KiB
Languages
TypeScript 100%