Chapter 41Multi-Agent Systems and Orchestration
So far we have built single agents. But some problems are best tackled not by one generalist agent but by a *team* of specialized agents working together — a researcher, a writer, a reviewer, each focused on what it does best. This chapter explores multi-agent systems: how several agents collaborate, the patterns for coordinating them, and — just as importantly — when a team of agents helps and when a single well-designed agent is the wiser choice. As always, we favor clear thinking over hype, because multiplying agents is as easy to overdo as it is to underuse.
When One Agent Isn't Enough
A single agent, however capable, is a generalist juggling everything at once — researching, reasoning, writing, checking — within one context and one set of instructions. For some complex goals, that juggling becomes a liability. Just as a human team divides a big project among specialists, a multi-agent system divides a goal among several agents, each with a focused role. A research agent gathers information, a writing agent turns it into prose, a reviewing agent checks the result. Each does one thing well rather than everything adequately.
What a Multi-Agent System Is
A multi-agent system is simply several agents — each a full agent in the sense of Chapter 31, with its own instructions, tools, and loop — working together toward a shared goal, coordinated in some way. The key words are specialized and coordinated. Each agent has a narrower job and often its own focused prompt and toolset, and some mechanism routes work between them. Nothing about an individual agent changes; you are composing agents you already know how to build into a collaborating group.
Why Multiple Agents Can Help
When the structure fits, splitting work across agents brings real benefits.
- Specialization — each agent can have a tightly focused prompt and the exact tools its job needs, often outperforming a generalist trying to do everything.
- Separation of concerns — a system of focused agents is easier to understand, test, and improve than one sprawling agent with a giant prompt.
- Parallelism — independent subtasks can run at the same time, speeding up the whole.
- Built-in checking — one agent can review another's work, catching errors a single agent might miss — a structural form of the verification theme that runs through this book.
Common Coordination Patterns
Agents can be organized in several ways, and most systems use one of a few patterns.
Sequential (pipeline)
Agents form a chain, each handing its output to the next: a researcher gathers facts, passes them to a writer, who passes a draft to an editor. Simple, predictable, and easy to follow — like an assembly line where each station adds something.
Manager (orchestrator)
A coordinator agent breaks the goal into subtasks, delegates each to a worker agent, and combines the results. The manager decides who does what — like a project lead directing specialists. This is flexible and handles goals where the needed steps are not known in advance.
Collaborative (debate or critique)
Agents interact more freely — discussing, critiquing, or refining each other's work — to reach a better result than any would alone. Useful when multiple perspectives genuinely improve the outcome, though it is the most complex and costly pattern.
Handoffs
However agents are organized, they must pass work between them, and these handoffs are where multi-agent systems succeed or fail. One agent's output becomes another's input, so clear interfaces matter: what exactly does the researcher hand the writer, and in what form? Sloppy handoffs — vague, incomplete, or misformatted output — cause the receiving agent to stumble. Designing clean handoffs is much of the craft of multi-agent systems, and it echoes the structured-output discipline of Chapter 29.
Building a Simple Two-Agent System
The simplest useful multi-agent system is a sequential pair: a researcher and a writer. The researcher gathers material; the writer turns it into a finished piece.
def research_agent(topic):
# a focused agent with search tools; returns gathered facts
return run_agent(f"Research key facts about: {topic}", tools=[search])
def writing_agent(topic, facts):
# a focused agent specialized in clear writing
return run_agent(
f"Write a short, clear article about {topic} using these facts:\n{facts}",
tools=[],
)
# The handoff: the researcher's output becomes the writer's input.
facts = research_agent("how vaccines work")
article = writing_agent("how vaccines work", facts)
print(article)Each agent is an ordinary Chapter 31 agent with a focused job. The system is just the two of them, wired together by a clean handoff — the researcher's facts flow into the writer. Simple, but already more capable on this task than one agent doing both jobs at once.
When Multiple Agents Help — and When They Don't
Here is the most important judgment in the chapter, and it cuts against the temptation to build elaborate agent teams. Multi-agent systems add real costs: coordination overhead, more model calls (and thus more money and latency), more points of failure, and harder debugging. Very often, a single well-designed agent is simpler, cheaper, and better. Reach for multiple agents only when the task genuinely decomposes into distinct specialties, benefits from parallelism, or is meaningfully improved by one agent checking another. If you cannot articulate why a second agent earns its keep, you probably do not need it.
The Challenges
Beyond cost, multi-agent systems bring distinctive difficulties. Agents can miscommunicate through poor handoffs. Errors can compound as they pass down a chain — a mistake by the researcher misleads the writer. The extra model calls drive up cost and latency. And the whole system is harder to debug, because a failure could lie in any agent or any handoff between them. These challenges are manageable, but they are real, and they are the price of the benefits — pay it only when the benefits are worth it.
Adding a Reviewer
One especially valuable use of a second agent is review. Add a reviewer agent that checks the writer's output against the goal and requests fixes if it falls short, looping until the work passes. This builds a verification step directly into the system — the same principle that runs through the whole book, now structural: one agent produces, another checks. A reviewer can meaningfully raise quality, catching mistakes the producing agent was blind to, and it is often the multi-agent addition that most clearly earns its keep.
Summary
A multi-agent system is several specialized agents — each a full agent in its own right — coordinated toward a shared goal. Multiplying agents can help through specialization, separation of concerns, parallelism, and built-in checking, and they are organized with patterns like sequential pipelines, a manager delegating to workers, or collaborative critique, all relying on clean handoffs between agents. But multi-agent systems add coordination overhead, cost, latency, failure points, and debugging difficulty, so a single well-designed agent is often the better choice; add agents only when a clear benefit justifies them. A reviewer agent that checks another's work is a particularly worthwhile addition, building verification into the system's very structure.
Whether one agent or many, real-world agents ultimately need real-world capabilities. Chapter 42 closes Part VIII by connecting agents to the messy real world — the web, code execution, files, and external APIs — with a firm eye on reliability and safety.
Exercises
- 1Explain when a team of specialized agents would outperform a single generalist agent, and give a concrete task where the split makes sense.
- 2Describe the three coordination patterns (sequential, manager, collaborative) and give an example task suited to each.
- 3Build a two-agent system where a researcher hands off to a writer. Pay attention to the handoff: what exactly does the researcher pass, and in what form?
- 4Explain why clean handoffs are so important in multi-agent systems, and describe one way a sloppy handoff could cause the system to fail.
- 5Make the case for when a single agent is the better choice than a multi-agent system. List the specific costs that multiple agents add.
- 6Add a reviewer agent to your two-agent system that checks the writer's output and requests revisions. Describe how this changes the output and why it connects to the book's theme of verification.
