Search IOCombats

Search challenges, guides, questions and articles

When is a multi-agent system worth the extra complexity compared with a single agent?

Advanced12 min interview
Skills tested:
Identifying tasks that are truly parallel and independentExplaining context isolation as both the benefit and the risk of subagentsEstimating the cost multiplier of multi-agent designsImplementing a subagent as a tool with a compact return valueChoosing a single agent by default and justifying when to split

Advertisement

🧩 Scenario

Your product team wants an "AI design reviewer" that checks a Figma export for accessibility, copy tone and design-system consistency. One engineer proposes five specialist agents talking to each other. The interviewer asks when multiple agents are worth the complexity and what you would build instead or as well.

Concept Walkthrough

Why split at all?

A single agent has one context window and runs one loop at a time. Multiple agents help in two situations:

  1. Parallel, independent work. Researching five competitors is five separate searches. Running them at once is like Promise.all instead of awaiting in a loop.
  2. Context that will not fit, or should not mix. Each subagent gets a fresh context, digs through lots of material, and hands back a short summary. The parent stays clean, the same way a child component keeps its own state and only reports up through a callback.

The evidence on both sides

Anthropic's post on their research feature describes an orchestrator-worker setup: a lead agent plans and spawns subagents that search in parallel, then combines their findings. On their internal research eval, this setup beat a single agent clearly. They also report multi-agent runs using about 15x the tokens of a chat, and note that domains where agents must share the same context, or have many dependencies, are not a good fit. They call out that most coding tasks have fewer truly parallel parts than research.

Cognition's "Don't Build Multi-Agents" argues the other side: share full context, because actions carry implicit decisions. Their example splits a Flappy Bird clone into "background" and "bird" subtasks, and the two subagents produce parts in clashing styles.

Both posts agree on the key test: are the subtasks independent, or do they depend on each other's decisions?

Applying it to frontend work

Building a feature (component, styles, tests) is full of shared decisions: naming, props, design tokens. Split it across agents and you get the Flappy Bird problem. Checking a finished page for accessibility, copy and performance is closer to independent reads, so parallel reviewers can work, as long as one step merges and de-duplicates the results.

A sensible default

Start with one agent and good tools. Add a subagent when you can point to a specific bottleneck: the context fills with search results, or sequential steps make the response too slow. Then add guardrails: a cap on subagents, a step limit per subagent, a compact return format and tracing across all of them.


Key Code Explained

import { ToolLoopAgent, tool, isStepCount } from 'ai';
import { z } from 'zod';

const model = 'anthropic/claude-sonnet-5.5'; // example id

// A focused worker with its own instructions and a small step budget
const researcher = new ToolLoopAgent({
  model,
  instructions: 'Research one topic. Reply with at most 5 bullet points and source URLs.',
  tools: { /* webSearch, fetchPage ... */ },
  stopWhen: isStepCount(5),
});

// The subagent is exposed to the lead agent as a normal tool
const research = tool({
  description: 'Research one independent sub-question in a separate context.',
  inputSchema: z.object({ question: z.string() }),
  execute: async ({ question }, { abortSignal }) => {
    const result = await researcher.generate({ prompt: question, abortSignal });
    // Return only the compact answer, never the whole transcript
    return { summary: result.text };
  },
});

export const lead = new ToolLoopAgent({
  model,
  instructions:
    'Split the request into at most 4 independent sub-questions, call research for each, then write one combined answer.',
  tools: { research },
  stopWhen: isStepCount(8), // caps how many rounds of delegation can happen
});

The lead's context only ever holds short summaries, which is the main benefit. The prompt limits fan-out to four, but prompts are not guarantees, so in production you would also count calls inside execute and refuse extra ones. If the model requests several research calls in one step, they can run concurrently, which is where the speed gain comes from.


Tradeoffs

AspectSingle agentMultiple agents
Shared contextEverything in one placeEach agent sees only its slice
Consistency of decisionsHighRisk of conflicting choices
Parallel speedSequential stepsIndependent parts run together
Token costLowerMultiplies with each agent loop
DebuggingOne traceMany traces to stitch together
Best fitBuilding, editing, dependent stepsBroad research, independent checks

What Interviewers Actually Check

  • Whether you ask "are the subtasks independent?" before splitting
  • Whether you know context isolation is both the benefit and the risk
  • Whether you mention the cost multiplier with real evidence, not guesses
  • Whether you design compact hand-offs between agents
  • Whether you add limits and tracing to the orchestrator

Follow-Up Questions

  1. How would you merge findings from parallel subagents that contradict each other?
  2. What would you put in a subagent's prompt so it does not repeat work another subagent is doing?
  3. How would you show the progress of several subagents in the UI?
  4. How would you decide the step budget for each subagent?
  5. When would a fixed parallel workflow beat an orchestrator that decides subtasks at runtime?

Common Candidate Mistakes

  • Designing agents around roles because it looks like a team chart.
  • Assuming more agents means better answers without measuring.
  • Letting subagents return raw tool output to the parent.
  • Forgetting to pass the abort signal through, so cancelled requests keep spending tokens.
  • Not tracing which subagent produced which claim.

Interview Readiness Checklist

Before you leave this question, make sure you can answer:

  • Can you name the two main reasons to use multiple agents?
  • Can you explain the shared-context problem with an example?
  • Can you describe the orchestrator-worker pattern?
  • Can you implement a subagent as a tool with a compact result?
  • Can you list the limits you would put on an orchestrator?

Summary

Multiple agents are worth it when work splits into independent parts that benefit from running in parallel or from separate, clean context windows, such as broad research. They cost far more tokens, are harder to debug, and break down when subtasks share decisions, because each subagent sees only part of the picture. Default to a single agent with good tools. Split only for a measured bottleneck, implement subagents as tools that return compact results, and cap fan-out, steps and cost.

Frequently Asked Questions

How much more expensive are multi-agent systems?

In Anthropic's write-up of their research feature, agents used about 4x the tokens of a chat interaction and multi-agent systems about 15x. Your numbers will differ, so measure your own, but expect a large multiplier rather than a small one.

Is a subagent just a tool?

From the parent's point of view, often yes. The parent calls a tool, and that tool runs another model loop with its own instructions and context, then returns a compact result. This is the simplest way to add a subagent without a framework.

Why do subagents make conflicting decisions?

Each subagent only sees the context it was given. Cognition's "Don't Build Multi-Agents" post shows two subagents building parts of a game in clashing visual styles because neither saw the other's choices. Actions carry implicit decisions, and those decisions need shared context to stay consistent.

Advertisement


Stay Updated

Get the latest frontend challenges, interview questions and tutorials delivered to your inbox.

Namaste Dev
Sponsored

Cohort-style courses to go from tutorials to job-ready.

Explore Courses

Advertisement