9 Router: Classifying and dispatching
The router pattern addresses the problem of many specialized agent components needing a single, simple entry point. Instead of forcing one general-purpose agent to handle every request, a lightweight selector classifies the incoming task and forwards it to the most appropriate specialist. This keeps the outside interface unified while allowing the internal system to remain modular, more reliable, and easier to govern.
A central benefit of routing is that it reduces tool overload, prevents domain knowledge from bleeding across unrelated tasks, and enables specialization. Each sub-agent can use its own prompt, tools, retrieval sources, and policy constraints, so billing, technical support, fraud handling, or other domains can be optimized independently. The routing chokepoint also becomes a natural place for logging, access control, escalation, and other oversight functions.
The chapter also shows several ways routers can be extended. An ensemble router can send one task to multiple specialists and reconcile their outputs when the best path is uncertain; a multi-layered router can route through a hierarchy of increasingly specific selectors; and a proximity router can decentralize routing so agents hand tasks among neighbors. These variants support different goals such as accuracy, cost control, load balancing, and privilege enforcement, and the chapter illustrates them with examples like tax advice, budget-aware model selection, and medical triage.
The AFD of the Router pattern. The input task is first seen by the selector element, which decides which sub-agent to invoke. The task is then forwarded unaltered to the selected sub-agent, and the result of that sub-agent's processing is eventually presented as the output of the whole routing component.
The AFD of the Ensemble router variant. The input task is seen by the selector element, which decides on which group of sub-agent to invoke. The task is then forwarded to the selected sub-agents, and the results of all sub-agents' processing is gathered and fed into reconciliation element, which produces the final output.
The AFD of the Multi-layered router variant. The input task is seen by the root selector element, which decides on which of its children sub-selectors to invoke. This continues until a leaf sub-agent is selected. The task is then forwarded to the selected sub-agent, and its result is presented as the final output.
The AFD of the Proximity router variant. The input task is seen by the root selector element, which decides on which the many sub-agents to invoke. The selected sub-agent can then either take on the input task or refer it to one of its neighbors, which may in turn do the same. The process terminates when a sub-agent takes on the task, at which point its output becomes the final output of the component.
Summary
- The growth in specialized components within complex agents creates a need for a unified mechanism that directs tasks to the right component while presenting a single, general interface to the rest of the system.
- The Router pattern is a component that selects among sub-agents based on task properties, constructs an appropriate payload, and forwards the task for processing without incrementally building context.
- Routers forward inputs and outputs, expose a general interface despite heterogeneous sub-agent interfaces, and make constraint-preference choices based on task nature, complexity, or security demands.
- Routers primarily improve robustness and reliability once specialized components exist, and they differ from Orchestrators by not subdividing problems or maintaining cross-step work context.
- Router variants include the Ensemble Router (parallel invocation with reconciliation), the Multi-layered Router (a hierarchical tree of selectors), and the Proximity Router (decentralized routing decisions delegated to sub-agents).
- Examples such as a jurisdiction-aware tax advisor, a complexity-driven inference budget optimizer, and an ensemble-based medical symptom triage system illustrate Router as a pattern that professionalizes agent architecture by turning ad-hoc component selection into disciplined, structured dispatch.
Agent Design Patterns ebook for free