Multi-Agent Systems
Learn when multiple specialized agents improve a task and when they only add complexity.
Why use more than one agent?
Multiple agents can help when a task contains genuinely different responsibilities, models need different tools, or independent perspectives improve review quality. A researcher may gather evidence, a planner may structure work, and a reviewer may challenge unsupported claims. Splitting a task is not automatically an improvement. Each handoff adds latency, token usage, state-management work, and another place for instructions to be misunderstood. Start with the smallest architecture that can meet the quality requirement.
Divide by responsibility
Good boundaries reflect different skills, permissions, or failure modes. A read-only research agent should not share credentials with an executor. A reviewer should receive the proposed result and evidence, not unrestricted access to every tool. Keep each role’s goal narrow and define the artifact it must return. “Researcher” is too vague unless its output specifies sources, claims, confidence, and unresolved questions. Clear responsibility makes both prompts and tests easier to maintain.
type Research = {
taskId: string;
claims: Array<{ text: string; source: string; confidence: number }>;
openQuestions: string[];
};
async function review(taskId: string, research: Research) {
if (research.claims.some((claim) => !claim.source)) {
return { taskId, status: 'needs-research' as const };
}
return reviewerAgent.check({ taskId, evidence: research.claims });
}
// The reviewer receives a narrow, inspectable artifact—not every tool.
Coordination patterns
Common patterns include a supervisor selecting specialists, a sequential pipeline passing artifacts from one role to the next, parallel workers producing independent results, and a reviewer deciding whether a result is acceptable. Choose based on dependency structure. Parallel work helps when tasks are independent; a sequential pipeline helps when later steps need earlier evidence. A supervisor can route dynamically but adds another model decision. Document the pattern as a workflow with states, inputs, outputs, and stop conditions.
Typed messages and state
Do not coordinate through unstructured agent-to-agent conversation when a typed artifact will do. Define fields such as task ID, source references, claims, confidence, errors, and next action. Give each field an owner and a lifecycle. Shared state should have concurrency rules, version checks, and tenant boundaries. Persist checkpoints for long jobs so a failed worker can resume without repeating completed side effects. Structured state turns a conversational swarm into a system that can be inspected.
Review is not truth
A reviewer model can catch omissions, contradictions, and format errors, but it can also agree with a confident mistake. Give it independent evidence, deterministic checks, and explicit criteria. For high-impact claims, compare against authoritative data or require human review. Avoid asking one model to generate and approve the same answer without additional signals. The reviewer’s output should state what it checked and what remains uncertain, rather than merely returning “approved.”
Costs and failure surfaces
If three agents each make two model calls and one call retries, a simple request can become seven calls before tools are counted. Measure the complete trace: tokens, model tier, tool calls, queue time, wall-clock latency, and human interventions. Set a per-task budget and stop when the expected value of another attempt is low. Add circuit breakers for repeated failures and degrade to a simpler workflow when a specialist is unavailable. Complexity must earn its cost through measurable quality gains.
Example: document due diligence
A document due-diligence workflow might use a parser to identify clauses, a researcher to retrieve related policy, a comparer to find conflicts, and a human reviewer to sign off. The parser should preserve page references, the researcher should return sources, and the comparer should cite both inputs. None of these agents should independently send legal advice to a customer. The final product can be a review packet with evidence and open questions, while a qualified person remains responsible for the decision.