0 XP
L1
?
Lessons
Orchestration Patterns
exercise ⏱ 20m
2/3

Orchestration Patterns

Once you have multiple agents, you need to decide how they communicate and coordinate. The orchestration pattern determines reliability, speed, and complexity.

Hub-and-Spoke (Supervisor)

One supervisor agent delegates work to specialized workers:

┌──────────┐
         │Supervisor │
         └────┬─────┘
        ┌─────┼──────┐
        ▼     ▼      ▼
    ┌──────┐┌──────┐┌──────┐
    │Data  ││Writer││Format│
    │Agent ││Agent ││Agent │
    └──────┘└──────┘└──────┘

The supervisor understands the full task, breaks it into subtasks, assigns each to a worker, collects results, and synthesizes. Workers only talk to the supervisor, never to each other.

Pros: Clear control flow, easy to debug, single point of coordination.

Cons: Supervisor is a bottleneck, can't handle truly parallel work well.

Peer-to-Peer (Message Passing)

Agents communicate directly with each other:

┌──────┐     ┌──────┐
    │Agent A│◄───►│Agent B│
    └──┬───┘     └───┬──┘
       │             │
       └──────┬──────┘
              ▼
         ┌──────┐
         │Agent C│
         └──────┘

Each agent decides when to pass work to another agent. No central coordinator. Like a team of senior engineers who self-organize.

Pros: No bottleneck, truly parallel, natural for equal-status agents.

Cons: Hard to debug, potential infinite loops (agents passing work back and forth), consistency issues.

Hierarchical

Agents can spawn sub-agents. A tree structure:

┌──────────┐
         │  Manager  │
         └────┬─────┘
        ┌─────┴──────┐
        ▼            ▼
    ┌──────┐    ┌──────┐
    │Lead A │    │Lead B │
    └──┬───┘    └──┬───┘
    ┌──┴──┐     ┌──┴──┐
    ▼     ▼     ▼     ▼
  ┌───┐┌───┐ ┌───┐┌───┐
  │W1 ││W2 │ │W3 ││W4 │
  └───┘└───┘ └───┘└───┘

This is how Claude Code's Agent tool works — it spawns sub-agents for specific tasks, each with their own context and tools.

Pros: Scales to complex tasks, natural decomposition, each level manages its own complexity.

Cons: Deep hierarchies are slow, lots of context passing overhead.

Shared State vs Message Passing

Two ways agents share information:

Shared state: All agents read/write to a common store (database, file, shared memory). Simple but requires careful coordination to avoid conflicts.

Message passing: Agents send explicit messages. More structured, but more overhead. Each agent only knows what it's been told.

For most practical systems, shared state (a database or file) is simpler. Your Obsidian vault is shared state — any agent can read and write to it.

Error Handling

What happens when one agent fails?

  • Retry: Try the same agent again (works for transient errors)
  • Fallback: Route to a different agent or a simpler approach
  • Escalate: Pass to a human (the supervisor agent asks for help)
  • Circuit breaker: After N failures, stop trying and report the error

Always design for failure. Agents are unreliable by nature — non-deterministic outputs, tool errors, rate limits. Your orchestration pattern needs to handle this gracefully.

❓ Quiz 1
Claude Code's Agent tool, which spawns sub-agents for specific tasks, is an example of which pattern?
The Agent tool creates child agents that can themselves spawn more agents — a tree structure. The parent delegates, the children execute and report back.
Answer to continue ↓

Review

Time to consolidate what you learned.

🎮 Pattern ↔ Product
Click a left item, then click its match on the right.
Hub-and-Spoke
Peer-to-Peer
Hierarchical
Pipeline
CI/CD: build → test → deploy (fixed stages)
Claude Code's Agent tool (supervisor delegates)
Microservices via message queues
Corporate org: CEO → VPs → Managers → ICs
Complete to continue ↓
🛠 Exercise 1
Design a 3-agent system for automated client weekly reports at Muno Labs. Define: (1) Each agent's role and tools, (2) The orchestration pattern (hub-spoke, peer-to-peer, or hierarchical), (3) How they share state, (4) What happens when the data-gathering agent can't reach PostHog (error handling).
✓ Saved
advance · ? shortcuts 04.02
Claude — Tutor
select text for context
Ask me anything about this lesson.
I can see your quiz answers and decisions.

💡 Select text in the lesson to use it as context.
CONTEXT