Multi-agent patterns: when several agents help
How the orchestrator and subagent pattern works in Claude Code and the Agent SDK, when several agents help or hurt, and how to control cost and check their work. 8 min
Read
Orchestrator and subagents
In the orchestrator pattern, a lead agent splits a job into parts, hands each part to a subagent and combines what comes back. Each subagent works in its own fresh context window with its own instructions and tools, and only its final report returns to the lead, which keeps the lead's context clean.
Anthropic's engineering write-up of its Research feature describes this design: a lead agent sends several subagents searching in parallel, then pulls their findings together. On Anthropic's internal research evaluation, that multi-agent setup (Claude Opus 4 leading Claude Sonnet 4 subagents) scored 90.2% higher than Opus 4 working alone.
The catch: a subagent knows only what you give it. In the Agent SDK, the only thing passed from lead to subagent is the delegation prompt, so include file paths, decisions already made and the output format you expect.
Lesson notes: Multi-agent patterns: when several agents help
Everything in this lesson as text, for revision or to read without the interactive steps. By the end you will be able to: You can decide when to split work across subagents and set one up with limits and checks.
Step 1 of 6 · Read
Orchestrator and subagents
In the orchestrator pattern, a lead agent splits a job into parts, hands each part to a subagent and combines what comes back. Each subagent works in its own fresh context window with its own instructions and tools, and only its final report returns to the lead, which keeps the lead's context clean.
Anthropic's engineering write-up of its Research feature describes this design: a lead agent sends several subagents searching in parallel, then pulls their findings together. On Anthropic's internal research evaluation, that multi-agent setup (Claude Opus 4 leading Claude Sonnet 4 subagents) scored 90.2% higher than Opus 4 working alone.
The catch: a subagent knows only what you give it. In the Agent SDK, the only thing passed from lead to subagent is the delegation prompt, so include file paths, decisions already made and the output format you expect.
Step 2 of 6 · Read
Define a subagent
In Claude Code a subagent is a Markdown file with frontmatter, saved in
.claude/agents/for one project or~/.claude/agents/for all your projects. Onlynameanddescriptionare required. The description tells Claude when to delegate, the body becomes the subagent's system prompt, andtoolslimits what it can touch.In the Agent SDK you pass the same thing in code, through the
agentsoption with anAgentDefinitionfor each one, and include"Agent"inallowed_toolsso the lead can delegate without a prompt..claude/agents/contract-checker.md --- name: contract-checker description: Reviews one supplier contract for renewal dates, notice periods and price rises. Use when asked to check contracts, one contract per subagent. tools: Read, Grep, Glob model: haiku --- You check one contract. Reply in exactly this format: - File: - Renewal date: - Notice period: - Price rise clauses: - Anything unusual: Quote the clause number for every point. If something is missing, write "Not found". Do not edit any file.
Step 3 of 6 · Sort
One agent or several?
Where do subagents earn their cost?
- Check 30 separate contracts for renewal dates
- A tight edit, run, fix loop on one function
- Research five competitors and compare them
- Plan, build and test one small feature where each step depends on the last
- Search a huge codebase where raw results would flood the main conversation
- A quick question you want answered in seconds
Show the answers
- Check 30 separate contracts for renewal dates: Subagents help. Independent pieces that can run in parallel and each return a short report.
- A tight edit, run, fix loop on one function: One agent is better. Every step needs the same context. Handoffs add delay and drop detail.
- Research five competitors and compare them: Subagents help. Broad, parallel searching is the pattern Anthropic built Research on.
- Plan, build and test one small feature where each step depends on the last: One agent is better. Anthropic notes most coding tasks have fewer parallel parts than research and need shared context.
- Search a huge codebase where raw results would flood the main conversation: Subagents help. The subagent absorbs the noise and hands back a summary.
- A quick question you want answered in seconds: One agent is better. Starting subagents adds time for no benefit.
Step 4 of 6 · Read
Control the cost
More agents means more tokens. In the same write-up, Anthropic reports agents using about 4 times the tokens of a chat, and multi-agent systems about 15 times. In Claude Code, each subagent's requests count toward the same usage limits as your main session.
Send simple subtasks to a cheaper model with
model: haiku, and cap the growth. In the Agent SDK,max_budget_usdends the run at a spend limit,CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTScaps how many run at once (default 20), andCLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHcaps nesting (default 3 layers; set it to 1 so subagents cannot start their own). Checked 18 November 2026.Python: caps on a multi-agent run options = ClaudeAgentOptions( allowed_tools=["Read", "Grep", "Glob", "Agent"], env={ "CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "1", "CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS": "5", }, max_budget_usd=5.0, )Step 5 of 6 · Read
Check the work
Give every subagent the same output format so results can be compared and merged, and ask for evidence with each claim, such as a clause number or a source link.
Then check. A separate reviewer agent with read-only tools can test each report against a short rubric: accurate, complete, cites its source. Anthropic's Research team found a single judging prompt scored against a rubric matched human judgement best, and still kept people testing to catch what automation missed.
Spot-check by hand. Pick two or three reports at random and read the source yourself before you act on the combined answer.
Step 6 of 6 · Quiz
Check your understanding
Thirty contract subagents finish, and the lead's summary says one contract auto-renews next month unless you give notice. What next?
- Act on it straight away, because the subagent quoted a clause
- Open that contract and read the cited clause before acting
- Rerun all 30 subagents on a bigger model to be sure
Show the answer
Open that contract and read the cited clause before acting The evidence you asked for makes the check quick, and a decision with a deadline deserves a human read.