Sub-Agent-Aware Routing
Sub-agent-aware routing leaves parent-agent traffic with its configured routing
algorithm while routing delegated sub-agent work separately. It is available on
passthrough, stage_router, and composite routes through the optional
subagents table.
Set OPENROUTER_API_KEY, save the configuration as routes.toml, and validate it
before starting the server:
The subagents table has its own model groups, separate from the parent
route’s. A category name in the sub-agent table always means the sub-agent’s own
models, even when the parent route uses that category too, and the parent never
falls back onto a model only the sub-agents were given.
The parent always uses parent. For a delegated request, the classifier sees
the prompt supplied by the parent and selects one configured target. With
classify_trigger = "new_session", Switchyard reuses that decision for later
requests from the same session + agent identity. Use every_request to
classify each delegated request. user_turn is not supported for sub-agent
routing. Harness-maintenance requests continue through the parent route.
To use Stage Router for parent traffic, replace the [routes.agent] table in the
example with the following. The nested [routes.agent.subagents] classifier is
unchanged.
The parent stage route may also declare [routes.agent.tool_semantics] to map
domain-specific tools; delegated sub-agent policy configuration is unaffected.
Clients must still request the route ID (agent above). An explicit model name
that is not registered as a route is rejected before sub-agent classification.
message_hash_fallback is not supported for sub-agent routing because affinity
requires harness-provided child identity.
Claude Code sends child identity (x-claude-code-agent-id) starting with version
2.1.139. Older builds send only the session id, so Switchyard cannot tell a
sub-agent request from the parent’s and routes it through the parent route.
When a route with a subagents table sees an older Claude Code, Switchyard logs
one warning that a harness upgrade may be required. Upgrade Claude Code to
2.1.139 or later.
To send every delegated sub-agent request to one fixed target without calling a
classifier, replace the subagents table above with: