Repository navigation
Model router gaps: writable + agent-def routing, miss observability, models.subagent (#285-#288) - #289
Merged
Conversation
…odel The def-less child-default model (--subagent-model, the CLAUDE_CODE_SUBAGENT_MODEL analogue) was CLI-flag-only on both mecated and mecatui while the rest of the operator model policy lives durably in the settings.yaml models: subtree. Add the models.subagent: key: strict-parsed on ModelsSection, operator-tier only (a project-tier subagent: is stripped with a WARN, the default_provider pattern), folded by foldOperatorSubagentModel after the router fold and before normalizeSubagentModel so the YAML value rides the SAME fail-fast validation as the flag (a dead child-default selector fails startup — deliberately stricter than the fail-soft models.default, because an inert child default silently runs the whole fleet on the expensive parent model). CLI wins when both are set (the cliModelKeys snapshot discipline). configgen example + regenerated skeleton and configuration reference + usage docs included. Closes #288 Co-Authored-By: Claude Fable 5 <[email protected]>
A router miss was 100% silent — six distinct fail-soft paths (degenerate input, classifier StopError/StopCancelled, non-JSON verdict, hallucinated category, unresolvable category target) all inherited the default model with no signal until the breaker opened after 3 CONSECUTIVE misses, so isolated misses (and any pattern interleaved with hits) were invisible and indistinguishable from gated delegations. RunModelRouter and Deps.SubagentModelRouter now return a missReason (the new RouterMiss* vocabulary; composition adds category-selector-empty / category-target-unresolvable), consumed at the ONE dispatch-path routeTask chokepoint as the INFO symmetric to the existing "subagent routed" line — metadata-only (gauntlet #7: never the task prompt or classifier output, pinned by an adversarial sentinel test), shared by all three delegation families. Fail-soft posture unchanged; breaker-open/hardAbort skips deliberately stay silent. Engine API change regenerated (task api:update) + CHANGELOG entry; the SubagentPayload wire cue stays a follow-up. Closes #287 Co-Authored-By: Claude Fable 5 <[email protected]>
mode:"read-write" silently ignored a per-call model AND the model-router pick: resolveEngineAndLimits unconditionally clobbered the selected engine with the one pre-built writableChildEngine, while the tool spec, the mode description, and validateMode's own error text all promised the combination (ADR 0041 called it an accepted v1 residual; the shipped contract said otherwise). Add the writable per-model engine factory (WithWritableEngineFactory, the ADR 0058 agentWritableFactory sibling; composition builds it over the shared writableExplorerDeps body — MAIN runner, direct-write parity, override id verbatim): a writable explorer now mints its engine on the requested model (loud model-addressable error on an unknown id, loud validateMode error when the factory is unwired — never a silent inherit) and a routed pick applies fail-soft. maybeRouteModel gates the classifier on the factory being wired so a discarded pick never spends a call; writable+resume keeps the default writable engine. Spec text updated to shipped truth; e2e proves the override model reaches the child's request while its Write still lands in the real workspace. Closes #285 Co-Authored-By: Claude Fable 5 <[email protected]>
…outer An agent-def delegation was gated out of the router unconditionally under "never override pinned intent" — but a def with no model: key pinned SCOPE, not model intent, so a def-based review panel got zero routing and every specialist silently inherited whatever session model the user happened to pick. Unpinned defs (TrimSpace(def.Model)=="") are now ROUTABLE: composition computes the set (routableAgentNames — excluding provider-switched defs, whose routed parent- provider id would be wrong, and inline-MCP defs, which the factory would decline) and threads it via the new WithRoutableAgents option; a routed hit rebuilds the SAME def's scoped engine on the routed model through the existing ADR 0035 agentModelFactory (per-def limits untouched), a miss/decline fail- softs to the pre-built def engine. Any non-empty def model — incl. the explicit `model: inherit` sentinel — stays pinned and never routes; explicit agent+model and writable specialists are unchanged; the classifier is never spent on a pick that couldn't be consumed. Precedence: per-call model > def model (incl. inherit) > router > SubagentModel > session model. The consolidated ADR 0066 records this and the #285 writable-routing change, narrowly superseding ADR 0041's writable-residual sentence and amending ADR 0031's agent-gating rule. Team members / Parallel branches are out of scope by decision. Closes #286 Co-Authored-By: Claude Fable 5 <[email protected]>
Five confirmed findings from the review panel: the build-once "router ACTIVE" line now discloses the WIDENED routing scope (plain + writable-explorer + unpinned agent-def delegations — the at-startup spend signal the docs already carried); the model-routing.md subagent: example no longer contradicts the router precedence configured in the same snippet (it is the fail-soft floor when a taxonomy is present); the RouterMiss* const-block doc states honestly that the constants enumerate RunModelRouter's closed output set while the composition closure may return open-set informational reasons (log-only, not a branchable enum); a new TestRouterBreakerOpenSkipStaysSilent pins that the breaker-OPEN skip path emits no per-miss INFO (count == max, not max+skips); and the two deliberately-unmerged select siblings carry reciprocal comments naming their divergences to preempt future DRY pressure. Co-Authored-By: Claude Fable 5 <[email protected]>
jhrozek
approved these changes
Jul 21, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Reviewed via 4-way panel (spec compliance, architecture/layering, security, test coverage) — all clean, no blocking issues.
- Spec: all four fixes (#285-#288) implement the described behavior; precedence chain (per-call > def model > router >
--subagent-model> session) traced and correct. - Architecture: layering respected, no adapter/os/gRPC leakage into engine/agent; "provider fixed, re-derive via factory" discipline holds for all new engine-minting paths.
- Security: model routing doesn't affect the command runner/permission mode for writable Subagents; router-miss logging confirmed metadata-only (no prompt/arg leakage);
models.subagent:operator-tier enforcement is structural, not just documented; no panic/nil-deref on unwired factories. - Tests: strong coverage including an adversarial canary-string test proving no-leak for #287 and exact-count assertions proving the precedence rungs. One minor gap:
mode:"read-write"+ namedagent:with the router wired has no direct test confirming the classifier is skipped (defensive early-return insubagent.go:1805) — low risk, worth a follow-up test but not blocking.
🤖 Generated with Claude Code
…-288 # Conflicts: # engine/CHANGELOG.md # llms.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the four model-router gaps found while debugging why "coder" work ran on the orchestrator model (kimi-k3) despite a configured taxonomy — one commit per issue plus a review-iteration commit:
model(and the router pick) — the writable explorer is pinned to the child-default engine #285 —mode:"read-write"silently ignored the per-callmodelAND the router pick (theresolveEngineAndLimitsclobber). NewWithWritableEngineFactory: a writable explorer now mints its engine on the requested/routed model (loud errors when unwired/unroutable — never a silent inherit), the classifier is never spent on a pick that can't be consumed, and the Subagent spec text matches shipped behaviour. E2E proves the override model reaches the child's request while its Write still lands in the real parent workspace (direct-write parity).WithRoutableAgents: a def with nomodel:key routes through the operator taxonomy (the routed hit rebuilds the def's SCOPED engine via the ADR 0035 factory; per-def limits untouched; provider-switched and inline-MCP defs excluded; explicitmodel: inheritstays the pin). Precedence: per-call model > def model (incl. inherit) > router >--subagent-model> session model.RunModelRouter/Deps.SubagentModelRouternow return a miss reason (RouterMiss*closed set engine-side; open-set informational reasons composition-side) logged as a per-miss INFO at the one dispatch chokepoint — metadata-only (gauntlet ACP: accept client-provided streaming-HTTP MCP servers #7 pinned by an adversarial sentinel test); breaker-open skips stay silent (also pinned). TheRoutedMisswire cue stays a follow-up.models.subagent:key #288 —--subagent-modelgets its settings.yaml home:models.subagent:(strict-parsed, operator-tier only with a project-tier strip WARN, CLI wins, FAIL-FAST validation — deliberately stricter than fail-softmodels.default), with configgen example + regenerated artifacts.Design record: ADR 0066 (consolidated), narrowly superseding ADR 0041's "accepted v1 residual" sentence and amending ADR 0031's agent-gating rule. Engine API changes regenerated via
task api:updatewithengine/CHANGELOG.mdentries (the #287 signature widening classified Changed/breaking; the two options + constants Added/minor).Closes #285
Closes #286
Closes #287
Closes #288
Review
Nine-agent panel over the branch diff — Spec, Standards, Security (all-clear, CWE-cited), Architecture (no findings ≥ Medium), the reuse/duplication pair (lean), UX, DevEx, and a QA test-adequacy pass (no must-add gaps). The five confirmed should-fix findings were applied in the final commit (honest "router ACTIVE" scope disclosure, docs-example precedence fix,
RouterMiss*doc-coverage correction, breaker-silence test, deliberately-not-merged sibling comments).Verification
task testgreen at every commit and on the final tree (root -race + engine module + GOWORK=off standalone + api-compat gate + docs citation lint)task lint0 issues (root + engine);task generateartifacts committed (llms.txt, config skeleton/reference)go run ./cmd/mecademostill prints a full offline session🤖 Generated with Claude Code