Multi-Agent Architecture
Independent educational resource, not an official Anthropic course. Facts about the API, prices and limits were checked against Anthropic's documentation on 15 November 2026 and the code was run against a local mock of the API, not the live service. Check the linked official pages before relying on a number, and test with your own key.
Multi-agent systems get a lot of attention, and for good reason: they can do things one agent can't. They also cost a lot more, fail in odd ways and are rarely the right first choice. This lesson explains what they are, what Anthropic reported from building one, and gives you a small tested version so you can see where the costs come from.
What you'll learn
- The orchestrator-worker architecture and what each part does.
- Why a worker needs a detailed brief.
- How to handle a worker that fails or runs out of budget.
- When multi-agent is worth it, and when a single agent is better.
Before you start
The architecture
┌───────── lead model ─────────┐
question ─────────► │ splits into briefs │
└──────┬─────────┬─────────┬───┘
▼ ▼ ▼
worker 1 worker 2 worker 3 (own context, own tools, own budget, in parallel)
│ │ │
└─────────┴────┬────┘
▼
┌───────── lead model ─────────┐
│ combines the findings │ ──► answer (and a list of gaps)
└──────────────────────────────┘
Anthropic describes its research feature this way: a lead agent plans, starts several subagents that search in parallel, and then combines what they find. Each worker has its own context window, which is the main benefit. Facts a worker reads along the way don't crowd the lead's context. Only a compact summary comes back.
What Anthropic reported
From their write-up on building the research system, three things stand out:
- It worked for a particular kind of task: broad, open-ended questions that need many sources, where parallel search pays off. They found it beat a single agent on their internal research evaluation.
- It cost a lot. They report agents using about four times the tokens of a chat, and multi-agent systems about fifteen times. Their conclusion is that it only makes sense when the value of the task is high enough to pay for that.
- They also say multi-agent systems are a poor fit for work where agents need much shared context or have many dependencies between them. Coding was their example of a task with fewer truly parallel pieces.
These are numbers from their research product, not a promise for yours. Measure your own.
Briefs: the part people skip
A worker starts knowing nothing but what you tell it. Vague instructions like "research laptops" make workers duplicate each other or wander. A brief needs an objective, the output format you want back, and boundaries saying what the others cover. Here's the code, tested end to end:
import json
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass, asdict
from llm import parse_json
@dataclass
class Brief:
"""What a worker is told. A worker has none of the lead's context, so a vague brief gives vague or duplicated work."""
objective: str
output_format: str
boundaries: str # what NOT to do or cover; stops two workers doing the same job
def to_prompt(self) -> str:
return (f"<objective>{self.objective}</objective>\n<output_format>{self.output_format}</output_format>\n"
f"<boundaries>{self.boundaries}</boundaries>")
@dataclass
class WorkerResult:
brief: Brief
ok: bool
text: str
tokens: int = 0
reason: str = ""
def plan_briefs(lead, question: str, max_workers: int = 3) -> list[Brief]:
raw = lead.complete(
f"Split this question into at most {max_workers} independent research briefs. Reply with a JSON array of objects "
f'with keys "objective", "output_format" and "boundaries". Boundaries must say what the other briefs cover, so work is not duplicated.\n\n'
f"<question>\n{question}\n</question>")
return [Brief(**{k: str(item[k]) for k in ("objective", "output_format", "boundaries")}) for item in parse_json(raw)][:max_workers]
def run_worker(make_agent, brief: Brief) -> WorkerResult:
try:
run = make_agent().run(brief.to_prompt())
except Exception as e: # noqa: BLE001 - one failed worker must not take the others down
return WorkerResult(brief, False, "", 0, f"{type(e).__name__}: {e}")
if run.status != "done":
return WorkerResult(brief, False, "", run.state["tokens"], run.reason)
return WorkerResult(brief, True, run.text, run.state["tokens"])
def research(lead, make_agent, question: str, max_workers: int = 3) -> dict:
briefs = plan_briefs(lead, question, max_workers)
with ThreadPoolExecutor(max_workers=max(1, len(briefs))) as pool:
results = list(pool.map(lambda b: run_worker(make_agent, b), briefs))
good = [r for r in results if r.ok]
gaps = [f"{r.brief.objective} ({r.reason})" for r in results if not r.ok]
if not good:
return {"answer": None, "gaps": gaps, "tokens": sum(r.tokens for r in results), "results": results}
findings = "\n\n".join(f"<finding objective=\"{r.brief.objective}\">{r.text}</finding>" for r in good)
note = f"\n\nThese parts could not be completed and must be mentioned as gaps: {gaps}" if gaps else ""
answer = lead.complete(f"Answer the question using only these findings. Say so if something is missing.{note}\n\n"
f"<question>\n{question}\n</question>\n\n{findings}")
return {"answer": answer, "gaps": gaps, "tokens": sum(r.tokens for r in results), "results": results}
def cost_multiple(single_tokens: int, multi_tokens: int) -> float:
"""Measure it on YOUR task. Anthropic's own multi-agent research write-up reported agents using about 4x the tokens
of a chat and multi-agent systems about 15x; treat those as a warning, not a forecast."""
return round(multi_tokens / single_tokens, 1)
Notice plan_briefs asks the lead to state boundaries explicitly, "what the other briefs cover", so two workers don't both look up price.
When a worker fails
With several workers, one will eventually fail: an exception, a tool outage or a spent budget. run_worker catches that and returns an unsuccessful result with the reason, so one failure doesn't throw away the others. The lead then answers from the successful findings, and is told which parts are missing so it can say so instead of papering over them. If every worker fails, research returns no answer rather than inventing one. Our tests cover a worker raising, a worker hitting its token budget (reported as token_budget) and all workers failing.
When not to use it
- The task fits comfortably in one context window and one agent can do it.
- The pieces depend on each other, so there's nothing to run in parallel.
- The value of a good answer doesn't justify several times the cost.
- You can't yet evaluate a single agent well. Adding more agents makes problems harder to find.
A related option is a plain subagent, as in Claude Code (lesson 5.8): one helper, a clean context, a summary back. That gives you most of the context benefit without a whole system.
Measuring the cost
cost_multiple divides multi-agent tokens by single-agent tokens for the same task. Run both on a set of real examples before deciding. If the multiple is high and quality hasn't clearly improved, you have your answer.
Real-world use case (illustrative scenario)
This scenario is an invented example to show how the ideas fit together. It is not a case study and its details are not measured results.
A shop's analyst asks, "How do our three main competitors handle returns, shipping times and warranties?" That's three independent research jobs: a good fit for three workers with distinct briefs, each reading several pages, then a lead combining a table. The same analyst asking "fix the typo on the returns page" doesn't need any of it. Using the research system for the typo would multiply the cost for no benefit.
Mistakes to avoid
- Spinning up agents for small tasks.
- Vague briefs, leading to duplicated or off-target work.
- Letting one failed worker fail the whole job.
- Hiding gaps: an answer that quietly leaves out a missing part is worse than one that says so.
- Not measuring cost against a single agent.
Security notes
Each worker reads outside content, so each is an injection target. Give workers read-only tools and no access to anything the lead holds. Treat a worker's returned text as untrusted data when the lead combines it, and don't let a worker's output become instructions for the lead.
Cost and speed
Parallel workers cut waiting time and raise token use. Put a budget on every worker, a limit on how many run at once, and a cap on workers per question. Use a smaller model for workers if quality holds up, a strategy Anthropic's cost guidance also discusses.
Key takeaways
- Lead plans, workers act in parallel with their own contexts, lead combines.
- Write detailed briefs with objective, output format and boundaries.
- Isolate failures and report gaps honestly.
- Multi-agent costs much more; use it for high-value, parallel, open-ended work.
Lesson recap: lead plans, workers act in parallel, lead combines; detailed briefs matter and the cost is high.
Quick quiz
- What's the main benefit of giving each worker its own context?
- What three things belong in a worker's brief?
- What happens in our code if one worker fails?
- Name a kind of task where multi-agent is a poor fit.
- How do you decide whether it's worth the cost?
Answers and explanations
- What a worker reads doesn't fill the lead's context; only a compact summary comes back, and workers can run in parallel.
- An objective, the output format and boundaries saying what other workers cover.
- Its failure is recorded with a reason, the other results are still used, and the lead is told about the gap.
- Work with heavy shared context or many dependencies between parts, such as much coding work.
- Run the same examples through a single agent and the multi-agent version, then compare quality against token cost.
Official references and further reading
Related tutorials