Area 03 · AI Agents · Concept 12 of 20

Orchestrator-Worker Pattern

A lead agent splits the work, workers do the parts in parallel, the lead merges the results.

11–20 · Production levelPhase 3 · Weeks 11–14≈ 1.5 hours

The idea

For broad tasks (research a market, review a large codebase), one agent working sequentially is slow and its context fills up. An orchestrator breaks the task into independent subtasks, starts a worker agent for each with a focused brief, and merges what they return.

Workers run in parallel and each has a clean context, so they go deeper on their slice. The orchestrator only sees their condensed results. Anthropic described large gains from this pattern in its multi-agent research system, at the cost of many more tokens.

It suits tasks that split cleanly. Tasks with tight dependencies between parts are better done by one agent.

Why it matters

It is how agents scale to big tasks within latency and context limits.

Picture it

Words to know

  • SubagentA worker agent started by another agent for one subtask.

Try it without code

Split a research task

  1. Pick a question like "Compare three CRM tools for a 10-person startup".
  2. Write 3 independent worker briefs.
  3. Write how you would merge their outputs.

Use it in code

Plan subtasks, run workers in parallel with asyncio, merge.

python
import asyncio, json, anthropic
client = anthropic.AsyncAnthropic()

async def ask(prompt, model="claude-sonnet-5-5"):
    m = await client.messages.create(model=model, max_tokens=1500,
                                     messages=[{"role": "user", "content": prompt}])
    return m.content[0].text

async def orchestrate(task):
    plan = json.loads(await ask(f"Split into 3 independent research subtasks. JSON list of strings only.\nTask: {task}"))
    results = await asyncio.gather(*(ask(f"Research this and report key facts in 150 words:\n{s}") for s in plan))
    notes = "\n\n".join(f"## {s}\n{r}" for s, r in zip(plan, results))
    return await ask(f"Task: {task}\nWorker notes:\n{notes}\nWrite the final answer.")

print(asyncio.run(orchestrate("Compare three CRM tools for a 10-person startup")))
PRACTICE · TICK IT AFTER THIS

Run the same research task single-agent and orchestrator-worker; compare time, tokens and your quality score.

Common mistakes

  • Overlapping subtasks that duplicate work.
  • Ignoring the token bill of many parallel workers.

Go deeper