Repository navigation
Router: expose routing miss/gate reason on delegation-start events (#397) - #408
Conversation
JAORMX
left a comment
There was a problem hiding this comment.
Panel review — Approve.
Sound discipline throughout. routingReasonPayload is the single chokepoint applied at every emit site (subagent foreground+background, parallel branch_start incl. cancelled-before-start, team roster): it whitespace-collapses + clamps to 200 runes AND confines the wire to a closed event-safe allowlist (the 8 session.RoutingReason* gates + 5 RouterMiss* + 2 composition codes + empty-model), so a non-allowlisted string an external composition returns (provider error body, classifier output, task excerpt) degrades to the generic routing-miss label — gauntlet #7 holds at the projection rather than trusting compositions. The reason never carries model ids or def names (preserving metrics-label cardinality hygiene), and the closed set is mirrored consistently across all three delegation families + proto (additive fields 18/8/25) + mecatui — no half-wiring.
The -1120 deletion is internal parentCaps.routeTask plumbing (the exported Deps.SubagentModelRouter 5-tuple is untouched); the one exported change (Supervisor.MemberRouting 2→3 returns) is correctly classified Changed in CHANGELOG + api/agent.txt/session.txt, WithPinnedAgents is Added, and the api-compat gate passes. reconcileRoutedModel correctly clears routed fields and reports route-target-unavailable when a factory declines a routed target. Tests cover each gate/miss reason, the allowlist attack surface, and all emit paths; the no-content-leak guards scan RoutingReason by reflection.
Non-blocking notes: (1) no composition-level e2e asserting a detailed reason (e.g. category-selector-empty (category=large)) reduces end-to-end through buildModelRouterTask to a delegation-start event — the reduction and gate pass-through are unit-tested, so the composition-to-wire seam is only indirectly verified; a single e2e would close it. (2) The PR removed a blank line in engine/CHANGELOG.md and a pre-existing merged-bullet wart remains — cosmetic, not correctness. Good to merge.
Add a composition-level e2e test proving buildModelRouterTask's detailed category-selector-empty miss reduces to the static wire code before reaching a delegation-start event, closing the previously indirect composition-to-wire seam. Also fix two cosmetic CHANGELOG.md formatting issues (a merged bullet, a dropped blank line). Co-Authored-By: Claude Sonnet 5 <[email protected]>
2d87f8f to
e4874d1
Compare
…nts (#397) The delegation-start events (EvSubagentStart, parallel branch_start, team roster) carried only the router-HIT half (routed_category/routed_model); every miss/gate collapsed to empty strings while the *why* existed only in operator diagnostics. A UI could not distinguish router-disabled, pinned model, agent-def pinned, inherited default, classifier failure, or breaker-open. Plumb the already-returned missReason through the internal routeTask seam and add a bounded, additive routing_reason to the three session payloads + three proto fields (Subagent 18, TeamMemberSpec 8, Parallel 25) + server mappers. Empty on a routed hit; a session.RoutingReason* gate constant (pinned-model / agent-def-pinned-model / resume / fork / router-disabled / breaker-open / aborted) or a classifier/composition miss string otherwise. Gauntlet-#7 safe (never the task prompt or classifier reasoning), clamped at the emit site. Widens only the internal routeTask + MemberRouting (2->3); Deps.SubagentModelRouter is untouched. ADR 0083. Co-Authored-By: mecatl <[email protected]>
…#397) Addresses the follow-up review findings on the routing-reason feature: mecatui now projects routing_reason across Subagent/Parallel/Team render paths, Subagent attribution correctly prioritizes explicit resume/fork/ per-call-model/agent-def choices over router absence, the CHANGELOG entries are reclassified under the correct Added/Changed headings, ADR 0083 and the doc lifecycle are filled in, and routingReasonPayload now emits only bounded static codes (never raw composition/callback text) to close a gauntlet-#7 gap. Also regenerates engine/api/agent.txt and engine/api/session.txt for WithPinnedAgents and RoutingReasonTargetUnavailable, which were added by this diff but missing from the api-compat snapshot. Fixes #397 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Add a composition-level e2e test proving buildModelRouterTask's detailed category-selector-empty miss reduces to the static wire code before reaching a delegation-start event, closing the previously indirect composition-to-wire seam. Also fix two cosmetic CHANGELOG.md formatting issues (a merged bullet, a dropped blank line). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Rebasing 396-sse-missing-on-run onto main surfaced a gap the structural UTF8 fuzz test (added upstream after this branch forked) flags automatically: Subagent/Team/Parallel RoutingReason is harness/composition-authored bare metadata reduced to a closed allowlist (routingReasonPayload), never producer text, so it belongs in harnessTokenFields alongside the sibling RoutedCategory/RoutedModel fields rather than through valid(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
The rebase onto origin/main (which had just merged PR #428's llms.txt regen) resolved the llms.txt conflict by taking main's side verbatim, but that snapshot predates this branch's own docs/adr/0083 and other router-reason doc additions being re-applied on top. Regenerate for real against the final tree; task docs:check --strict passes clean (0 broken links/anchors/ambiguous/orphans). Co-Authored-By: Claude Sonnet 5 <[email protected]>
e4874d1 to
78334bc
Compare
Summary
routeTaskseam so router misses/gates (pinned model, agent-def-pinned, resume, fork, router-disabled, breaker-open, target-unavailable, aborted) surface a boundedrouting_reasonstring onsubagent.start, the Team roster, and Parallelbranch_start— previously every non-hit case collapsed to an indistinguishable emptyrouted_*.routing_reasonacross the Subagent/Parallel/Team render paths, Subagent attribution correctly prioritizes explicit resume/fork/per-call-model/agent-def choices over router absence, CHANGELOG entries reclassified under the correct Added/Changed headings, ADR 0083 + doc lifecycle filled in, androutingReasonPayloadconfines the wire value to a closed allowlist (never raw composition/callback text) — closing a gauntlet-ACP: accept client-provided streaming-HTTP MCP servers #7 gap.engine/api/agent.txt/session.txtforWithPinnedAgentsandRoutingReasonTargetUnavailable, which were added but missing from the api-compat snapshot.Fixes #397
Test plan
task lint(root + engine + provider/* modules)task api:update/ api-compat gate greengo test ./engine/... ./cmd/mecatui/... ./internal/adapter/server/... ./internal/apicheck/...go run ./cmd/mecademo— full offline session still prints turn/tool.call/permission.ask+approval/result🤖 Generated with Claude Code