Multi-Agent Systems
Multiple agents means multiple prompts, tools, and traces. Use them when roles truly diverge. A second agent is not a substitute for a better tool.
- agents
- orchestration
- multi-agent
Five personas arguing in Slack is not architecture. It is token burn with extra steps. A multi-agent setup means more than one prompt, more than one toolbox, and more than one trace for a single user request. That tax is worth it when the roles cannot safely share a window. It is not worth it because a talk made “crews” sound like microservices.
If the second agent exists to “be more careful,” you wanted a better tool, a schema, or a unit test.
Key takeaways
- Extra agents mean extra prompts, tools, tokens, and traces. Pay that only when roles diverge.
- A second agent is not a substitute for a missing function.
- Supervisor-and-specialist and peer-to-peer are different control planes. Pick one.
- Isolated context stops dump-everything contamination. Shared context is a hidden global.
- One function call is cheaper than a crew, and easier to auth.
When a multi-agent setup earns the extra traces
Split when two of these are true:
- Different tools. A researcher may
grepthe repo. A deployer may hit Kubernetes. Putting both in one schema is how the researcher “helpfully” rolls a restart. - Different privileges. Read-only vs write. Customer-visible vs internal.
- Different context. A 4k-file exploration will drown the thread that is trying to write a three-line comment. A subagent with a fresh window is the point.
- Different stop rules. The explorer can take 20 steps. The writer gets two, then a human.
If they share tools, privileges, context, and stop rules, you have one agent with extra system prompts. Merge them.
type AgentId = 'triage' | 'patch' | 'review';
type AgentSpec = {
id: AgentId;
tools: Array<'read_file' | 'grep' | 'apply_patch' | 'run_tests' | 'post_comment'>;
maxSteps: number;
canWrite: boolean;
};
const specs: Record<AgentId, AgentSpec> = {
triage: {
id: 'triage',
tools: ['read_file', 'grep'],
maxSteps: 12,
canWrite: false,
},
patch: {
id: 'patch',
tools: ['read_file', 'apply_patch', 'run_tests'],
maxSteps: 8,
canWrite: true,
},
review: {
id: 'review',
tools: ['read_file', 'post_comment'],
maxSteps: 4,
canWrite: false,
},
};
Triage cannot apply_patch. Patch cannot post_comment on GitHub. Review cannot edit. That split is the product. Three “senior engineers” with the same tools is cosplay.
Supervisor vs peer
Two topologies. Do not mix them accidentally.
Supervisor. One router owns the user conversation. It delegates a job with a brief and receives a structured report. It never forwards the raw 80k-token explore dump. Handoffs are a tool the supervisor calls, with cycle detection.
Peer. Two agents pass a ticket between them (support ↔ billing). Each has a stop rule for ping-pong: max hops, or a terminal “human” state.
type Report = {
from: AgentId;
summary: string;
artifacts: Array<{ path: string; sha: string }>;
openQuestions: string[];
};
type SupervisorEvent =
| { type: 'delegate'; to: AgentId; task: string }
| { type: 'final'; text: string };
async function supervisorTurn(
event: SupervisorEvent,
run: (id: AgentId, task: string) => Promise<Report>,
): Promise<string | Report> {
if (event.type === 'final') return event.text;
if (event.to === 'patch' && !event.task.includes('test command')) {
return {
from: 'triage',
summary: 'refused: patch agent requires an explicit test command',
artifacts: [],
openQuestions: ['Which test should patch run?'],
};
}
return run(event.to, event.task);
}
The supervisor is allowed to refuse a delegation. That is the whole advantage over a group chat.
Anthropic’s agent skills (packaged instructions loaded on demand) and OpenAI’s agent tooling are ways to specialize behavior. They are not a reason to spin five concurrent conversations if one skill plus one tool would do.
Shared context vs isolated windows
Isolated. Child starts with a brief, its tools, and maybe one file. It returns a Report. Parent never sees the grep haystack. Cost: you might miss a detail that was in a dropped file. Benefit: the writer is not lost in the middle of a log.
Shared. Everyone appends to one message list. Simple. Also: the billing agent now sees the user’s password-reset draft, and the researcher now sees a half-applied patch. Shared context is a global variable. Use it for a short, two-agent ping with a hop cap.
Trace each agent separately. A single user-facing request id, child spans per agent, tool calls nested under the child. If you cannot answer “which agent spent 40k tokens,” you will not cut the bill. Tracing LLM apps is not optional once you have more than one loop.
A function call is cheaper than a crew
Before you add an agent, write the tool you are avoiding.
| Urge | Cheaper substitute |
|---|---|
| “Researcher agent to look up the refund window” | docs_search tool on the one agent |
| “Math agent” | prorate() in TypeScript |
| “Critic agent to check JSON” | Schema validation, then retry once |
| “Style agent” | System prompt, or a linter |
| “Team of personas for brainstorming” | One model, n samples, you pick |
Crews earn their keep in coding products where explore-and-patch really do need separate privileges and windows. They rarely earn their keep in a support chatbot. Start from what AI agents are and a single think-act-observe loop. Split when a privilege or a context budget forces you to.
Interview answer (out loud)
“Multi-agent means multiple prompts, tools, and traces for one request. I use it when roles diverge on tools, privileges, or context, like a read-only explorer and a gated patch agent. I prefer a supervisor that delegates a brief and gets a structured report, not a group chat. Isolated windows by default. If the second agent exists to be careful, I wanted a better tool or a schema. A function call is cheaper than a crew.”
Further reading (primary sources)
Related on this site
Related guides
- Agent HandoffsA handoff passes the conversation to another agent with a slimmer prompt and different tools. What to copy, what to drop, and how to avoid ping-pong.
- Graph Workflows for AgentsAn agent graph workflow makes loops, branches, and human pauses explicit. Use it when a hidden while-loop is how you lose the plot.
- Agent Failure ModesAgents loop, lie about tool results, skip confirmation, and get stuck apologizing. Catalog the failures and the circuit breakers.
- Agent MemoryAgents forget when the context window ends. Working memory, session summaries, and long-term stores are three different systems. Do not mix them.
- Agent System Design InterviewDesign a support or coding agent in a loop: tools, approvals, traces, evals, and cost. The frontend surfaces matter as much as the model.