Jahanzaib
Architecture

Multi-Agent System

Two or more specialized agents that collaborate, hand off tasks, or critique each other.

Last updated: April 26, 2026

Definition

A multi-agent system splits a complex job across multiple agents, each with a focused role and tool set. Common patterns: orchestrator-and-workers (one router agent dispatches to specialists), debate (two agents argue, third judges), pipeline (sequential handoffs). The benefit is specialization. A "research" agent can have web search tools while a "writer" agent has only formatting tools. The cost is exploding token counts and harder debugging. Multi-agent is rarely the right first answer; try a single agent with more tools first.

Code Example

python
# Simple orchestrator pattern
async def orchestrator(task: str) -> str:
    plan = await planner_agent.plan(task)
    results = []
    for step in plan.steps:
        agent = pick_specialist(step.type)  # researcher | writer | coder
        results.append(await agent.run(step))
    return await synthesizer_agent.combine(results)

Orchestrator routes each step to the right specialist. Specialists never call each other directly.

When To Use

Use multi-agent when one agent's prompt is unmanageable, when different steps need genuinely different tool sets, or when you need a separate critic for quality. Default to a single agent first.

Related Terms

Building with Multi-Agent System?

I've shipped this pattern in real production systems. If you want a second pair of eyes on your architecture, that's what I do.