27.1 Why Multi-Agent?
Monolithic agents struggle when single prompts are overloaded with conflicting instructions, bloated tool definitions, and incompatible permission tiers. Multi-agent systems decompose complexity across focused specialists, each maintaining isolated prompts, restricted tool scopes, and distinct context windows.
27.2 Hierarchical (Manager + Workers)
flowchart TD
Manager["Orchestrator / Manager Agent\n(Decomposes Goals, Evaluates Progress & Synthesizes)"]
subgraph Specialists["Specialized Worker Agents"]
Research["Research Specialist\n• Web Search\n• Internal RAG Vector DB"]
Analysis["Analysis Specialist\n• SQL Query Runner\n• Statistical Sandbox"]
Writer["Synthesis Specialist\n• Markdown Formatter\n• Citations & Review"]
end
Manager -->|Dispatches Sub-Task 1| Research
Manager -->|Dispatches Sub-Task 2| Analysis
Research -.->|Returns Findings| Manager
Analysis -.->|Returns Data Summary| Manager
Manager -->|Dispatches Assembly| Writer
Writer -.->|Returns Final Report| Manager
- Pros: clear hierarchy, controllable, predictable, easy to reason about failure isolation.
- Cons: the orchestrator is a single point of failure and a concurrency bottleneck.
- Use when: there is a natural hierarchy of tasks and coordination overhead is acceptable.
27.3 Peer-to-Peer (Collaborative / Debate)
┌────────┐ ┌────────┐
│Agent A │◀═══════▶│Agent B │
└───┬────┘ └───┬────┘
│ Disagree? │
└────────┬─────────┘
▼
┌──────────┐
│ Arbiter │ ← resolves conflicts
│ Agent │ or escalates to human
└──────────┘
Agents communicate directly (or via a shared message bus) and contribute competing or complementary perspectives — e.g., a “propose” agent and a “review/critique” agent that debate until they converge, with a senior arbiter or human breaking ties. Use when agents need to negotiate, cross-check each other, or represent genuinely different viewpoints (market analysis vs. risk assessment vs. financial modeling).
27.4 Sequential Pipeline
Input → [Classifier] → [Researcher] → [Analyzer] → [Writer] → [Reviewer] → Output
Agent Agent Agent Agent Agent
Each agent processes and hands off to the next. Simple, fully debuggable (trace each stage independently), but no parallelism and no feedback loop — the slowest agent bounds total latency, and a downstream failure cannot easily reshape upstream work.
Use when: the task has a natural, linear workflow (e.g., document classification → extraction → analysis → summary → quality review).
27.5 Dynamic Routing (Recommended for Production Assistants)
┌──────────────┐
│ Router Agent │ ─── classifies intent/complexity and selects agent(s)
└──────┬───────┘
│
┌──────▼───────────────────────────────────┐
│ Agent Pool │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │ FAQ │ │Search│ │Action│ │Expert│ │
│ │Agent │ │Agent │ │Agent │ │Agent │ │
│ └──────┘ └──────┘ └──────┘ └──────┘ │
└──────────────────────────────────────────┘
A cheap router model classifies the request and dispatches to the right specialist (or specialists) — simple questions go to a cheap FAQ agent, complex questions to an expensive expert model, action requests to an action agent gated by approval. This pattern optimizes cost and latency simultaneously by matching model/tool cost to task complexity.
27.6 Choosing a Multi-Agent Architecture — Decision Framework
Task Complexity?
/ \
Simple Complex
│ │
Single Agent How many domains of expertise?
/ \
1 domain 2+ domains
│ │
Single Agent Multi-Agent
with tools with orchestration
(pick pattern above
by coordination need)
Rule of thumb: start single-agent + tools. Multi-agent adds complexity exponentially (state passing, partial failure handling, cross-agent context, evaluation surface). Only split into multiple agents once a single agent genuinely cannot handle the workflow — e.g., distinct expertise domains, distinct permission boundaries, or a latency win from real parallelism.
Section 27 — Interview Q&A
Q1: How do you decide between a single agent and a multi-agent system? Use a single agent when the task completes in under ~10 tool calls, all needed expertise is in one domain, latency matters (sub-5-second responses), and the workflow is simple/well-defined (e.g., a lookup or FAQ bot). Move to multi-agent when the task spans multiple expertise domains, has branching logic, requires different permission levels per action, or when true parallelism would meaningfully cut latency (e.g., detect → triage → diagnose → remediate in incident response).
Q2: What’s the failure mode of the hierarchical pattern, and how do you mitigate it? The orchestrator is a single point of failure and a throughput bottleneck — if it goes down or is slow, the whole pipeline stalls. Mitigate with: stateless, horizontally scaled orchestrator instances behind a queue; checkpointing orchestrator state so a crashed instance can be resumed by another; and circuit breakers so a stuck worker doesn’t block the orchestrator indefinitely.
Q3: Design a multi-agent system for automated incident response (or an analogous multi-stage enterprise workflow). Agent 1 (Alert Aggregator) — dedupes/correlates raw alerts into a consolidated incident. Agent 2 (Triage) — classifies severity/blast radius using a knowledge graph and SLO data. Agent 3 (Diagnosis) — queries logs/metrics/deployment history and traverses the dependency graph for root cause. Agent 4 (Remediation) — matches root cause to a runbook and executes pre-approved actions with human-in-the-loop for anything production-mutating. Agent 5 (Communication) — drafts stakeholder updates. Orchestration via a graph-based state machine (e.g., LangGraph) with a shared incident-state object, explicit success/failure transitions per agent, and timeout-driven escalation to a human operator.