router
flowchart TD
Input([Task input]) --> Router[Router agent]
Router --> C{Category}
C -- BUG_FIX --> B[Bug-fix agent]
C -- FEATURE --> F[Feature agent]
C -- REFACTOR --> R[Refactor agent]
C -- SECURITY --> S[Security agent]
B & F & R & S --> Done([Result])
A classifier agent analyzes the input and dispatches to the appropriate specialist agent. The routing decision is made once, upfront — no specialist ever sees tasks outside its domain.
How it works
- The router agent classifies the input into a known category (e.g.
BUG_FIX,FEATURE,REFACTOR,SECURITY). - The category determines which specialist agent receives the task.
- The specialist processes the task with a focused system prompt.
- Effort is allocated per role: the router runs at
loweffort with a smallmax_tokens(one word out); the specialist gets the budget atmedium. Same model, one cache namespace — measure this before reaching for a cheaper classifier model.
When to use
- Pipelines where input type varies significantly and a single generalist agent produces worse results than a specialist.
- Systems where you want each agent’s context to stay narrow and auditable.
When not to use
- Tasks that span multiple categories at once (e.g. a bug fix that also requires a security patch) — the router will misclassify or you’ll need a second pass.
- When the category set is unstable — adding new categories requires rewriting the router prompt.
Trade-offs
| Pro | Each specialist is focused — smaller prompt, better results |
| Pro | Easy to add specialists without touching existing ones |
| Pro | Routing cost stays small next to the specialist call when the router runs at low effort |
| Con | Misclassification silently sends the task to the wrong agent |
| Con | Tasks that span categories require either multi-label routing or a fallback generalist |
Failure modes
- Misclassification — the router picks the wrong category; the specialist produces a confident but irrelevant result.
- Unknown category — input doesn’t fit any known category; the router hallucinates a label or falls through to a default.