Contents

Orchestrator–Workers

Also known as: lead agent and subagents, manager pattern, dynamic delegation

Who decides
A manager agent
Shape
Fan-out

Intent

A lead model reads the request, decides which subtasks it needs, and hands each one to a worker that starts with an empty context. The model decides this split for each request at run time, not the developer in code, and the lead merges the results or plans another round.

About the name. Many sources use “orchestrator” and “supervisor” for the same thing. On this site an orchestrator plans a batch of new subtasks at run time, while a supervisor picks one worker from a fixed roster at every step.

Problem

A platform team is building an internal assistant for tooling questions. A developer asks: “Compare Vitest, Jest and node:test for our TypeScript monorepo (about 1,200 test files, on Jest today), and recommend one.”

The first version is a single agent with web search and read access to the repository. It reads docs, benchmarks, migration guides and the repository’s config files one after another, all in one conversation, then writes the report. Three things go wrong:

A fixed pipeline with one research step per runner does not help either. The next question (“audit every route handler for missing auth checks”) needs a different split, and nobody knows that split before the request arrives.

A single agent reads pages for all three test runners into one context window, the earliest pages get buried, and the report comes out slow and uneven.Requestcompare 3 test runnersand recommend oneOne agentreads everything, in sequencecontext windowVitest pages (buried)Jest pagesnode:test pagesrepo config filesmigration guidesReportslow: one page at a timeearly sources lostuneven depth per runnerone prompt, every tool
Scroll to see all of it.
One agent reads everything into one context: the more it reads, the less it keeps of what it read first.

Solution

Split the work between a lead, the orchestrator, and workers. The lead plans, writes briefs and merges results, and does little reading itself. Each worker gets one brief, an empty context, a few tools and a budget, runs its own tool loop, and returns a condensed result instead of its whole transcript.

On the test-runner question, a run looks like this:

  1. Plan. The lead sees a comparison and decides on four subtasks: one per runner (CI speed, features, ecosystem), plus an inventory of the Jest-specific APIs the monorepo uses, such as mocks and custom matchers.
  2. Brief. For each subtask it writes a self-contained brief: the objective, what the other workers cover (so the Vitest worker leaves Jest alone), which sources to prefer, a tool-call budget, when to stop and the format of the result.
  3. Dispatch. Runtime code starts the four workers in parallel. Three search the web; the fourth has read-only access to the repository.
  4. Work and return. A worker may read tens of thousands of tokens, but it sends back a short result: findings with their sources, conflicts between sources and open questions. Raw benchmark tables go to a file store, and only a reference comes back.
  5. Synthesize or loop. The lead merges the four results and notices a gap: no worker found a CI benchmark for a repository of this size. It starts one more worker to time node:test and Vitest on one package, then writes the recommendation itself.

The model decides how many workers to start and when the run is finished; runtime code enforces the caps. The nearest pattern, Parallelization, also fans work out, but there the developer fixes the split in code, while here a model writes the list of subtasks for each request.

Structure

The task goes to the orchestrator, which writes briefs for three workers with separate contexts; workers return condensed results and store large outputs in an artifact store; the orchestrator synthesizes, then answers or plans another round, all inside limits enforced by runtime code.gaps found and budget left: another roundlarge outputsread on demandTaskOrchestratorplan + briefsVitest workerown context + toolsJest workerown context + toolsRepo workerread-only toolsOrchestratorsynthesizesAnswerArtifact storeRuntime code: worker cap, concurrency limit, timeouts, round and token budgets12345678
Scroll to see all of it.

Hover over a number, or tap it, to read what it is.

Solid arrows carry the task, briefs and answer; dashed arrows carry results. Both orchestrator boxes are the same agent at two moments, and workers never talk to each other.
  1. Orchestrator, planning. Reads the task and decides how many workers it needs and what each one covers. Usually the strongest model.
  2. Brief. The only thing a worker receives from the lead: the objective, what is out of scope, sources and tools, a budget, when to stop and the result format.
  3. Workers. Each does one bounded subtask in its own context, often as a ReAct loop with a small toolset, possibly on a cheaper model.
  4. Result. A fixed shape for what comes back: a status, a short summary, findings with sources, conflicts, open questions and references to stored outputs.
  5. Artifact store. Storage for bulky outputs, which reach the lead as references instead of filling its context.
  6. Orchestrator, synthesis. Merges the results, flags contradictions and spots gaps. Only the lead writes the final answer.
  7. Another round. When something important is missing and budget remains, the lead writes new briefs instead of answering.
  8. Runtime. Plain code that starts the workers and enforces limits on their number, time, rounds and tokens.

Use it when / Avoid it when

Use it when

Avoid it when

How it fails

Over-spawning

The lead starts a dozen workers for a simple question, and the cost of the run explodes.

Mitigation: give the lead effort rules (one worker for a simple fact, a few for a comparison) and enforce a hard cap on workers in code.

Duplicate work

Two workers research the same thing from vague briefs, while another part of the question goes uncovered.

Mitigation: say in every brief what the other workers cover and what is out of scope.

Conflicting decisions

Outputs that each look fine do not fit together, because each worker made its own assumptions.

Mitigation: keep the writing in one agent and put the shared decisions in every brief.

Lost detail

A number or a caveat disappears when a worker condenses its findings for the lead.

Mitigation: have workers store large outputs and return references, which the lead reads when precision matters.

Related patterns

Try it

Describe the requests your system handles and the worker types the lead can start. The generator writes two system prompts: one for the orchestrator, and one shared by the workers with the result format.

Further reading