Skip to content
mentoor

Topic 3 of 5 · 5 min read

Orchestrator and worker delegation patterns

Goal: Pick a delegation pattern for a multi-part change and split the work into areas that do not overlap.

Split work along seams where the parts do not need each other: by phase (explore, plan, implement, review) or by area (one worker per package), and never let two workers write the same file.

Check yourself · 1 of 3

What is a safe rule for splitting work across parallel worker agents?

Choose one answer

Why it matters

The delegation pattern decides whether the run is fast and clean or a pile of conflicting edits. Anthropic describes two useful shapes in its write-up on building agents: parallelization, where independent subtasks run at once, and orchestrator-workers, where a lead agent breaks work down and hands pieces to workers. Most coding setups combine them.

Pattern 1: phases in a line

  1. Explore (read-only, small model): map the code, return paths.
  2. Plan (parent): decide the change and split it.
  3. Implement (workers): write code and tests.
  4. Review (a different agent): check the whole result.

Each phase gets the previous phase's output, written down. The reviewer stays separate from the implementers, so nobody grades their own work.

Pattern 2: fan-out over areas

When the plan shows independent areas, send one worker to each. Good seams are packages, services, or layers that share no files. A worker owns a list of paths and edits only those.

Pattern 3: one reviewer at the end

Run one typecheck, one test pass and one review over the merged result. Parallel workers each running the full test suite repeat the same expensive work and see each other's half-finished files.

How to split without overlap

  • Write the area list as file paths or folders, with no path in two lists.
  • Shared files (a config, a changelog, a type barrel) belong to the parent or to one named worker.
  • If two areas must change one interface, do that change first, then fan out.

Before and after

Weak plan: "Worker 1: update the API. Worker 2: update the client. Worker 3: update the tests." The client and tests both depend on the API shape, and all three may edit types.ts.

Fixed plan: the parent changes types.ts first. Then worker 1 owns api/, worker 2 owns client/, worker 3 owns the tests for each, and one reviewer runs everything at the end.

What goes wrong

  • Overlapping areas. Two workers edit one file; the last write wins and the first fix is lost.
  • Fan-out before the interface is stable. Workers build against different guesses.
  • No final review. Each part passes alone, and the merged result still breaks.

Examples

A plan with clean seams

Goal: add a locale field to orders.

Parent:    edit packages/shared/src/order.ts (the type), then start workers
Worker A:  owns packages/api/**       (db, handler, API tests)
Worker B:  owns packages/web/**       (form, display, UI tests)
Worker C:  owns docs/orders.md
Reviewer:  after all finish, run typecheck and tests once, review the whole diff

No path appears twice, and the shared type is fixed before anyone fans out.

Collision

Two workers both add an export to index.ts. Worker B overwrites worker A's line. Both reports say "done", and the build fails. The fix was to give index.ts to the parent.

Key points

  • Phases (explore, plan, implement, review) keep each agent's job small and let a separate reviewer check the result.
  • Fan out only across areas that share no files.
  • Shared files belong to the parent or exactly one worker.
  • Stabilise any shared interface before parallel workers start.
  • Run one verification pass at the end instead of one per worker.

Common mistakes

  • Assigning areas by topic ("auth") instead of by file paths, so they overlap.
  • Starting parallel workers before the shared type or interface is settled.
  • Letting every worker run the full test suite.
  • Skipping the final review because each worker reported success.

Check yourself · 2 of 3

Two areas both need a new field added to one shared type. When should that type change happen?

Choose one answer

Check yourself · 3 of 3

Why run one reviewer over the merged result instead of tests inside each worker?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic