Track 4 · Architecture 1 / 29
Track 4 · Architecture

Multi-Agent Systems

Orchestrate fleets of specialized agents that divide, parallelize, and coordinate complex work — without a single agent getting overwhelmed.

Module 14 of 30
20 min read
5 concepts
29 cards

Prerequisites: M12 (Tool Use), M13 (Orchestration). This module covers the leap from one clever agent to a coordinated crew.

Concept Index

Tap to jump to any concept.

Concept 1 of 5

When One Agent Isn't Enough

A single Claude instance handles one thing at a time with a fixed context window. When tasks grow large enough to exceed that window, span multiple specializations, or benefit from parallelism, you need a crew — multiple agents with distinct roles working in concert.

Four signals tell you it's time to split: the task doesn't fit one context window, different steps need different expertise, sub-tasks can run in parallel, or you need failure in one part to not cascade into everything else.

A 1,200-token system prompt trying to make Claude an expert at research, writing, legal review, and formatting is worse than four 300-token specialists — each expert at one thing.

Concept 1 of 5

Analogy

Solo Contractor → Construction Crew
Before

You hire one contractor to build a house. They're competent, but they handle electrical, plumbing, framing, and finishing sequentially, alone. Every sub-task blocks on the last.

Pain

The contractor gets overwhelmed. Framing mistakes delay plumbing. A single error cascades through the whole build. The house takes twice as long and quality suffers everywhere.

Mapping

A construction crew assigns specialists: electricians, plumbers, framers — each with focused expertise. The foreman coordinates. Work runs in parallel. One trade failing doesn't stop another. Multi-agent systems are the crew.

Concept 1 of 5

How It Works

  1. 1
    Identify the split signals
    Context overflow, multi-specialization, parallelism opportunity, or failure isolation need — any one qualifies.
  2. 2
    Assign roles
    Each agent gets a narrow, focused system prompt (300 tokens beats 1,200-token generalist).
  3. 3
    Limit tools per agent
    Accuracy degrades when an agent has more than ~5 tools. Specialists stay under the limit.
  4. 4
    Isolate failures
    Design so one agent's error doesn't silently corrupt the whole pipeline — surface errors explicitly.
Multi-agent vs. Single-agent
Generalist
Context overload, tool degradation
Coordinator
Specialist A
Specialist B
Specialist C
Concept 1 of 5

Decision Framework

When should you split into multiple agents?

FUNCTION should_split(task):
  # Signal 1: context window
  IF task.token_estimate > context_limit * 0.7:
    RETURN "SPLIT — context overflow risk"

  # Signal 2: distinct expertise
  IF task.domains.count > 2:
    RETURN "SPLIT — use specialist agents"

  # Signal 3: parallelism
  IF task.has_independent_subtasks:
    RETURN "SPLIT — run subtasks concurrently"

  # Signal 4: failure isolation
  IF task.failure_must_not_cascade:
    RETURN "SPLIT — isolate blast radius"

  RETURN "SINGLE AGENT is fine"
Concept 1 of 5

Common Misconceptions

Myth: More agents = better results

Multi-agent systems add orchestration overhead, latency, and coordination complexity. Use the minimum number of agents the task actually requires — start single, split when a specific signal fires.

Myth: Agents share context automatically

Each subagent starts with a blank context window. Only what you explicitly pass in the handoff message is visible. Context does NOT flow automatically between agents.

💡 Key Takeaway

Multi-agent systems earn their complexity only when a specific signal fires: context overflow, multi-domain specialization, parallelism, or failure isolation. Never split by default.

Concept 2 of 5

Architecture Patterns

Three proven topologies exist for connecting multiple agents. The right choice depends on whether tasks are independent or sequential, whether you need easy debugging, and whether the roles are fixed or dynamic.

Supervisor/Worker (hub-and-spoke) is the most common and easiest to debug. Pipeline suits sequential refinement. Peer-to-peer is flexible but rare in production because debugging becomes hard when any agent can talk to any other.

The cert exam (Domain 1.2) favors Supervisor/Worker as the default pattern — it's auditable, role boundaries are clear, and failures surface at the supervisor.

Concept 2 of 5

Analogy

Kitchen Crews
Before

Imagine running a restaurant where every chef can give orders to every other chef. A dish touches six hands with no one coordinating the order. Timing is chaos.

Pain

The fish and the steak arrive at the table 8 minutes apart. Two chefs independently started the same sauce. Nobody agreed on who owns the dessert.

Mapping

The head chef (supervisor) owns the sequence and timing. Line cooks (workers) execute focused tasks and report back. That's hub-and-spoke. A single assembly line (pipeline) works when each dish must pass through every station in order. Peer-to-peer is the chaotic kitchen with no head chef.

Concept 2 of 5

How It Works

Three Topologies
Hub-and-spoke (Supervisor/Worker)
Supervisor
Worker A
Worker B
Worker C
Pipeline (sequential)
Stage 1
Stage 2
Stage 3
Peer-to-peer (mesh)
A
B
C
← hard to debug
  1. 1
    Start with Supervisor/Worker
    Default for most tasks — easy to audit, supervisor owns the state.
  2. 2
    Use Pipeline for refinement chains
    Draft → Review → Edit → Publish — each stage adds value to prior output.
  3. 3
    Avoid Peer-to-peer in production
    Flexible but debugging loop-backs is very hard; reserve for research prototypes.
Concept 2 of 5

Decision Framework

Which topology fits your use case?

Pattern Best For Trade-off
Supervisor/Worker Parallel independent tasks, mixed role budgets Extra supervisor call per cycle
Pipeline Sequential refinement (draft → review → edit) No parallelism — bottleneck at each stage
Peer-to-peer Dynamic, exploratory tasks Hard to debug, rare in production
FUNCTION choose_topology(task):
  IF task.subtasks_are_independent:
    RETURN "SUPERVISOR_WORKER"
  IF task.is_refinement_chain:
    RETURN "PIPELINE"
  IF task.is_exploratory_prototype:
    RETURN "PEER_TO_PEER"
  RETURN "SUPERVISOR_WORKER" # safe default
Concept 2 of 5

Common Misconceptions

Myth: Pipeline is faster than Supervisor/Worker

Pipeline is strictly sequential — no step starts until the prior completes. Supervisor/Worker can dispatch multiple workers in parallel. For independent sub-tasks, hub-and-spoke is almost always faster.

Myth: All agents must use the same model

Route expensive tasks to Opus, cheap tasks to Haiku. A Supervisor/Worker pattern lets you assign a model per role — the biggest cost lever in multi-agent systems.

💡 Key Takeaway

Default to Supervisor/Worker. It's the cert-preferred pattern, easiest to debug, and supports model-per-role cost optimization. Switch to Pipeline only for true refinement chains.

Concept 3 of 5

Agent Communication Protocols

Agents don't communicate through magic — every handoff is a structured message passed explicitly. The #1 failure mode in multi-agent systems is context dropping: critical information exists in one agent's context but never makes it into the next agent's message.

Good protocols define exactly what fields every handoff message must carry: sender, receiver, task ID, type, payload, original goal, and structured error context on failure.

Cert Domain 1.3: Subagents have isolated context windows. They do NOT inherit the coordinator's conversation history — only what you pass explicitly.

Concept 3 of 5

Analogy

Medical Referral Letter
Before

Your GP has your complete history — medications, allergies, past surgeries. They refer you to a specialist who has never met you and knows nothing about your case.

Pain

The specialist asks you to repeat everything from scratch. They miss context your GP considered obvious. They prescribe something that conflicts with your existing medication because the referral said "see cardiologist."

Mapping

A proper referral letter explicitly includes: patient history, reason for referral, active medications, known allergies, and the GP's working hypothesis. That letter is your handoff message. Without it, the specialist (subagent) starts blind.

Concept 3 of 5

How It Works

  1. 1
    Define message schema
    Every handoff carries: sender, receiver, task_id, type, payload, original_goal, instructions, metadata.
  2. 2
    Include original_goal always
    Without the overarching goal, a subagent optimizes locally and may contradict the system's intent.
  3. 3
    Propagate errors structurally
    On failure: return type=ERROR with error_type, message, context, and suggested_recovery — don't let errors vanish silently.
  4. 4
    Never assume shared state
    Each agent starts with a blank context. Everything it needs must arrive in the message.
Concept 3 of 5

Pseudocode

# Handoff message schema
FUNCTION build_handoff(task, goal):
  RETURN {
    "sender":        "coordinator",
    "receiver":      task.assigned_agent,
    "task_id":       generate_uuid(),
    "type":          "TASK_REQUEST",
    "payload":       task.data,
    "original_goal": goal,  # NEVER omit
    "instructions":  task.spec,
    "metadata":      { "timestamp": now() }
  }

# Error response schema
FUNCTION build_error(exc, context):
  RETURN {
    "type":               "ERROR",
    "error_type":         exc.class,
    "message":            exc.message,
    "context":            context,
    "suggested_recovery": suggest(exc)
  }
Concept 3 of 5

Common Misconceptions

Myth: Subagents inherit the coordinator's context

They do not. Each subagent opens with a blank context window. The coordinator must explicitly pass every piece of information the subagent will need — there is no automatic inheritance.

Myth: Errors propagate automatically so you can ignore them

Errors vanish silently if you don't structure them. A subagent that fails with no error message makes the coordinator think success. Always return a structured error payload with recovery guidance.

💡 Key Takeaway

Every handoff is an explicit letter, not a phone call. Include the original goal in every message, structure errors so they surface, and never assume context flows automatically.

Concept 4 of 5

Shared State vs. Message Passing

When multiple agents need to exchange data, you have two fundamental approaches. Shared state (a central database or dict all agents can read/write) is intuitive but creates race conditions when two agents write simultaneously. Message passing keeps each agent's state private and exchanges outputs explicitly — no race conditions possible.

A hybrid approach uses message passing for coordination but passes artifact IDs instead of large payloads — agents fetch the artifact directly from storage when needed.

Concept 4 of 5

Analogy

Whiteboard vs. Envelopes
Before

Five colleagues share a single whiteboard. Anyone can erase and rewrite any part at any time. The board shows the "current state" of the project.

Pain

Two people reach for the same section simultaneously. One overwrites the other's update. The next reader gets a corrupted half-written state. Debugging requires figuring out whose version was correct.

Mapping

Message passing is sealed envelopes. Each person keeps their own notes private and only shares finished results by handing over a sealed envelope. No one can modify your notes in-flight. The coordinator receives completed outputs, never mid-write state.

Concept 4 of 5

How It Works

  1. 1
    Shared state: concurrent write risk
    Two agents both update state["draft"] — the second write silently overwrites the first. Lost work, no error raised.
  2. 2
    Message passing: explicit and auditable
    Each agent returns its result to the coordinator. The coordinator owns state updates — only one writer at a time.
  3. 3
    Hybrid: artifact IDs
    Pass artifact_id (e.g. a storage URL) in the message instead of the full payload. Agents fetch when needed — avoids huge message sizes.
Shared State vs Message Passing
Shared DB
Agent A
+
Agent B
→ race condition
Agent A
Coordinator
Agent B
✓ safe
Concept 4 of 5

Pseudocode

# BAD: shared state — race condition
PARALLEL:
  agent_a: state["draft"] = result_a  # write 1
  agent_b: state["draft"] = result_b  # write 2 overwrites!

# GOOD: message passing
FUNCTION coordinator_run(task):
  results = PARALLEL_DISPATCH([
    agent_a, agent_b, agent_c
  ], task)
  # Coordinator owns state — one writer
  state["outputs"] = merge(results)
  RETURN state

# HYBRID: artifact IDs for large payloads
FUNCTION dispatch_with_artifact(agent, data):
  artifact_id = store(data)  # save to storage
  RETURN send_message(agent, {
    "artifact_id": artifact_id  # pass ID, not payload
  })
Concept 4 of 5

Common Misconceptions

Myth: Shared state is fine because agents take turns

One of the main benefits of multi-agent systems is parallel execution. The moment you run agents in parallel with shared state, you have concurrent write risk. Don't design for sequential shared access and then add parallelism later.

Myth: Message passing is too slow for large payloads

Use the hybrid pattern: store large data in a blob store and pass the artifact ID in the message. The message stays small; the agent fetches data only when it needs it. Best of both worlds.

💡 Key Takeaway

Default to message passing — coordinator owns state, agents return outputs. Use artifact IDs when payloads are large. Shared state + parallelism = race conditions.

Concept 5 of 5

Conflict Resolution

When multiple agents produce contradictory outputs — different diagnoses, different code approaches, different recommendations — you need a strategy to resolve the conflict. Four strategies exist, each with different cost and reliability profiles.

Picking the wrong strategy causes either wasted API calls (voting on a simple question) or unsafe automation (confidence scoring on a high-stakes medical decision). Match the strategy to the stakes.

Concept 5 of 5

Analogy

Expert Panel Disagreement
Before

Three specialists review your medical case and come back with different recommendations. One says surgery, one says medication, one says watchful waiting. You need an answer.

Pain

With no resolution protocol, you freeze. Or worse, you pick the loudest voice. The stakes are high and the disagreement is real — someone needs to own the decision.

Mapping

Arbitration: your GP (supervisor) reviews all three opinions and decides.
Voting: majority rules — medication wins 2:1.
Confidence scoring: the specialist with the highest certainty gets weight.
Escalation: the case goes to a hospital ethics board when stakes exceed a threshold.

Concept 5 of 5

How It Works

  1. 1
    Supervisor arbitration
    Send all conflicting outputs to a supervisor agent for review. Costs one extra Claude call but produces a reasoned decision with context.
  2. 2
    Voting / consensus
    Run 3 agents, majority wins. Best for high-stakes binary decisions. Cost: 3× the agent calls.
  3. 3
    Confidence scoring
    Each agent returns confidence 0.0–1.0 with its output. Highest confidence wins. Cheap but not always well-calibrated — agents can be confidently wrong.
  4. 4
    Human-in-the-loop escalation
    Define programmatic thresholds: if confidence < 0.7 or conflict type is "safety-critical", escalate to human. Never leave escalation to Claude's judgment.
Concept 5 of 5

Pseudocode

FUNCTION resolve_conflict(outputs, context):
  # Strategy 1: safety-critical → human
  IF context.is_safety_critical:
    RETURN escalate_to_human(outputs)

  # Strategy 2: high-stakes → voting
  IF context.stakes == "HIGH":
    votes = run_agents(task, n=3)
    RETURN majority(votes)

  # Strategy 3: low confidence → arbitration
  max_conf = max(o.confidence FOR o IN outputs)
  IF max_conf < 0.7:
    RETURN supervisor_arbitrate(outputs)

  # Strategy 4: confident result → use it
  best = argmax(outputs, key="confidence")
  RETURN best.result
Concept 5 of 5

Common Misconceptions

Myth: Confidence scores are always reliable

LLMs can return confidence: 0.95 for a completely wrong answer. Confidence scores reflect the model's self-assessment, not ground truth. Always pair confidence scoring with a fallback (arbitration or human escalation) for high-stakes decisions.

Myth: Human escalation is a failure mode

Escalation is a feature, not a failure. Define clear programmatic thresholds in code — don't leave it to Claude to decide when to escalate. A well-placed escalation path is what makes an agent system trustworthy in production.

💡 Key Takeaway

Match resolution strategy to stakes: arbitration for nuanced conflicts, voting for high-stakes binaries, confidence scoring for speed, human escalation for safety-critical. Define escalation thresholds in code — not in Claude's judgment.

Quick Quiz

Tap each answer to reveal.

1. Name two signals that tell you to split a task into multiple agents.
Context overflow (task exceeds context window) and parallelism (independent subtasks can run concurrently). Also: multi-domain specialization and failure isolation.
2. Which topology is cert-preferred and why?
Supervisor/Worker (hub-and-spoke). The supervisor owns state, failures surface centrally, and you can assign different models per role — easiest to audit and debug.
3. What is the #1 failure mode in agent handoffs?
Context dropping — critical information exists in the coordinator's context but never gets passed in the handoff message. Each subagent starts blank; it only knows what you explicitly send.
4. Why is shared state dangerous in parallel multi-agent systems?
Race conditions: two agents writing simultaneously overwrite each other's results silently. No error is raised — the last writer wins, and the other's work is lost.
5. When should you use human-in-the-loop escalation vs. confidence scoring?
Use human escalation for safety-critical decisions — confidence scores can be high even when wrong. Confidence scoring is fine for low-stakes routing where speed matters more than correctness guarantees.