Key characteristics
- Router decomposes the query
- Zero or more specialized agents are invoked in parallel
- Results are synthesized into a coherent response
When to use
Use the router pattern when you have distinct verticals (separate knowledge domains that each require their own agent), need to query multiple sources in parallel, and want to synthesize results into a combined response.Basic implementation
The router classifies the query and directs it to the appropriate agent(s). UseCommand for single-agent routing or Send for parallel fan-out to multiple agents.
- Single agent
- Multiple agents (parallel)
Use
Command to route to a single specialized agent:Tutorial: Build a multi-source knowledge base with routing
Build a router that queries GitHub, Notion, and Slack in parallel, then synthesizes results into a coherent answer. Covers state definition, specialized agents, parallel execution with
Send, and result synthesis.Stateless vs. stateful
Two approaches:- Stateless routers address each request independently
- Stateful routers maintain conversation history across requests
Stateless
Each request is routed independently—no memory between calls. For multi-turn conversations, see Stateful routers.Stateful
For multi-turn conversations, you need to maintain context across invocations.Tool wrapper
The simplest approach: wrap the stateless router as a tool that a conversational agent can call. The conversational agent handles memory and context; the router stays stateless. This avoids the complexity of managing conversation history across multiple parallel agents.Full persistence
If you need the router itself to maintain state, use persistence to store message history. When routing to an agent, fetch previous messages from state and selectively include them in the agent’s context—this is a lever for context engineering.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.