import{c as e,Q as a,j as i,m as n}from"./chunks/framework.BPKcPtvA.js";const k=JSON.parse('{"title":"Module 4: Multi-Agent Orchestration","description":"","frontmatter":{},"headers":[],"relativePath":"modules/m4-orchestration.md","filePath":"modules/m4-orchestration.md","lastUpdated":null}'),t={name:"modules/m4-orchestration.md"};function l(r,s,o,p,h,d){return a(),i("div",null,[...s[0]||(s[0]=[n(`
A single agent, no matter how smart, hits three ceilings:
Context ceiling — One agent doing everything means one context window holding everything. File contents, database schemas, business logic, deployment configs — it all competes for space.
Capability ceiling — A generalist agent is mediocre at everything. A specialized agent (backend dev, security reviewer, UI designer) outperforms the generalist at its domain.
Reliability ceiling — One agent failing = everything fails. Multi-agent systems degrade gracefully — one team's failure doesn't take down the whole system.
Single smart model < Two specialized agents < Orchestrator + 3 teamsBenchmarks measure single models. Production wins with multi-agent orchestration.
User → Orchestrator → dispatches to:
├── Specialist A (parallel)
├── Specialist B (parallel)
└── Specialist C (parallel)
← synthesizes resultsBest for: Tasks that need multiple perspectives or parallel work. The orchestrator doesn't work — it delegates, then synthesizes.
Implementation: agent-team extension. Teams defined in teams.yaml. Orchestrator uses dispatch_agent tool.
Step 1: Planner → Step 2: Builder (gets $INPUT=plan) → Step 3: Reviewer (gets $INPUT=code)Best for: Workflows with clear stages where each depends on the previous.
Implementation: agent-chain extension. Pipelines in agent-chain.yaml. $INPUT carries forward, $ORIGINAL preserves user prompt.
Agent A ←→ Agent B ←→ Agent C
(no orchestrator, all peers)Best for: Cross-device work, heterogeneous model teams, flat information flow.
Implementation: coms / coms-net extensions. 4 tools: list, send, get, await.
Concept: Run N agents simultaneously on the same task. Each agent works independently. Pick the best result.
User prompt
│
├── Agent 1 (Claude Opus) ──► output_1
├── Agent 2 (Gemini Pro) ──► output_2
├── Agent 3 (DeepSeek V3) ──► output_3
└── Agent 4 (Qwen) ──► output_4
│
▼
Judge (or human) picks best# mprocs-teams.yaml
procs:
claude-lead:
cmd: ["claude", "-p", "{{PROMPT}}"]
gemini:
cmd: ["gemini", "-p", "{{PROMPT}}"]
opencode:
cmd: ["opencode", "--model", "opencode-go/deepseek-v4-flash", "-p", "{{PROMPT}}"]Run all three simultaneously, collect outputs, pick best.
Your Tauri UI (agent-mux) is a P-thread controller: it spawns agents into panes, monitors progress, and presents results for comparison.
Concept: N agents produce outputs. A synthetic judge (or rubric) selects the winner. More sophisticated than P-threads — includes evaluation.
Agent 1 ──► Output 1 ──┐
Agent 2 ──► Output 2 ──┤
Agent 3 ──► Output 3 ──┤──► Judge → Winner
Agent 4 ──► Output 4 ──┤
Agent 5 ──► Output 5 ──┘Your ui-agents project uses F-threads natively:
{
"criteria": [
{"name": "correctness", "weight": 0.4},
{"name": "efficiency", "weight": 0.2},
{"name": "maintainability", "weight": 0.2},
{"name": "completeness", "weight": 0.2}
]
}The production-proven hierarchy from lead-agents and ui-agents:
User
│
v
Orchestrator (Opus-level, thinking only)
│
├── Planning Team Lead (synthesizes, delegates)
│ ├── Product Manager (domain worker)
│ └── UX Researcher (domain worker)
│
├── Engineering Team Lead (synthesizes, delegates)
│ ├── Frontend Dev (domain worker)
│ └── Backend Dev (domain worker)
│
└── Validation Team Lead (synthesizes, delegates)
├── QA Engineer (domain worker)
└── Security Reviewer (domain worker)Leads and orchestrators are thinkers, planners, and managers. They are not doers. They delegate to workers who write files and make changes. Workers don't make strategic decisions.
Every agent maintains its own expertise file:
# engineering-lead-mental-model.yaml
observations:
- type: architectural_pattern
observation: "We use vertical slice architecture for new features"
evidence: "PR #142, PR #156"
- type: common_failure
observation: "WebSocket reconnection logic needs retry with backoff"
evidence: "Incident log 2026-03-15"Agents periodically run self-improve commands that:
Session 1: Agent learns project structure Session 2: Agent learns common patterns Session 3: Agent learns failure modes Session N: Agent operates at senior engineer level for this codebase
Every agent has explicit domain permissions:
# Engineering Lead domain
domain:
- path: .pi/multi-team/
read: true
upsert: true
delete: false
- path: src/
read: true
upsert: true
delete: false
- path: .
read: true
upsert: false
delete: false # Can't delete anything at rootThree levels:
read: false — can't even see the filesupsert: false — can read, can't writedelete: false — can read+write, can't deletePrevents the #1 multi-agent failure mode: an orchestrator that delegates, gets results, and then wanders off without completing the plan. The task list is the forcing function.
# agent-chain.yaml
steps:
- agent: planner
prompt: "Create a detailed plan for: $INPUT"
- agent: builder
prompt: "Implement the following plan: $INPUT"
- agent: reviewer
prompt: "Review this code: $INPUT"$INPUT — Output of the previous step$ORIGINAL — The user's original prompt (always accessible)Traditional agent communication is top-down:
Orchestrator → Team Lead → Worker → (result goes back up)Peer-to-peer flips this. Agents are equals:
Agent A ←→ Agent B
↕ ↕
Agent C ←→ Agent DJeff's MCP Agent Mail provides a more formal coordination layer:
This complements our simpler P2P approach. Use direct coms for speed, MCP Agent Mail for audit trails.
| Tool | What It Does |
|---|---|
*_list | List peer agents (name, model, context usage) |
*_send | Send a prompt; returns msg_id |
*_get | Non-blocking poll on msg_id |
*_await | Block until reply or timeout |
Every agent reads a shared JSONL conversation log before responding:
.pi/multi-team/sessions/<session-id>/conversation.jsonlThis means:
Agents need to interact with external services: Twitter, GitHub, Linear, Slack, email.
Each service gets an MCP connector:
Agent → MCP Client → Service Connector → External API
├── twitter-connector: post, search, DM, timeline
├── github-connector: PRs, issues, actions, code search
├── linear-connector: issues, comments, projects, cycles
├── slack-connector: messages, channels, threads, search
├── email-connector: send, read, search, folders
└── custom: build your own via connector SDKJeff Emanuel's flywheel_connectors (79★) provides a mesh-native protocol for this. His approach:
Orchestrator → delegates to agent
Agent → calls service connector via MCP
Connector → authenticates → calls API → returns result
Agent → processes result → continues work
Orchestrator → synthesizes final output8 specialist agents for strategic decision-making:
| Board Member | Focus | Time Horizon |
|---|---|---|
| Revenue | Cash flow, short-term wins | 30-90 days |
| Compounder | Trust, long-term value | 6-24 months |
| Contrarian | Assumptions, blind spots | 3x weight on dissent |
| Technical Architect | System durability | Ongoing |
| Product Strategist | Problem selection | Quarterly |
| Customer Oracle | User behavior | Ongoing |
| Market Strategist | Positioning | Quarterly |
| Moonshot | Asymmetric upside | 1-5 years |
12 agents across 4 teams for brand-consistent UI generation:
Brand → Product → Tree → Branch → LeafEach level has its own brand.yaml with CSS custom properties. Zero hardcoded values. Agents generate Vue components that use only CSS custom properties from the brand config.
Objective: Create a plan→build→review pipeline in YAML.
Starter: course/labs/L4-agent-chain/starter.yamlSolution: course/labs/L4-agent-chain/solution.yaml
Checkpoints:
Objective: Set up orchestrator + 2 teams with domain locking.
Starter: course/labs/L4-multi-team/starter-config.yamlSolution: course/labs/L4-multi-team/solution-config.yaml
Checkpoints: