# 2.2 Routing & parallelization

Routing dispatches to a specialist; sectioning and voting run calls concurrently.

1. Routing: classify, then dispatch to a specialised prompt.
2. Sectioning: fan out independent subtasks.
3. Fan-in: latency = max(tᵢ), not Σtᵢ.
4. Voting: N samples, majority aggregation.

- **Use when:** Separable input classes, independent subtasks, or high-variance decisions.
- **Avoid:** Subtasks with sequential dependencies; voting scales cost linearly in N.

```
# Route
kind = llm.classify(request)          # "billing"
return experts[kind](request)

# Split
parts = await gather(check_safety(x), review(x), write_docs(x))
return combine(parts)

# Vote
votes = await gather(*[judge(x) for _ in range(3)])
return majority(votes)
```

## References

- [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents) (Anthropic)
- [RouteLLM](https://arxiv.org/abs/2406.18665) (Ong et al.)
- [Self-Consistency](https://arxiv.org/abs/2203.11171) (Wang et al.)
- [Workflows and agents](https://docs.langchain.com/oss/python/langgraph/workflows-agents) (LangChain)
