AI ENGINEERING · AGENTS · ORCHESTRATION · 18 OF 35

Multi-Agent Systems: Orchestrators, Workers and Handoffs

When to split work across several agents and when one is better: separate context windows, specialised prompts and parallel work against multiplied cost and failure points. Orchestrator and workers, pipelines, handoffs, critic loops and debate, a worked token-cost example, compact results, shared state, budgets and tracing.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
1 / 19

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Split for clean contexts and parallel work
  • pay in cost and failures
  • pass summaries
  • one owner
  • budgets
  • trace

Notes

The idea

Picture one agent writing a market report. It searches, reads pages and takes notes, and every result lands in the same context window. By step thirty it rereads sixty four thousand tokens to decide one small step. A multi-agent system splits that work across several agent loops. Each one has its own context, its own prompt and its own tools, and they pass results along.

One agent, one context
  • every search result, every page and every plan lands
  • in the same window
  • by step 30 the model is reading 64k tokens to decide one small step
  • multi-agent: several loops, each with its own context, prompt and tools

Why split

There are three real reasons to split. First, separate context windows. Each worker sees only its own subtask, so its context stays small and focused. Second, specialised prompts and tools. A worker with a short prompt and four relevant tools picks better than one agent juggling thirty. Third, parallel work. Independent subtasks run at the same time, so the user waits for the slowest one, not all of them in a row.

Three real reasons
  • 1 separate context windows each worker sees only its own subtask: less noise
  • 2 specialised prompts + tools a short prompt, 4 tools, not one prompt for all 3 parallel work independent subtasks run at the same time

Why not

And three real costs. Cost multiplies, because every agent pays for its own system prompt, its own tool list and its own exploration. Failure points multiply, because each hop is another place to go wrong. Three agents in a chain, each right ninety percent of the time, succeed together only about seventy three percent of the time. And coordination is hard. Briefs get misread, workers repeat each other, and their results can contradict.

Three real costs
  • 1 cost: every agent pays for its own prompt, tools and exploration
  • 2 more failure points: 3 hops at 90% each = 73%
  • 3 coordination overhead: briefs get misread, work overlaps, results conflict
  • harder to debug and to test

Orchestrator-workers

The most common pattern is an orchestrator with workers. The orchestrator reads the goal and splits it into subtasks: market size, competitors and regulation. It writes a brief for each one, with the goal, the scope, the expected output format and a budget, and starts three workers at once. Each worker searches on its own and returns short findings with sources. The orchestrator merges them, spots gaps, maybe sends one more worker, and writes the report.

Fan out, then merge
  • orchestrator: reads the goal, writes 3 briefs, starts 3 workers at once
  • each brief: goal, scope, output format, budget
  • workers: search and read, return short findings
  • orchestrator: merges, spots gaps, writes report

Worked example

Let us put numbers on it. Each agent starts with six thousand tokens of prompt and tools, and each step adds two thousand. One agent doing all thirty steps resends a growing context each time: about one point zero five million input tokens and ninety seconds. Three workers doing ten steps each use one hundred and fifty thousand tokens apiece. With the orchestrator, the total is under half a million, in about forty seconds, because no context grows large.

Same report, two designs
each step: +2k tokens, start 6k
one agent, 30 steps:
  30×6k + 2k×(0+…+29)
  = 180k + 870k ≈ 1.05M input
  ~30 steps in a row ≈ 90 s
3 workers, 10 steps each:
  10×6k + 2k×(0+…+9) = 150k
  ×3 = 450k, + orchestrator
  ~30k ≈ 0.48M input
  1 + 10 + 2 steps ≈ 40 s

The catch

Here is the catch. At the same depth, the team can be cheaper. Once work runs in parallel, you give each worker twenty steps to dig deeper. Now each one uses half a million tokens, and the total is about one point five five million, around one and a half times the single agent. Add overlapping searches, a reviewer and retries, and bills of several times one agent are normal. You buy depth and speed.

Why real bills go up
give each worker 20 steps:
  20×6k + 2k×190 = 500k each
  ×3 + orchestrator ≈ 1.55M
  ≈ 1.5× the single agent
+ overlapping searches
+ a reviewer pass
+ retries on failed workers

you pay more to go deeper,
in less wall time

Compact results

A worker should return a short structured result: the answer, a confidence, its sources and any open questions, around fifteen hundred tokens. Not its whole transcript. With summaries, the orchestrator merges from about eleven thousand tokens. With three full transcripts, it would read seventy eight thousand, and you have rebuilt the bloated single context you split to escape. Keep full transcripts in logs, not in prompts.

Pass results, not history
{ "subtask": "market size",
  "answer": "~4.2B USD, 2025",
  "confidence": "medium",
  "sources": [6 urls],
  "open_questions": [...] }

merge context, 3 workers:
  summaries: 6k + 3×1.5k ≈ 11k
  transcripts: 6k + 3×24k ≈ 78k

Pipeline

The second pattern is a pipeline, like an assembly line. A research agent produces notes, a writing agent turns them into a draft, and an editing agent polishes it. The order is fixed in your code, so this is really a workflow whose stages happen to be agents. It is predictable, and each stage can be tested alone. The weakness is that an early mistake flows all the way down, so validate output between stages.

Assembly line
  • research → write → edit
  • order fixed in code; each stage has its own prompt
  • + easy to test one stage
  • + predictable cost
  • an early mistake flows all the way down check output between stages

Handoffs

The third pattern is a handoff. A triage agent reads the message, sees a billing problem, and hands the conversation to a billing agent. The billing agent has its own prompt and the only refund tools. The handoff carries a short note: customer id, the issue and what was already tried. Specialists hand back when a request is out of scope, and you cap handoffs so agents cannot bounce a customer back and forth forever.

Triage to billing
  • triage: reads the message, picks the specialist
  • billing: own prompt, and the only agent with refund tools
  • handoff note: customer id, issue, what was tried
  • hand back when out of scope
  • cap handoffs: no ping-pong

Critic loop

The fourth pattern is a critic or reviewer loop. One agent drafts, and a reviewer checks the draft against a rubric, then returns either pass or specific fixes, like two claims lack sources. Reviewers work best when they can run real checks, such as tests or opening each citation. A copy of the same model with the same prompt shares the same blind spots. Cap the loop at two or three rounds, or it can polish forever.

Generate, review, revise
  • reviewer gets: the draft + a rubric, not the history
  • returns: pass, or specific fixes
  • best with real checks: run tests, open citations
  • same model, same prompt = same blind spots
  • max 2 to 3 rounds

Debate and judge

The fifth pattern is debate with a judge. Two or three agents answer the same hard question independently, sometimes reading and attacking each other's answers, and a judge agent picks the best or merges them. It helps on ambiguous decisions, but costs several full answers. A cheaper cousin is to sample a few answers and take a majority vote. And watch the judge: model judges are known to favour position, longer answers and their own style.

Debate, vote, judge
  • 2 to 3 agents answer the same question independently
  • optional: they read and attack each other's answers
  • judge: picks or merges
  • cheaper cousin: sample N answers, majority vote
  • judge bias: order, length, its own style

Shared state

When agents share state, like a task board or a folder of notes, decide who owns each piece. The orchestrator owns the plan and the final report. Each worker owns its own notes file. Others may read, or append to a log, but only the owner writes. Add version numbers so a slow agent cannot overwrite newer work. The classic failure is several agents editing one document at once, silently undoing each other. It is a classic distributed systems problem.

Who owns what
  • plan + task list: orchestrator
  • notes/market.md: worker A notes/rivals.md: worker B
  • final report: orchestrator
  • one writer per key; others read, or append to a log
  • version numbers stop lost updates
  • never: all edit one doc

Budgets and stopping

A team of agents needs stopping rules at two levels. Each worker gets a cap on steps, tokens and time. The whole task gets one global budget that every agent draws from, so ten workers cannot each spend the maximum. Limit spawn depth, so workers cannot start more workers. Cap critic rounds and handoffs. Write the definition of done into every brief, and when a limit is hit, return partial results with a clear status.

Limits that must exist
  • per worker: max steps, tokens, wall time
  • whole task: one global token and cost budget
  • spawn depth: workers may not start workers (depth 1)
  • critic rounds: max 2 to 3
  • handoffs: max 3 per chat
  • done: written in each brief
  • hit a limit: return partial

Tracing

When a multi-agent run gives a bad answer, you need to know which agent caused it. Give every task one trace id, and record a span for each agent, each tool call and each handoff, with its parent, tokens, cost, latency and status. Now the bad report has an explanation: worker C timed out three times, returned nothing, and the orchestrator wrote the regulation section from memory.

One trace, many spans
trace t-91  report  1.13M tok
 ├ orchestrator.plan    6k
 ├ worker A  18 steps  480k
 ├ worker B  20 steps  510k
 ├ worker C   7 steps  failed
 │  └ fetch() timeout x3
 ├ orchestrator.merge  11k
 └ reviewer   2 rounds 40k
span: parent, agent, tokens,
  cost, latency, status

Numbers worth knowing

Some numbers worth knowing. Most systems use two to five workers per task. A good worker result is about one to two thousand tokens. Each extra hop adds a model call, up to a few seconds. Expect a multi-agent design to spend roughly two to five times the tokens of one agent. Parallel workers can make the research phase up to N times faster, but the plan and merge steps stay serial. And chains of agents lose reliability fast.

Ballpark numbers
workers per task        2 - 5
worker result           ~1-2k tokens
extra hop               +1 call, 0.5-5 s
multi-agent tokens      ~2-5× one agent
parallel speed-up       up to ~N× on
                        the fan-out part
chain of 3 at 90%       ~73% success
critic rounds           2 - 3 max

Start with one

The practical rule: start with one agent, and split only when you can measure a reason. Quality drops late in long runs, one prompt holds rules that conflict, the tool list causes wrong picks, or independent subtasks are slow in a row. Common mistakes: agents designed like an org chart, agents chatting freely, sharing state with no owner, and having no global budget. Always compare against one agent on the same evals.

Split when you see
  • context overflows or quality drops late in runs
  • one prompt holds rules that conflict between tasks
  • too many tools, wrong picks
  • independent subtasks and latency matters
  • common mistakes: agents per job title, chatty agents, no owner, no global budget

Say it like this

How to say it. I would start with one agent. Evals showed quality falling past forty thousand tokens, and the subtopics were independent, so we split. An orchestrator fans out to three workers in parallel, and each returns a short structured summary with sources. There is one global token budget, workers cannot spawn workers, and every agent is traced. It costs about one and a half times the tokens, and it researches twice as deep in less time.

In the interview
  • "I would start with one agent. Evals showed quality falling past 40k tokens, so we split: an orchestrator fans out to 3 workers in parallel. Each returns a 1.5k JSON summary. One global token budget, depth 1, every agent traced. ~1.5× the tokens, 2× the depth."

Interview questions

Q1What is a multi-agent system?

Several agent loops, each with its own prompt, tools and context window, that cooperate on one task by passing results to each other. Common shapes are an orchestrator with workers, a fixed pipeline, handoffs between specialists, and critic or judge loops.

Q2When would you split a task across several agents?

When you can measure a reason: one context grows so large that quality drops, one prompt holds conflicting instructions or too many tools, or subtasks are independent and running them in parallel cuts latency. Otherwise a single agent is cheaper, simpler and easier to debug.

Q3What are the downsides of multi-agent designs?

Token cost multiplies because each agent pays for its own prompt, tools and exploration; every hop is another failure point, so reliability compounds downward; and coordination adds overhead such as misread briefs, duplicated work and conflicting results. Debugging also needs cross-agent tracing.

Q4How does the orchestrator-worker pattern work?

An orchestrator reads the goal, splits it into subtasks and writes a brief for each (goal, scope, output format, budget). Workers run in parallel and return compact findings, and the orchestrator merges them, fills gaps and produces the final answer.

Q5Why should workers return summaries instead of full transcripts?

Transcripts drag every search result and dead end back into the orchestrator's context, recreating the bloated window you split to avoid. A short structured result with the answer, confidence, sources and open questions keeps merging cheap and focused; full transcripts belong in logs.

Q6What is a handoff between agents?

One agent transfers the conversation to a specialist, for example triage handing a duplicate charge to a billing agent that alone holds refund tools. It passes a short note with ids, the issue and what was tried, and handoffs are capped to stop agents bouncing a user back and forth.

Q7How do you keep shared state consistent between agents?

Give each piece of state exactly one owner who may write it; others read it or append to a log. Use version numbers or compare-and-set so a slow agent cannot overwrite newer work, and never let several agents edit the same document freely.

Q8How do you stop a multi-agent system from running away on cost?

Cap steps, tokens and time per agent and also set one global budget for the whole task, limit spawn depth so workers cannot start workers, cap critic rounds and handoffs, and return partial results with a clear status when a limit is hit.

Q9How do you debug a bad answer from a multi-agent system?

Trace it: one trace id per task with a span for every agent, tool call and handoff, recording parent, tokens, cost, latency and status. That shows which agent failed, for example a worker that timed out and left the orchestrator guessing.