Coordinator and Subagents: Decompose, Delegate, Check Coverage, and Call Only the Spokes You Need
A research question about chat or email support goes to a coordinator with four subagents. The coordinator splits the question into distinct slices, calls only the spokes it needs, checks the draft for gaps and re-delegates. A plan that is too narrow gives a report that covers a third of the question.
What you will learn
- Name the coordinator's four jobs: decompose, delegate, aggregate and decide which spokes to call
- Give each subagent a distinct slice so no two search the same pages
- Run a coverage check on the draft and re-delegate a targeted query to fill a gap
- Define four subagents with AgentDefinition and give the coordinator Task in allowed_tools
Before you start
- The Claude Agent SDK: query and ClaudeAgentOptions
- Context isolation through subagents
Your boss asks: do customers prefer chat or email support? That isn't one lookup. It's a research job with several parts: search the web, read documents, merge the findings, write a report. Give all of that to one agent and its context fills with every page it reads and every note it keeps. Roles get mixed, details get lost, and the answer drifts.
So we split the work and give the splitting to one manager, the coordinator. The general hub-and-spoke shape (a hub in the middle, spokes that never talk to each other) is covered in hub and spoke in LangGraph, and why each spoke gets a clean context is covered in context isolation through subagents. This article is about what the coordinator itself has to get right, with the Claude Agent SDK.
The coordinator's four jobs
Think of a newsroom editor. The editor owns the whole story, gives each reporter a different topic, and every story comes back to the editor. Reporters never phone each other. The coordinator works the same way, and it has four jobs:
- Decompose. Split the question into distinct subtopics.
- Delegate. Send each piece to the right subagent.
- Aggregate. Collect the results into one picture.
- Decide. Choose which spokes to call for this query.
The subagents do the work. The coordinator does the thinking about the work. And because every message goes through the hub, the coordinator also owns routing, error handling and what information goes where.
Call only the spokes the query needs
The fourth job is the one people skip. Compare two questions.
A simple one: how fast does one vendor say its chat replies are? One search is enough. The coordinator calls web search and skips the rest.
A broad one: chat, email or phone, what do customers prefer? Now the full pipeline makes sense: search, document analysis, synthesis, report.
Give each subagent a distinct slice
Next, scope. Suppose three search agents all get the same brief: customer support preferences. They find the same pages three times. That's wasted work, and the merge step now has to remove duplicates.
Partition instead. Agent 1 owns chat support, agent 2 owns email, agent 3 owns phone. Each part of the question has exactly one owner. You can also split by source type: surveys, forums, reports. Either way, distinct subtopics or source types cut duplicated work.
Check the draft, fill the gap, synthesise again
First drafts have holes, so the coordinator refines:
Synthesis writes a first draft. The draft goes back to the coordinator, which checks it against the question. It finds a gap: there's no phone support data. So it re-delegates a targeted query, phone support only, to search and analysis, rather than rerunning the whole research. The new findings go back into synthesis, the coordinator checks again, and now coverage is fine. Only now is the report written.
research_team.py: four spokes, one hub
Here it is with the Claude Agent SDK: four AgentDefinitions and one set of coordinator options. The lecture shows this file but doesn't run it (it needs the SDK and a Claude login or API key), so there's no output to show.
"""Hub and spoke: one coordinator, four specialist subagents."""
import asyncio
from claude_agent_sdk import (AgentDefinition, ClaudeAgentOptions,
query)
AGENTS = {
"web_search": AgentDefinition(
description="Finds web sources on ONE assigned subtopic.",
prompt="Search the web for your subtopic. Return sources.",
tools=["WebSearch"]),
"doc_analysis": AgentDefinition(
description="Reads given documents and lists key findings.",
prompt="Read the documents you are given. List findings.",
tools=["Read"]),
"synthesis": AgentDefinition(
description="Merges findings into one cited summary.",
prompt="Combine the findings you are given. Cite each.",
tools=[]),
"report": AgentDefinition(
description="Writes the final report from a summary.",
prompt="Write a short report from the summary you get.",
tools=["Write"]),
}
COORDINATOR = """You lead a research team.
Split the question into distinct subtopics and source types.
Call only the subagents the question needs.
Subagents see only what you send them, so pass the facts.
Check the draft for gaps and re-delegate before the report."""
OPTIONS = ClaudeAgentOptions(
system_prompt=COORDINATOR,
allowed_tools=["Task"], # the coordinator may spawn subagents
agents=AGENTS,
)
async def main():
question = "Do customers prefer chat or email support?"
async for message in query(prompt=question, options=OPTIONS):
print(message)
asyncio.run(main())
What to notice:
descriptiontells the coordinator when to call each subagent. "Finds web sources on ONE assigned subtopic" also nudges it to hand out one slice per call.toolsgives each spoke only its own tools. Web search getsWebSearchand nothing else, document analysis getsRead, and report getsWrite.- The
COORDINATORprompt carries the four jobs as five plain lines: distinct subtopics and source types, only the subagents needed, pass the facts (a subagent sees only what the coordinator sends), and check for gaps before the report. The coverage loop lives here, as an instruction. There's no loop in the Python; the coordinator runs it through its own Task calls. allowed_tools=["Task"]is what lets the coordinator spawn a subagent at all. Without Task, it cannot spawn one. The exam guide calls this tool Task; newer Agent SDK docs may list it as Agent, so check the docs for your SDK version.
For the SDK basics (query, ClaudeAgentOptions) see the Claude Agent SDK. The project file and README for this lesson are in the community, free to join.
Break it: a plan that is too narrow
The lecture's failure case. The coordinator plans only one subtopic, chatbots. It calls web search once and writes the report.
The report covers chat. Email is missing. Phone is missing. It reads fine and covers a third of the question.
Every spoke did its job perfectly. The decomposition was the problem, so the fix goes in the coordinator's instructions: name every channel in the question, list the source types, and check the draft for gaps before the report. Lines two and five of COORDINATOR point the same way: distinct subtopics and source types, then a gap check before the report.
How this shows up in a question
A scenario describes a report that misses part of a broad topic, then offers causes like a missing tool, spokes running in the wrong order, or spokes that can't message each other. None of those produces missing coverage. When a broad question comes back incomplete, look at the decomposition first.
| Symptom | Where to look | Fix |
|---|---|---|
| Report covers chat only, email and phone missing | Coordinator's plan (decompose) | Name every channel and source type; check for gaps |
| Three agents return the same pages | Overlapping scope (delegate) | One distinct slice per subagent |
| A one-fact question runs the whole pipeline | Spoke selection (decide) | "Call only the subagents the question needs" |
| Coordinator never spawns a subagent | allowed_tools | Add Task (or Agent in newer docs) |
Common mistakes
- Blaming the spokes for a narrow report. A narrow plan gives an incomplete report, however good each spoke is.
- Giving every subagent the same brief. They duplicate each other's work. Partition by subtopic or source type.
- Letting spokes talk directly. Everything goes through the hub, which is what keeps routing, errors and information flow in one place.
- Assuming the subagent knows the question. It starts with a blank page and knows only what the coordinator sends. The next lesson, passing context to subagents, is about exactly that.
- Writing the report straight after the first draft. Check coverage first, re-delegate the gap with a targeted query, then report.
Quick recap
| Coordinator job | What it means here |
|---|---|
| Decompose | Chat, email, phone (or surveys, forums, reports), one owner each |
| Delegate | Each slice to the subagent whose description fits |
| Aggregate | Every result comes back to the hub, then to synthesis |
| Decide | One spoke for a simple query, the full pipeline for a broad one |
| Refine | Check the draft, re-delegate the gap, synthesise again |
Try it yourself
Add a fifth subagent to AGENTS, for example one that reads survey results only, and give it a description that says when to use it. Then ask a narrower question, such as one vendor's chat reply speed, and watch which spokes the coordinator calls. Finally remove the last line of COORDINATOR and see whether the coverage check still happens.
Related course on Udemy
Claude Certified Architect - Foundations (CCAR-F) Exam Prep
Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)Related posts
The Claude Messages API: Your First Call, Field by Field
One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.
Claude Tool Use: How tool_use and tool_result Work in the Messages API
Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.
Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.
Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.
