← All topics
Knowledge

Multi-agent: split roles, coordinate the work

Break a hard job into specialized agents with narrow roles and separate context windows, then coordinate their work through an orchestrator or a structured exchange.

What it is

Instead of one agent juggling everything, you split the job across several specialized agents — each with a narrow role and its own context window.

  • Orchestrator + workers: a lead agent decomposes the task, hands subtasks to workers, then merges their results.
  • Debate / roles: two or more agents take opposing or distinct stances (proposer vs critic, researcher vs writer) and the exchange sharpens the output.

The win is focus: each agent sees only what its job needs, so prompts stay short and behavior stays predictable.

When to use it

Reach for this when one agent is straining:

  • The task has distinct skills — research, then code, then review — that benefit from different prompts and tools.
  • Subtasks are independent and can run in parallel, cutting wall-clock time.
  • You want adversarial pressure — a critic agent catching what the author missed (close cousin of reflection).
  • One context window is overflowing with mixed concerns.

Don't use it when a single agent with good tools already does the job. Every extra agent adds coordination overhead, latency, and token cost. Start with one; split only when you feel the strain.

How it works

An orchestrator owns the goal and delegates; workers do narrow jobs and report back.

  • The orchestrator decomposes the goal — e.g. plan("ship feature X") returns subtasks research, implement, test.
  • It spawns a worker per subtask, passing only that subtask's context — not the whole conversation.
  • Each worker runs in its own context window and returns a structured result, like {status, output}.
  • The orchestrator collects results, resolves conflicts, and synthesizes the final answer.

Delegation often leans on planning up front, and the messages between agents are the surface you'll standardize via agent comms.

Watch out for

  • Coordination cost compounds. More agents means more round-trips, more tokens, more places to fail. A two-agent setup that works beats a five-agent one that thrashes.
  • Context loss at the seams. A worker only knows what you pass it; forget a key constraint and it confidently does the wrong thing.
  • Error propagation. A bad subtask result poisons the merge. Have the orchestrator validate worker output, not just concatenate it — see reliability.
  • No clear owner. Exactly one agent must own the final decision. Diffuse responsibility produces mush.

Related patterns

Ask the swarm