Chapter 15: Routing
Lecture
Chapter principle
Key takeaways
- Routing allocates tasks to capabilities, workflows, models, or control paths.
- Routing errors can have asymmetric cost and risk.
- Router accuracy and end-to-end system quality are different metrics.
- Model routing trades quality against cost and latency.
- Cascades replace perfect prediction with failure detection and escalation.
- Compare with simple baselines: always-strong, deterministic rules.
Experiments
Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.
Experiment 27: Sending each task to the right place
Can a router send each request to the right place, and what does a wrong choice cost?
Seven requests must each go to one of three routes: math (a calculator), policy (answers from company policy documents) or write (drafting text). Three routers are compared: simple keyword rules; a real model given plain descriptions of the routes; and the same model given a sharper description of the policy route. Mistakes have a cost: a policy question sent elsewhere costs 5, any other mistake costs 1. This is a recorded run of a real model. A new run may route differently.
Experiment 28: Cheap model or strong model?
Can a system save money by using a cheap model when it is good enough?
Two real models answer five sums without a calculator. FAST is a small model costing 1 unit per call; STRONG is a larger one costing 10. The units are illustrative, not prices. Three sums are easy; the two with brackets are hard for FAST. Five strategies are compared: always FAST, always STRONG, an oracle that knows which sums are hard, a router that guesses from the length of the sum, and a cascade that tries FAST first and asks STRONG only when an exact check fails. This is a recorded run of real models. A new run may differ.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters