liveBook · Manning

Chapter 9: Router: Classifying and dispatching

What you will learn in chapter 9 of Agent Design Patterns

The introduction explains why a single general-purpose agent can struggle with specialized tasks and presents Router as a unified interface that classifies requests and dispatches them to suitable specialists.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why a single general-purpose agent can struggle with specialized tasks and presents Router as a unified interface that classifies requests and dispatches them to suitable specialists.

Key terms: tool choice overload, knowledge cross-contamination, specialization, Router, selector, sub-agent, classification, routing, governance, observability

9.1 The pain point: Too many specialized components to choose from

This section explains why specialized agent components are difficult to organize in a fixed hierarchy and introduces the Router pattern as a way to present them as one general agent.

Key terms: specialized components, fixed hierarchy, interdependent payloads, Router pattern, routing mechanism, single, general agent

9.2 How the Router pattern works

This section explains how a Router chooses a specialized component, prepares its input, and presents the result through a general interface.

Key terms: router, payload, fallbacks, selector element, input forwarding, output forwarding, interface generality, constraint preference choice, task-component expertise alignment, task-component efficiency alignment

9.2.1 Tradeoffs

This section explains when routers are typically introduced and the benefits they bring to an agent.

Key terms: routers, specialized components, Capability, Robustness, Reliability, design and code clarity

9.2.2 Implementation sketch

The section sketches a Router that classifies a task, uses the resulting key to dispatch its payload to a sub-agent, and handles an unrecognized selection.

Key terms: selector IE, key-based mapping, sub_agents, registry, payload, UnknownSubAgentError, selection miss, general-purpose catch-all agent, retrial

9.2.3 When and where to use Router

The section explains when routers help agentic systems by directing requests to specialized agents, appropriately priced models, available instances, or secure workflows.

Key terms: router, specialized domain triage, sub-agents, tool catalog bloat, inference budget optimization, lightweight semantic classifier, reasoning budget, low-latency models, frontier models, load balancing

9.2.4 How Router works with other patterns

This section distinguishes Router from Guardrail, Orchestrator, and agent swarms by what each component chooses or manages.

Key terms: Router, Guardrail, Orchestrator, work context, tools/sub-agents, proximity routers, agent swarms, flat teams, sub-agent

9.3.1 Ensemble router

This section shows how an ensemble router selects several specialists for a task, runs them in parallel, and reconciles their outputs.

Key terms: ensemble router, selector IE, top-k, sub-agent identifiers, reconciler element, dynamic Voter, committee, hedging, optimal path

9.3.2 Multi-layered router

This section shows how routers can form a hierarchy that narrows a task from broad categories to a terminal specialist agent.

Key terms: multi-layered router, root router, sub-router, terminal sub-agent, coarse-to-fine routing, IE objects, shared interface, Composite OOP pattern, compositionality, selector prompts

9.3.3 Proximity router

This section explains how a proximity router passes tasks among neighboring specialists and how to prevent tasks from cycling indefinitely.

Key terms: proximity router, sub-agent, neighbors, RoutingEncapsulation, local selector IE, chain of responsibility, cyclical references, local knowledge, RecursionError, stack overflow

9.4.1 Specialized jurisdiction-aware tax advisor

This section uses a jurisdiction-aware tax advisor to show how a Router can prevent tax rules from different legal domains from being mixed.

Key terms: cross-contamination of knowledge, jurisdiction, Swiss VAT, United States sales tax, selector IE, jurisdictional triage, legal category, sub-agent, fine-tuned, RAG-access

9.4.2 Complexity-driven inference budget optimizer

This section shows how a Router can reduce inference costs by sending simple tasks to inexpensive models and complex tasks to frontier models.

Key terms: Router, IE, selector, reasoning complexity, frontier models, inference budget, frontier model, complexity filter

9.4.3 Ensemble-based medical symptom triage

This section shows how an ensemble router handles ambiguous medical symptoms by consulting multiple specialists and combining their findings.

Key terms: Ensemble Router, k most relevant specialists, selector IE, final recomposer, persistent chest tightness, cardiology specialist, anxiety/mental health specialist, traditional linear router

9.5 Summary

This summary presents Router as a disciplined way to dispatch tasks among specialized components through one general interface, distinguishes it from an Orchestrator, and recaps its variants and examples.

Concepts explained in this chapter

← Chapter 8: Decompose-Process-Recompose: Handling large inputs with accuracy

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.