Every agent builder hits the same moment. The agent that was brilliant on day one starts to struggle: the prompt keeps growing, the tool list hits twenty, the context window fills up halfway through a task, and answers get worse. The obvious next idea is to add more agents.
Sometimes that is exactly right. A multi-agent system can research faster, handle more information and keep risky permissions apart. Just as often it makes things worse: more cost, more latency, and new failures that happen between agents, where no single agent can see them.
In this guide I explain what multi-agent systems are, the four signals that one agent really is not enough, the five patterns worth knowing, how to hand work between agents, a tested Python orchestrator, what it costs, why these systems fail and how to test them. If you have not built a single agent yet, start with How to Build Your First AI Agent and come back.
What is a multi-agent system?
A multi-agent system is two or more AI agents, each with its own instructions, tools and context, that work together on a task, usually under code or an agent that coordinates them.
Recall that a single agent is a loop: the model picks a tool, your code runs it, the result goes back, repeat until done (see What Is Agentic AI?). A multi-agent system runs several of those loops and connects them. Each agent can have:
- Its own prompt and expertise, such as "sales analyst" or "fact checker".
- Its own tools and permissions, so the research agent can read the web while only the finance agent can query the ledger.
- Its own context window, which is the real superpower: each agent starts clean and holds only what its subtask needs.
- Its own model, often a cheaper, faster model for narrow subtasks and a stronger one for planning.
Think of the difference between one very capable generalist and a small team with a lead. The team can cover more ground at once, but only if the lead writes clear briefs and checks the work. Most of this guide is about those two jobs.
When is one agent not enough?
Use more than one agent only when you see one of four signals: the work does not fit in one context window, it splits into independent parallel parts, one agent cannot choose reliably among too many tools, or parts of the job need different permissions or owners. And the task must be valuable enough to pay for the extra cost.
| Signal | What it looks like | Try this single-agent fix first |
|---|---|---|
| Context overflow | The agent reads so many documents or results that early facts fall out of its context, or it slows down and loses focus | Trim tool outputs, summarise as you go, store notes in a file |
| Parallel breadth | The task splits into independent questions, such as researching ten competitors or checking five data sources | Let one agent call several tools in parallel |
| Tool sprawl | Twenty-plus tools across different domains, and the agent keeps picking the wrong one | Merge overlapping tools and sharpen their descriptions |
| Permission or ownership boundaries | A research step reads untrusted web pages while another step can write to the CRM; or another team already runs a capability | Require human approval for the risky tool |
Anthropic's write-up of its multi-agent research system puts the sweet spot well: these systems "excel at valuable tasks that involve heavy parallelization, information that exceeds single context windows, and interfacing with numerous complex tools". If you cannot point to one of the four signals, you probably need a better single agent, not more agents.
When should you not use a multi-agent system?
Avoid multiple agents when every step depends on the full shared context, when the parts are tightly coupled, or when the task is not valuable enough to justify several times the cost.
The same Anthropic article is candid that domains where all agents need the same context, or with many dependencies between agents, "are not a good fit for multi-agent systems today", and that most coding tasks have fewer truly parallel parts than research. Cognition, the company behind the Devin coding agent, made the opposing case in a well-known essay titled "Don't Build Multi-Agents". Its two principles are worth memorising:
- Share context, including full agent traces, not just individual messages.
- Actions carry implicit decisions, and conflicting decisions carry bad results.
A classic example: one agent designs the background of a game while another designs the character, each makes sensible but different style choices, and the parts do not fit together. Neither agent made a mistake; the split did.
Skip multi-agent designs when:
- The steps are fixed and known in advance. Use a scripted workflow instead.
- Each step needs to see everything the previous steps saw.
- Latency matters more than depth, for example a customer chat that must answer in seconds.
- You have not yet got one agent passing an evaluation set. More agents will not fix an unmeasured system.
What are the main multi-agent patterns?
Five patterns cover most real systems: sequential pipeline, router, parallel fan-out, orchestrator-worker and evaluator-optimizer. The first three are mostly workflows, with paths fixed in code; the last two let a model decide more of the flow.
| Pattern | How it works | Best for | Main risk |
|---|---|---|---|
| Sequential pipeline | Agent A's output becomes agent B's input, in a fixed order | Draft → review → format; extract → clean → load | Errors early in the chain flow downstream unnoticed |
| Router | A classifier sends each request to the right specialist | Support triage, routing questions to finance, HR or IT agents | A wrong route means a confident answer from the wrong expert |
| Parallel fan-out | Several agents work at once on separate parts (or the same part, then vote); results are merged in code | Comparing many sources, multi-region analysis, second opinions | Merging conflicting results |
| Orchestrator-worker | A lead agent plans at run time, writes briefs, delegates to workers and synthesises | Open-ended research and analysis where subtasks are not known in advance | Vague briefs, duplicated work, high token use |
| Evaluator-optimizer | One agent produces, another critiques against criteria, and they loop | Reports, SQL or code that must meet a clear quality bar | Endless loops without a stopping rule |
These names follow Anthropic's widely cited guide Building Effective Agents, which also makes the most useful distinction in this field: workflows run models through predefined code paths, while agents direct their own process. Prefer a workflow pattern whenever the steps are predictable. It is cheaper, faster and far easier to test.
How does the orchestrator-worker pattern work?
In the orchestrator-worker pattern, a lead agent breaks the task into subtasks, sends each to a worker agent with a clear brief, runs independent workers in parallel, then combines and checks their findings. It is the pattern most people mean by "multi-agent system".
Anthropic's research feature is the best-documented example. Its lead agent spins up 3 to 5 subagents in parallel, each running its own searches, and a separate citation agent attaches sources at the end. On Anthropic's internal research evaluation, a multi-agent setup with Claude Opus 4 leading Claude Sonnet 4 workers outperformed a single Claude Opus 4 agent by 90.2%. Parallelism also cut research time by up to 90% on complex queries.
Two lessons from that write-up transfer to almost any system:
- Scale effort to the question. Their rule of thumb: simple fact-finding needs one agent with 3 to 10 tool calls; only complex research justifies 10 or more subagents. Put that rule in the lead agent's prompt, or it will over-delegate.
- Save the plan outside the context window. Long runs overflow. The lead writes its plan to memory so it can recover the thread.
How do agents hand off work to each other?
Agents hand off work through a written brief that states the objective, the expected output format, which tools or sources to use, and the boundaries of the task. A worker cannot read the lead's mind or the conversation so far; the brief is all it knows.
Weak brief: "Look into the Q3 revenue drop." Three workers given that will all query the same table and return overlapping essays.
Strong brief:
Objective: Find which regions and product lines drove the Q3 2026 revenue change vs Q2.
Output format: A table of region × product line with Q2, Q3 and % change, plus the SQL used.
Sources/tools: Sales database only (read-only). Revenue means SUM(net_amount) after refunds.
Boundaries: Q2 and Q3 2026 only. Do not investigate causes; another agent covers support tickets.
Beyond the brief, decide three things explicitly:
- What comes back. Ask for structured findings with evidence (SQL, ticket IDs, URLs), not prose. The lead should be able to check every claim.
- Shared state or messages. Workers can write to a shared store (a file, a table, a notes document) or return messages only. Shared state helps long tasks but needs rules on who may write what.
- How much context to pass. Cognition's advice is to pass full traces when decisions depend on each other. For truly independent subtasks, a tight brief is better than a context dump.
How do you build a simple multi-agent system in Python?
A minimal orchestrator-worker system is three functions: a planner that writes briefs as JSON, a worker runner that calls a single-agent loop with the right tools, and a synthesiser that combines the findings.
The example below answers business questions such as "Why did Q3 revenue drop?" with three specialists. It reuses the agent loop from my first-agent guide, extended so run_agent accepts a system prompt, a tool list and a step limit. call_model is your thin wrapper around any LLM provider's chat API, as in that guide.
import json
from concurrent.futures import ThreadPoolExecutor
MAX_WORKERS = 4 # cap fan-out: every worker is a full agent run with its own cost
MAX_STEPS_PER_WORKER = 8 # each worker gets its own step budget
# Each specialist gets its own prompt and ONLY the tools it needs.
WORKERS = {
"sales": {"system": "You analyse the sales database. Read-only. Show the SQL behind every number.",
"tools": ["list_tables", "describe_table", "run_sql"]},
"support": {"system": "You analyse support tickets. Quote ticket IDs for every claim.",
"tools": ["search_tickets"]},
"market": {"system": "You research public news about competitors. Cite a URL for every claim.",
"tools": ["web_search"]},
}
PLANNER = """You are the lead analyst. Split the question into 1-4 INDEPENDENT subtasks.
Return JSON: {"tasks": [{"worker": "sales|support|market", "objective": "...",
"output_format": "...", "boundaries": "..."}]}. Give each subtask everything it needs:
workers cannot see this conversation or each other's work."""
SYNTHESISER = """You are the lead analyst. Combine the worker findings into one answer.
Use only facts that carry evidence (SQL, ticket ID or URL). List any gaps or conflicts."""
def plan(question):
"""Orchestrator step 1: break the question into self-contained briefs."""
reply = call_model([{"role": "system", "content": PLANNER},
{"role": "user", "content": question}])
tasks = json.loads(reply["content"])["tasks"]
return [t for t in tasks if t.get("worker") in WORKERS][:MAX_WORKERS]
def run_worker(task):
"""Orchestrator step 2: run one specialist on one brief, with its own tools and budget."""
spec = WORKERS[task["worker"]]
brief = (f"Objective: {task['objective']}\nOutput format: {task['output_format']}\n"
f"Boundaries: {task['boundaries']}")
try:
answer, steps = run_agent(brief, system=spec["system"], tools=spec["tools"],
max_steps=MAX_STEPS_PER_WORKER)
except Exception as e: # one failed worker must not sink the team
answer, steps = f"FAILED: {e}", 0
return {"worker": task["worker"], "objective": task["objective"],
"answer": answer, "steps": steps}
def run_team(question, log=print):
tasks = plan(question)
with ThreadPoolExecutor(max_workers=MAX_WORKERS) as pool: # independent tasks run in parallel
results = list(pool.map(run_worker, tasks))
for r in results:
log(f"[{r['worker']}] {r['steps']} steps -> {r['answer'][:120]}")
reply = call_model([{"role": "system", "content": SYNTHESISER},
{"role": "user", "content": json.dumps(
{"question": question, "findings": results})}])
return reply["content"], results
What the code enforces, rather than hopes for:
- Least privilege per agent. The market agent, which reads untrusted web pages, never holds the database tools.
- Hard caps. At most four workers per question and eight steps each, so cost has a ceiling.
- Allow-listed workers. If the planner invents a worker that does not exist, it is dropped, not executed.
- Failure isolation. One crashed worker returns
FAILEDand the synthesiser reports the gap instead of the whole run dying. - Evidence in, evidence out. Every worker must attach SQL, ticket IDs or URLs, and the synthesiser may only use facts that carry them.
I tested this control flow with stubbed model and agent calls: the planner's unknown worker was dropped, the three valid workers ran in parallel, and a simulated search outage in one worker produced a FAILED finding while the other two completed. Test your version the same way before connecting real tools.
How much do multi-agent systems cost?
Multi-agent systems cost much more than single agents: Anthropic reports that agents use about 4 times the tokens of a chat, and multi-agent systems about 15 times. Every worker is a full agent run, and the lead pays again to read all their findings.
The same analysis found that token usage alone explained 80% of the performance difference on a browsing benchmark. In other words, much of what makes multi-agent systems better is that they spend more. That is fine when the answer is worth it, and wasteful when it is not.
| Cost lever | How to apply it |
|---|---|
| Cap fan-out | Set a maximum number of workers per run, as in the code above |
| Scale effort in the prompt | Tell the lead when one worker is enough and when more are justified |
| Mix models | Use a strong model for planning and synthesis, cheaper ones for narrow workers |
| Trim what returns | Workers return compact structured findings, not full transcripts |
| Set budgets and timeouts | Per-worker step limits and a per-run token or spend limit |
| Route simple questions away | Put a router in front so easy questions go to one agent or a plain query |
Latency follows the same logic. Parallel workers save time on breadth, but a lead that waits for every worker before continuing is only as fast as its slowest worker. Set timeouts and decide in advance whether a late worker's findings are worth waiting for.
Why do multi-agent systems fail?
Multi-agent systems usually fail because of poor system design, misalignment between agents, or weak checking of the final result, not because a single model is bad. That is the conclusion of MAST, a taxonomy built by researchers who annotated more than 1,600 traces across 7 popular multi-agent frameworks and found 14 distinct failure modes in 3 categories.
| MAST category | What it looks like in practice | Fix |
|---|---|---|
| System design issues | Agents ignore their role, repeat steps, lose the conversation history or never recognise they are finished | Clear roles, explicit stopping rules, step caps, plans saved outside the context |
| Inter-agent misalignment | Workers withhold key information, ignore each other's input, drift from the task or quietly change the goal | Structured briefs and outputs, shared definitions, passing full context when tasks depend on each other |
| Task verification | The system stops early or declares success without checking, so wrong answers look complete | A dedicated check step, evidence for every claim, end-to-end evaluation |
The same paper notes that gains from multi-agent setups on popular benchmarks are often minimal. In practice, the third category often comes down to one thing: nobody owns the final check. Each agent assumes another one verified the numbers.
How do you evaluate and monitor a multi-agent system?
Evaluate the whole system end to end on a fixed set of tasks with known answers, then use per-agent traces to find where failures start. Two agents that each pass their own tests can still fail together.
- Build a test set first. 20 to 50 real questions with answers you have checked, including ones a single agent handles and ones it does not.
- Compare against a single-agent baseline. If the team does not clearly beat one good agent on accuracy for the extra cost, keep the single agent.
- Run each task several times. Multi-agent runs vary more than single agents. Track how often all runs succeed, not just the best one.
- Trace every handoff. Log each brief, each worker's tool calls and each returned finding. Most bugs are visible in the brief.
- Watch cost and latency per run, and alert when they drift.
For grading methods, repeated-run metrics and a Python harness, see AI Agents That Work: How to Build, Evaluate and Secure Them.
Which frameworks support multi-agent systems?
Most major agent frameworks now support multiple agents, but you can build the core orchestrator-worker pattern in plain code, as above. Reach for a framework when you need durable state, retries, tracing or human-in-the-loop steps.
| Framework | Multi-agent approach | Good fit when |
|---|---|---|
| LangGraph | Agents and steps as nodes in a graph with shared state | You want explicit control over the flow and checkpoints |
| CrewAI | Role-based "crews" of agents with tasks | You want quick, readable role definitions |
| OpenAI Agents SDK | Handoffs between agents, and agents used as tools | You build on OpenAI models and want light abstractions |
| Microsoft Agent Framework | Agents plus multi-agent workflows; the successor to AutoGen and Semantic Kernel | You work in .NET or Python on Azure |
| Google Agent Development Kit (ADK) | Hierarchies of agents with workflow agents for sequence and parallelism | You build on Google Cloud and Gemini |
| Claude Agent SDK | Subagents with their own context and tools | You build on Claude and want the harness behind Claude Code |
Pick the framework that fits your stack and the pattern you chose, not the other way round. A framework will not tell you whether you need multiple agents.
How do MCP and A2A fit into multi-agent systems?
MCP connects each agent to its tools and data; A2A lets agents built by different teams or vendors delegate tasks to each other. Inside one system you control, plain function calls between agents are usually enough.
- MCP lets every worker reuse the same tool servers with their own scoped credentials. See MCP Explained.
- A2A (Agent2Agent) matters when the "worker" belongs to someone else, such as a vendor's procurement agent. Treat its answers as untrusted input, exactly like a web page.
How do you keep a multi-agent system secure?
Treat every agent's output as untrusted input to the next agent, and give each agent only the permissions its subtask needs. A prompt injection that reaches one agent can travel through the whole team if agents trust each other blindly.
- Separate reading untrusted content from taking actions. The agent that browses the web should not also send emails or write to databases.
- Do not let a worker's findings change another agent's instructions or permissions. Findings are data.
- Keep humans on irreversible steps, however many agents agreed on them.
- Log every handoff so you can reconstruct which agent introduced a bad instruction or number.
For the full threat model, see Prompt Injection and AI Agent Security.
What are the most common mistakes with multi-agent systems?
- Splitting by job title instead of by need. "CEO agent", "analyst agent" and "writer agent" make a nice slide but rarely map to real context or permission boundaries.
- Vague briefs. If the brief would confuse a new colleague, it will confuse a worker.
- No owner for the final check. Add a step whose only job is verifying evidence.
- Unlimited fan-out. Without caps, a lead agent can spawn workers for trivial questions.
- Agents chatting freely. Open-ended agent-to-agent conversations burn tokens and drift. Prefer structured handoffs.
- No single-agent baseline. You cannot claim the team is better if you never measured the alternative.
- Skipping the workflow option. If the steps are known, a scripted pipeline beats any autonomous team.
Checklist: before you split into multiple agents
- You can name which of the four signals applies (context, parallel breadth, tool sprawl, permissions)
- A single-agent baseline exists and its failures are measured
- The task is valuable enough to justify several times the token cost
- You chose the simplest pattern that fits, preferring a workflow where steps are known
- Every worker has a written brief: objective, output format, tools and sources, boundaries
- Each agent has only the tools and credentials its subtask needs
- Fan-out, steps, time and spend are capped in code
- Workers return structured findings with evidence
- A dedicated step verifies the final answer against that evidence
- Every handoff, tool call and finding is logged
- The whole system passes an end-to-end evaluation set across repeated runs
Sources and further reading
- Anthropic: How we built our multi-agent research system
- Anthropic: Building effective agents
- Cognition: Don't Build Multi-Agents
- Cemri et al.: Why Do Multi-Agent LLM Systems Fail? (MAST)
- Microsoft Agent Framework overview
Key takeaways
- A multi-agent system is several agents, each with its own context, tools and permissions, working on one task.
- Split only for a real signal: context overflow, parallel breadth, tool sprawl or permission boundaries.
- Prefer the simplest pattern; use orchestrator-worker for open-ended research and analysis.
- Clear briefs and evidence-based findings matter more than the framework.
- Expect roughly 15 times the tokens of a chat, and cap fan-out, steps and spend in code.
- Most failures happen between agents: own the final check and test the whole system against a single-agent baseline.
Frequently asked questions
What is a multi-agent system in AI?
A multi-agent system is two or more AI agents, each with its own instructions, tools and context window, that work together on one task. Usually a lead agent or code coordinates them, sending each agent a subtask and combining the results.
When should I use a multi-agent system instead of a single agent?
Use one when the work does not fit in one context window, splits into independent parallel parts, needs more tools than one agent can choose between reliably, or needs different permissions for different steps, and the task is valuable enough to pay for the extra cost. Otherwise improve the single agent.
What is the orchestrator-worker pattern?
A lead agent breaks a task into subtasks, writes a brief for each, sends them to worker agents that often run in parallel, then combines and checks their findings. It suits open-ended research and analysis where the subtasks are not known in advance.
Are multi-agent systems better than single agents?
Sometimes. Anthropic reported that its multi-agent research system beat a single agent by 90.2% on an internal research evaluation, but it used far more tokens. Research on multi-agent failures found gains on popular benchmarks are often minimal. Always compare against a single-agent baseline.
How much more do multi-agent systems cost?
Anthropic reports that agents use about 4 times the tokens of a chat interaction and multi-agent systems about 15 times. Cap the number of workers, steps and spend per run, and use cheaper models for narrow subtasks.
Why do multi-agent systems fail?
The MAST study of more than 1,600 traces across 7 frameworks found 14 failure modes in three groups: system design issues, misalignment between agents, and weak verification of the final result. Most failures happen between agents rather than inside one model.
What is the difference between a workflow and a multi-agent system?
In a workflow, code fixes the order of steps in advance. In an agentic multi-agent system, a model decides at run time which agents to involve and what to ask them. Workflows are cheaper and easier to test, so use them whenever the steps are predictable.
Which frameworks are used to build multi-agent systems?
Common choices include LangGraph, CrewAI, the OpenAI Agents SDK, Microsoft Agent Framework (the successor to AutoGen and Semantic Kernel), Google's Agent Development Kit and the Claude Agent SDK. A simple orchestrator can also be written in plain code.
How do MCP and A2A relate to multi-agent systems?
MCP connects each agent to tools and data through a standard protocol. A2A lets agents built by different teams or vendors delegate tasks to each other. Inside a single system you control, ordinary function calls between agents are usually enough.
How do I test a multi-agent system?
Run the whole system on a fixed set of tasks with known answers, several times each, and compare it with a single-agent baseline on accuracy, cost and latency. Log every brief, tool call and finding so you can see which handoff caused a failure.
Design your agent team with guidance
Deciding between one agent and a team, choosing the pattern and keeping costs and risks under control is where most projects go wrong. If you want help designing a multi-agent system for your workflows, or training your team to build and test one, let's talk.
Next read: AI Agents That Work: How to Build, Evaluate and Secure Them