Repository navigation
Description
Split out from #391 (claim 3).
Claim
Router misses have useful reasons in diagnostics (classifier-error, unknown-category, breaker-open, category-target-unresolvable, etc.), but on the client event wire an unrouted delegation only has empty routed_category / routed_model. A UI cannot distinguish: router disabled/absent; explicitly pinned model; defined agent that intentionally bypassed routing; inherited default; classifier failure or breaker-open fallback. Expose a bounded structured routing outcome/reason on subagent.start, Team roster entries, and Parallel branch_start — no classifier reasoning or prompt text needed.
Investigation (verified against the codebase)
Verdict: confirmed. The wire carries only the router-hit half; every miss/gate case collapses to empty strings while the why exists only in operator diagnostics. Notably this was a deliberate deferral (ADR 0031 scoped the wire as a follow-up; ADR 0034 landed the hit fields; ADR 0035 added unconditional model) — not an oversight.
Evidence
- Wire = hit-only:
routed_category/routed_modelon Subagent proto 11/12 (contracts/proto/mecatl/v1/harness.proto:1120,1125), TeamMemberSpec 5/6 (:1175,1180), Parallel 19/20 (:1353,1358) — every doc comment says "empty otherwise". Session mirrors:engine/session/event.go:546-547, 678-679, 804-805. - The miss-reason taxonomy exists: closed set
RouterMiss{DegenerateInput,ClassifierError,Cancelled,BadVerdict,UnknownCategory}(engine/agent/modelrouter.go:41-59) + composition'scategory-selector-empty/category-target-unresolvable(internal/app/build.go:5203,5212) +empty-model(engine/agent/dispatch.go:1348). All are consumed by exactly one sink: the diag INFO atdispatch.go:1343-1353. Breaker-open/hardAbort return early and deliberately log nothing (dispatch.go:1221-1231). - The reason is dropped at the internal seam:
Deps.SubagentModelRouteralready returnsmissReason(engine/agent/loop.go:283), butparentCaps.routeTasknarrows the signature to(category, model, ok)(engine/agent/subagent.go:163); the threemaybeRoute*gates translate any failure to("",""), landing verbatim as empty fields on EvSubagentStart (subagent.go:2273-2274), parallel.branch_start (parallel.go:564-565), and the team roster (teamsupervisor.go:864-869). - Of the five cases the issue lists, the wire distinguishes only a hit; pinned / def-pinned / inherited / router-absent / miss all read identically as
routed_*="" + model=<id>.
Nuance
The reason strings are already vetted gauntlet-#7-safe metadata ("never the task prompt or the classifier's output", modelrouter.go:38-40) — putting them on the wire crosses no new trust boundary. The miss reason is already plumbed end-to-end to the dispatch chokepoint (issue #287) — the fix is additive plumbing at an existing seam, not new collection.
Proposed fix (~1-2 days)
- Widen internal
routeTaskto passmissReasonthrough; synthesizebreaker-openat dispatch.go:1221; Subagent distinguishes its own gates from args (pinned-model,agent-def-pinned-model,router-disabled, resume/fork constants). - Add a
routing_reasonstring to the 3 session payloads + 3 additive proto fields (Subagent 18, TeamMemberSpec 8, Parallel 22) + mapper population (mapper.gotoProtoSubagent/Team/Parallel) + mecatui view-model. - Full coverage of all five cases (incl.
router-disabledas a value rather than absence) needs one new composition→engine bit (e.g.WithRouterConfigured(bool)).
Constraints
- New ADR entry (0031/0034/0035 are frozen).
- Additive proto fields only, next free numbers,
task generate(never hand-editcontracts/gen). - Session payload fields are Added/minor →
task api:update+engine/CHANGELOG.mdnote. - Clamp/whitespace-collapse composition-authored reason strings per the
SubagentPayload.Causeprecedent (event.go:594-599). - Update the structural leak guards (
TestTeamMemberSpecHasNoContentFields/TestParallelPayloadHasNoContentFields) and the behavioral gauntlet test (teamsupervisor_router_test.go:374-395). - The "loop emits exactly three diagnostics lines" invariant is untouched (the field rides events, not diag).
- Prefer widening only the internal routeTask —
Deps.SubagentModelRouteris exported API already returning the reason, so no exported signature change is needed.
Activity
feat(router): expose routing miss/gate reason on delegation-start eve…
fix(router): follow-up repairs for routing_reason on delegation-start (…
feat(router): expose routing miss/gate reason on delegation-start eve…
fix(router): follow-up repairs for routing_reason on delegation-start (…