Skip to the solution
HardAI Engineering13 min read

When should you split work across multiple agents instead of one?

947 views

The problem

Question presented to candidate: "Your team wants to rebuild its single agent as a 'team' of agents: a planner, researchers, a coder and a reviewer. When is splitting work across multiple agents actually the right call, when is it a mistake, and how would you decide for a given task?"

What a strong answer should cover:

  • The default is one capable agent with good tools; split only when a concrete constraint forces it
  • The real reasons to split: context isolation (a worker explores a lot and returns a short summary), parallelism over genuinely independent subtasks, and separation of role or permissions (an independent reviewer, a worker without write access)
  • The costs: lossy hand-offs (summaries drop the caveat that mattered), conflicting decisions between agents that cannot see each other, several times the tokens, harder debugging and more orchestration failure modes
  • A decision test: are the subtasks independent (no shared writes, no decisions that must agree)? Is the task valuable enough to pay for more tokens? Would a better tool or prompt fix it instead?
  • Named patterns and evidence: orchestrator-worker and parallelisation (Anthropic, "Building effective agents"), Anthropic's multi-agent research system results and its token cost, and Cognition's argument that parallel writers make incompatible implicit decisions
  • Anti-patterns: role-play org charts (PM agent, architect agent) passing messages with no isolation or parallelism benefit, and parallel workers editing the same files

Clarifying questions expected:

  • Are the subtasks independent, or do later ones depend on decisions made in earlier ones?
  • Is the bottleneck context size, wall-clock time, or quality, and what is the budget per task?

Code / implementation expected: Optional β€” an orchestrator that fans out independent subtasks and merges summaries, or the decision logic for when to fan out.

  • multi-agent
  • orchestration
  • subagents
  • architecture

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

13 min read Β· 11 sections

Read the code

Single agent vs orchestrator with an independence check
// Single agent vs orchestrator + workers, on a simple cost model with stated assumptions:
// every model turn re-reads its whole context; each turn takes 20 s; exploration results
// stay in the context of whoever did the exploring; a worker hands back only a summary.
const A = { base: 2000, brief: 500, turnsPerTask: 5, secPerTurn: 20 };

function single(tasks) {
  let ctx = A.base, input = 0, peak = ctx, turns = 0;
  for (const t of tasks) for (let j = 0; j < A.turnsPerTask; j++) {
    input += ctx; turns++;
    ctx += t.explore / A.turnsPerTask; peak = Math.max(peak, ctx);
  }
  return { input: input, peak: peak, seconds: turns * A.secPerTurn };
}

function fanOut(tasks) {
  let orch = A.base, input = 0, peak = orch, workerTurns = 0;
  input += orch; // one orchestrator turn to plan and dispatch
  for (const t of tasks) {
    let ctx = A.base + A.brief;
    for (let j = 0; j < A.turnsPerTask; j++) { input += ctx; ctx += t.explore / A.turnsPerTask; peak = Math.max(peak, ctx); }
    workerTurns = Math.max(workerTurns, A.turnsPerTask); // workers run in parallel
    orch += t.summary;
  }
  input += orch; peak = Math.max(peak, orch); // one turn to read summaries and synthesise
  return { input: input, peak: peak, seconds: (2 + workerTurns) * A.secPerTurn };
}

// Two sub-tasks can run in parallel only if neither writes what the other touches.
function conflicts(tasks) {
  const out = [];
  for (let i = 0; i < tasks.length; i++) for (let j = i + 1; j < tasks.length; j++) {
    const a = tasks[i], b = tasks[j];
    const shared = a.writes.filter((f) => b.writes.includes(f) || b.reads.includes(f))
      .concat(b.writes.filter((f) => a.reads.includes(f) && !a.writes.includes(f)));
    if (shared.length) out.push(a.name + "/" + b.name + " on " + shared.join(","));
  }
  return out;
}

const fmt = (r) => "input=" + String(r.input).padStart(7) + " tok  peak_context=" + String(r.peak).padStart(6) +
  " tok  wall=" + String(r.seconds).padStart(3) + " s";

const JOBS = {
  "research 4 vendors (read-only, independent)": ["acme", "globex", "initech", "umbrella"].map((n) =>
    ({ name: n, explore: 40000, summary: 600, reads: ["web:" + n], writes: ["notes/" + n + ".md"] })),
  "rename an auth API (shared files)": [
    { name: "change_api", explore: 6000, summary: 400, reads: ["auth.ts"], writes: ["auth.ts"] },
    { name: "update_callers", explore: 9000, summary: 400, reads: ["auth.ts", "app.ts"], writes: ["app.ts", "auth.ts"] },
    { name: "fix_tests", explore: 5000, summary: 400, reads: ["auth.ts", "app.ts"], writes: ["auth.test.ts"] },
  ],
  "answer one billing question (one small task)": [
    { name: "billing", explore: 3000, summary: 300, reads: ["db:invoices"], writes: [] },
  ],
};

for (const [job, tasks] of Object.entries(JOBS)) {
  console.log("== " + job);
  const c = conflicts(tasks);
  console.log("  single agent : " + fmt(single(tasks)));
  console.log("  orchestrator : " + fmt(fanOut(tasks)));
  console.log("  conflicts    : " + (c.length ? c.join("; ") : "none"));
  console.log("  decision     : " + (tasks.length < 2 ? "one agent; nothing to parallelise, orchestration only adds turns"
    : c.length ? "keep one agent (or one writer); parallel workers would race on shared files"
    : "fan out; isolation keeps each context small and the work runs in parallel"));
}

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 67 of 83 in AI engineering

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextHard

How do you evaluate and debug agent trajectories?

Continue