87 lines
42 KiB
JavaScript
87 lines
42 KiB
JavaScript
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":1780488246000}'),t={name:"modules/m4-orchestration.md"};function l(r,s,o,p,h,d){return a(),i("div",null,[...s[0]||(s[0]=[n(`<h1 id="module-4-multi-agent-orchestration" tabindex="-1">Module 4: Multi-Agent Orchestration <a class="header-anchor" href="#module-4-multi-agent-orchestration" aria-label="Permalink to "Module 4: Multi-Agent Orchestration""></a></h1><h2 id="lesson-4-1-why-one-agent-is-not-enough" tabindex="-1">Lesson 4.1: Why One Agent Is Not Enough <a class="header-anchor" href="#lesson-4-1-why-one-agent-is-not-enough" aria-label="Permalink to "Lesson 4.1: Why One Agent Is Not Enough""></a></h2><p>A single agent, no matter how smart, hits three ceilings:</p><ol><li><p><strong>Context ceiling</strong> — One agent doing everything means one context window holding everything. File contents, database schemas, business logic, deployment configs — it all competes for space.</p></li><li><p><strong>Capability ceiling</strong> — A generalist agent is mediocre at everything. A specialized agent (backend dev, security reviewer, UI designer) outperforms the generalist at its domain.</p></li><li><p><strong>Reliability ceiling</strong> — One agent failing = everything fails. Multi-agent systems degrade gracefully — one team's failure doesn't take down the whole system.</p></li></ol><h3 id="the-stacking-insight" tabindex="-1">The Stacking Insight <a class="header-anchor" href="#the-stacking-insight" aria-label="Permalink to "The Stacking Insight""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Single smart model < Two specialized agents < Orchestrator + 3 teams</span></span></code></pre></div><p>Benchmarks measure single models. Production wins with multi-agent orchestration.</p><hr><h2 id="lesson-4-2-orchestration-patterns" tabindex="-1">Lesson 4.2: Orchestration Patterns <a class="header-anchor" href="#lesson-4-2-orchestration-patterns" aria-label="Permalink to "Lesson 4.2: Orchestration Patterns""></a></h2><h3 id="pattern-1-dispatcher-hub-and-spoke" tabindex="-1">Pattern 1: Dispatcher (Hub-and-Spoke) <a class="header-anchor" href="#pattern-1-dispatcher-hub-and-spoke" aria-label="Permalink to "Pattern 1: Dispatcher (Hub-and-Spoke)""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>User → Orchestrator → dispatches to:</span></span>
|
||
<span class="line"><span> ├── Specialist A (parallel)</span></span>
|
||
<span class="line"><span> ├── Specialist B (parallel)</span></span>
|
||
<span class="line"><span> └── Specialist C (parallel)</span></span>
|
||
<span class="line"><span> ← synthesizes results</span></span></code></pre></div><p><strong>Best for</strong>: Tasks that need multiple perspectives or parallel work. The orchestrator doesn't work — it delegates, then synthesizes.</p><p><strong>Implementation</strong>: <code>agent-team</code> extension. Teams defined in <code>teams.yaml</code>. Orchestrator uses <code>dispatch_agent</code> tool.</p><h3 id="pattern-2-pipeline-sequential" tabindex="-1">Pattern 2: Pipeline (Sequential) <a class="header-anchor" href="#pattern-2-pipeline-sequential" aria-label="Permalink to "Pattern 2: Pipeline (Sequential)""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Step 1: Planner → Step 2: Builder (gets $INPUT=plan) → Step 3: Reviewer (gets $INPUT=code)</span></span></code></pre></div><p><strong>Best for</strong>: Workflows with clear stages where each depends on the previous.</p><p><strong>Implementation</strong>: <code>agent-chain</code> extension. Pipelines in <code>agent-chain.yaml</code>. <code>$INPUT</code> carries forward, <code>$ORIGINAL</code> preserves user prompt.</p><h3 id="pattern-3-peer-to-peer-flat" tabindex="-1">Pattern 3: Peer-to-Peer (Flat) <a class="header-anchor" href="#pattern-3-peer-to-peer-flat" aria-label="Permalink to "Pattern 3: Peer-to-Peer (Flat)""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Agent A ←→ Agent B ←→ Agent C</span></span>
|
||
<span class="line"><span> (no orchestrator, all peers)</span></span></code></pre></div><p><strong>Best for</strong>: Cross-device work, heterogeneous model teams, flat information flow.</p><p><strong>Implementation</strong>: <code>coms</code> / <code>coms-net</code> extensions. 4 tools: list, send, get, await.</p><hr><h2 id="lesson-4-2b-p-threads-—-parallel-agent-execution" tabindex="-1">Lesson 4.2b: P-Threads — Parallel Agent Execution <a class="header-anchor" href="#lesson-4-2b-p-threads-—-parallel-agent-execution" aria-label="Permalink to "Lesson 4.2b: P-Threads — Parallel Agent Execution""></a></h2><p><strong>Concept</strong>: Run N agents simultaneously on the same task. Each agent works independently. Pick the best result.</p><h3 id="pattern" tabindex="-1">Pattern <a class="header-anchor" href="#pattern" aria-label="Permalink to "Pattern""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>User prompt</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> ├── Agent 1 (Claude Opus) ──► output_1</span></span>
|
||
<span class="line"><span> ├── Agent 2 (Gemini Pro) ──► output_2</span></span>
|
||
<span class="line"><span> ├── Agent 3 (DeepSeek V3) ──► output_3</span></span>
|
||
<span class="line"><span> └── Agent 4 (Qwen) ──► output_4</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> ▼</span></span>
|
||
<span class="line"><span> Judge (or human) picks best</span></span></code></pre></div><h3 id="when-to-use-p-threads" tabindex="-1">When to Use P-Threads <a class="header-anchor" href="#when-to-use-p-threads" aria-label="Permalink to "When to Use P-Threads""></a></h3><ul><li>Creative work (UI generation, content writing, architecture design)</li><li>Benchmarking (compare models side-by-side on same task)</li><li>High-stakes decisions (multiple perspectives reduce blind spots)</li><li>Exploration (try N approaches, pick the winner)</li></ul><h3 id="implementation-with-mprocs" tabindex="-1">Implementation with mprocs <a class="header-anchor" href="#implementation-with-mprocs" aria-label="Permalink to "Implementation with mprocs""></a></h3><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># mprocs-teams.yaml</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">procs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> claude-lead</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> cmd</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"claude"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"-p"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"{{PROMPT}}"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> gemini</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> cmd</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"gemini"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"-p"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"{{PROMPT}}"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> opencode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> cmd</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"opencode"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"--model"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"opencode-go/deepseek-v4-flash"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"-p"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"{{PROMPT}}"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span></code></pre></div><p>Run all three simultaneously, collect outputs, pick best.</p><h3 id="implementation-with-agent-mux" tabindex="-1">Implementation with agent-mux <a class="header-anchor" href="#implementation-with-agent-mux" aria-label="Permalink to "Implementation with agent-mux""></a></h3><p>Your Tauri UI (<code>agent-mux</code>) is a P-thread controller: it spawns agents into panes, monitors progress, and presents results for comparison.</p><h3 id="key-design-rules" tabindex="-1">Key Design Rules <a class="header-anchor" href="#key-design-rules" aria-label="Permalink to "Key Design Rules""></a></h3><ul><li>Each agent gets the <strong>same prompt</strong> (fair comparison)</li><li>Agents are <strong>isolated</strong> (no cross-contamination)</li><li>Results are <strong>collected and compared</strong> by a judge or human</li><li>Cost = N × single-agent cost (budget accordingly)</li></ul><hr><h2 id="lesson-4-2c-f-threads-—-fusion-n-agents-one-winner" tabindex="-1">Lesson 4.2c: F-Threads — Fusion (N Agents, One Winner) <a class="header-anchor" href="#lesson-4-2c-f-threads-—-fusion-n-agents-one-winner" aria-label="Permalink to "Lesson 4.2c: F-Threads — Fusion (N Agents, One Winner)""></a></h2><p><strong>Concept</strong>: N agents produce outputs. A synthetic judge (or rubric) selects the winner. More sophisticated than P-threads — includes evaluation.</p><h3 id="pattern-1" tabindex="-1">Pattern <a class="header-anchor" href="#pattern-1" aria-label="Permalink to "Pattern""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Agent 1 ──► Output 1 ──┐</span></span>
|
||
<span class="line"><span>Agent 2 ──► Output 2 ──┤</span></span>
|
||
<span class="line"><span>Agent 3 ──► Output 3 ──┤──► Judge → Winner</span></span>
|
||
<span class="line"><span>Agent 4 ──► Output 4 ──┤</span></span>
|
||
<span class="line"><span>Agent 5 ──► Output 5 ──┘</span></span></code></pre></div><h3 id="when-to-use-f-threads" tabindex="-1">When to Use F-Threads <a class="header-anchor" href="#when-to-use-f-threads" aria-label="Permalink to "When to Use F-Threads""></a></h3><ul><li>Code generation (generate N variants, pick best compiled/tested)</li><li>UI generation (your UI Agents system uses this — 3 Vue generators, 1 winner)</li><li>Architecture decisions (N proposals, judge evaluates against criteria)</li><li>Bug fixes (N approaches, pick the one that passes tests)</li></ul><h3 id="your-ui-agents-system-as-f-thread-example" tabindex="-1">Your UI Agents System as F-Thread Example <a class="header-anchor" href="#your-ui-agents-system-as-f-thread-example" aria-label="Permalink to "Your UI Agents System as F-Thread Example""></a></h3><p>Your <code>ui-agents</code> project uses F-threads natively:</p><ul><li>3 UI Generation agents (Sonnet + open source variants)</li><li>Validation team screenshots + checks each</li><li>Lead picks the best result</li><li>Loser outputs are discarded (or logged for learning)</li></ul><h3 id="judge-criteria-template" tabindex="-1">Judge Criteria Template <a class="header-anchor" href="#judge-criteria-template" aria-label="Permalink to "Judge Criteria Template""></a></h3><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "criteria"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"correctness"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"weight"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">},</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"efficiency"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"weight"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">},</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"maintainability"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"weight"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">},</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"completeness"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"weight"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ]</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><hr><h2 id="lesson-4-3-depth-2-delegation" tabindex="-1">Lesson 4.3: Depth-2 Delegation <a class="header-anchor" href="#lesson-4-3-depth-2-delegation" aria-label="Permalink to "Lesson 4.3: Depth-2 Delegation""></a></h2><p>The production-proven hierarchy from lead-agents and ui-agents:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>User</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> v</span></span>
|
||
<span class="line"><span>Orchestrator (Opus-level, thinking only)</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> ├── Planning Team Lead (synthesizes, delegates)</span></span>
|
||
<span class="line"><span> │ ├── Product Manager (domain worker)</span></span>
|
||
<span class="line"><span> │ └── UX Researcher (domain worker)</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> ├── Engineering Team Lead (synthesizes, delegates)</span></span>
|
||
<span class="line"><span> │ ├── Frontend Dev (domain worker)</span></span>
|
||
<span class="line"><span> │ └── Backend Dev (domain worker)</span></span>
|
||
<span class="line"><span> │</span></span>
|
||
<span class="line"><span> └── Validation Team Lead (synthesizes, delegates)</span></span>
|
||
<span class="line"><span> ├── QA Engineer (domain worker)</span></span>
|
||
<span class="line"><span> └── Security Reviewer (domain worker)</span></span></code></pre></div><h3 id="the-rule" tabindex="-1">The Rule <a class="header-anchor" href="#the-rule" aria-label="Permalink to "The Rule""></a></h3><p><strong>Leads and orchestrators are thinkers, planners, and managers. They are not doers.</strong> They delegate to workers who write files and make changes. Workers don't make strategic decisions.</p><hr><h2 id="lesson-4-4-agent-experts-that-remember" tabindex="-1">Lesson 4.4: Agent Experts That Remember <a class="header-anchor" href="#lesson-4-4-agent-experts-that-remember" aria-label="Permalink to "Lesson 4.4: Agent Experts That Remember""></a></h2><h3 id="mental-models" tabindex="-1">Mental Models <a class="header-anchor" href="#mental-models" aria-label="Permalink to "Mental Models""></a></h3><p>Every agent maintains its own expertise file:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># engineering-lead-mental-model.yaml</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">observations</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">architectural_pattern</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> observation</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"We use vertical slice architecture for new features"</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> evidence</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"PR #142, PR #156"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">common_failure</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> observation</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"WebSocket reconnection logic needs retry with backoff"</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> evidence</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Incident log 2026-03-15"</span></span></code></pre></div><h3 id="self-improve-commands" tabindex="-1">Self-Improve Commands <a class="header-anchor" href="#self-improve-commands" aria-label="Permalink to "Self-Improve Commands""></a></h3><p>Agents periodically run self-improve commands that:</p><ol><li>Read the mental model</li><li>Compare against actual codebase (grep, read files)</li><li>Update stale entries</li><li>Add new findings</li></ol><h3 id="compounding-knowledge" tabindex="-1">Compounding Knowledge <a class="header-anchor" href="#compounding-knowledge" aria-label="Permalink to "Compounding Knowledge""></a></h3><p>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</p><hr><h2 id="lesson-4-5-domain-locking" tabindex="-1">Lesson 4.5: Domain Locking <a class="header-anchor" href="#lesson-4-5-domain-locking" aria-label="Permalink to "Lesson 4.5: Domain Locking""></a></h2><p>Every agent has explicit domain permissions:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Engineering Lead domain</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">domain</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.pi/multi-team/</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> read</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> upsert</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> delete</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">src/</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> read</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> upsert</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> delete</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">.</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> read</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> upsert</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> delete</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Can't delete anything at root</span></span></code></pre></div><p>Three levels:</p><ul><li><code>read: false</code> — can't even see the files</li><li><code>upsert: false</code> — can read, can't write</li><li><code>delete: false</code> — can read+write, can't delete</li></ul><hr><h2 id="lesson-4-6-tilldone-task-discipline" tabindex="-1">Lesson 4.6: TillDone Task Discipline <a class="header-anchor" href="#lesson-4-6-tilldone-task-discipline" aria-label="Permalink to "Lesson 4.6: TillDone Task Discipline""></a></h2><h3 id="the-pattern" tabindex="-1">The Pattern <a class="header-anchor" href="#the-pattern" aria-label="Permalink to "The Pattern""></a></h3><ol><li>Orchestrator creates task list before delegating</li><li>Tasks are assigned to specific agents</li><li>Agents mark tasks in progress → done</li><li>Footer shows live progress</li><li>If turn ends with incomplete tasks, agent is nudged to continue</li></ol><h3 id="why-it-matters" tabindex="-1">Why It Matters <a class="header-anchor" href="#why-it-matters" aria-label="Permalink to "Why It Matters""></a></h3><p>Prevents 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.</p><hr><h2 id="lesson-4-7-agent-chains" tabindex="-1">Lesson 4.7: Agent Chains <a class="header-anchor" href="#lesson-4-7-agent-chains" aria-label="Permalink to "Lesson 4.7: Agent Chains""></a></h2><h3 id="yaml-defined-pipelines" tabindex="-1">YAML-Defined Pipelines <a class="header-anchor" href="#yaml-defined-pipelines" aria-label="Permalink to "YAML-Defined Pipelines""></a></h3><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># agent-chain.yaml</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">steps</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">agent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">planner</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> prompt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Create a detailed plan for: $INPUT"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">agent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">builder</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> prompt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Implement the following plan: $INPUT"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">agent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">reviewer</span></span>
|
||
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> prompt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Review this code: $INPUT"</span></span></code></pre></div><h3 id="variables" tabindex="-1">Variables <a class="header-anchor" href="#variables" aria-label="Permalink to "Variables""></a></h3><ul><li><code>$INPUT</code> — Output of the previous step</li><li><code>$ORIGINAL</code> — The user's original prompt (always accessible)</li></ul><hr><h2 id="lesson-4-8-pi-to-pi-communication" tabindex="-1">Lesson 4.8: Pi-to-Pi Communication <a class="header-anchor" href="#lesson-4-8-pi-to-pi-communication" aria-label="Permalink to "Lesson 4.8: Pi-to-Pi Communication""></a></h2><h3 id="the-shift-hierarchy-→-flat" tabindex="-1">The Shift: Hierarchy → Flat <a class="header-anchor" href="#the-shift-hierarchy-→-flat" aria-label="Permalink to "The Shift: Hierarchy → Flat""></a></h3><p>Traditional agent communication is top-down:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Orchestrator → Team Lead → Worker → (result goes back up)</span></span></code></pre></div><p>Peer-to-peer flips this. Agents are equals:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Agent A ←→ Agent B</span></span>
|
||
<span class="line"><span> ↕ ↕</span></span>
|
||
<span class="line"><span>Agent C ←→ Agent D</span></span></code></pre></div><h3 id="reference-implementation-mcp-agent-mail-jeff-emanuel-1-955★" tabindex="-1">Reference Implementation: MCP Agent Mail (Jeff Emanuel, 1,955★) <a class="header-anchor" href="#reference-implementation-mcp-agent-mail-jeff-emanuel-1-955★" aria-label="Permalink to "Reference Implementation: MCP Agent Mail (Jeff Emanuel, 1,955★)""></a></h3><p>Jeff's MCP Agent Mail provides a more formal coordination layer:</p><ul><li><strong>Agent identities</strong>: Each agent has a registered identity</li><li><strong>Inboxes</strong>: Messages are delivered to agent inboxes</li><li><strong>Searchable threads</strong>: Full thread history with search</li><li><strong>Advisory file leases</strong>: Agents can reserve files to prevent conflicts</li></ul><p>This complements our simpler P2P approach. Use direct coms for speed, MCP Agent Mail for audit trails.</p><h3 id="four-tools" tabindex="-1">Four Tools <a class="header-anchor" href="#four-tools" aria-label="Permalink to "Four Tools""></a></h3><table tabindex="0"><thead><tr><th>Tool</th><th>What It Does</th></tr></thead><tbody><tr><td><code>*_list</code></td><td>List peer agents (name, model, context usage)</td></tr><tr><td><code>*_send</code></td><td>Send a prompt; returns msg_id</td></tr><tr><td><code>*_get</code></td><td>Non-blocking poll on msg_id</td></tr><tr><td><code>*_await</code></td><td>Block until reply or timeout</td></tr></tbody></table><h3 id="safety" tabindex="-1">Safety <a class="header-anchor" href="#safety" aria-label="Permalink to "Safety""></a></h3><ul><li>Max 5 hops (prevents A→B→A→B loops)</li><li>Audit log (msg_id, sender, hops — never prompt bodies)</li><li>Self-healing (stale sockets pruned, heartbeats every 10s)</li></ul><hr><h2 id="lesson-4-9-conversation-awareness" tabindex="-1">Lesson 4.9: Conversation Awareness <a class="header-anchor" href="#lesson-4-9-conversation-awareness" aria-label="Permalink to "Lesson 4.9: Conversation Awareness""></a></h2><p>Every agent reads a shared JSONL conversation log before responding:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>.pi/multi-team/sessions/<session-id>/conversation.jsonl</span></span></code></pre></div><p>This means:</p><ul><li>Agents know what's already been discussed</li><li>Agents don't repeat work</li><li>Full audit trail of every interaction</li></ul><h2 id="lesson-4-9b-service-connectors" tabindex="-1">Lesson 4.9b: Service Connectors <a class="header-anchor" href="#lesson-4-9b-service-connectors" aria-label="Permalink to "Lesson 4.9b: Service Connectors""></a></h2><p>Agents need to interact with external services: Twitter, GitHub, Linear, Slack, email.</p><h3 id="the-pattern-1" tabindex="-1">The Pattern <a class="header-anchor" href="#the-pattern-1" aria-label="Permalink to "The Pattern""></a></h3><p>Each service gets an MCP connector:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Agent → MCP Client → Service Connector → External API</span></span>
|
||
<span class="line"><span> ├── twitter-connector: post, search, DM, timeline</span></span>
|
||
<span class="line"><span> ├── github-connector: PRs, issues, actions, code search</span></span>
|
||
<span class="line"><span> ├── linear-connector: issues, comments, projects, cycles</span></span>
|
||
<span class="line"><span> ├── slack-connector: messages, channels, threads, search</span></span>
|
||
<span class="line"><span> ├── email-connector: send, read, search, folders</span></span>
|
||
<span class="line"><span> └── custom: build your own via connector SDK</span></span></code></pre></div><h3 id="design-rules" tabindex="-1">Design Rules <a class="header-anchor" href="#design-rules" aria-label="Permalink to "Design Rules""></a></h3><ol><li><strong>One connector per service</strong> — composable, not monolithic</li><li><strong>MCP protocol</strong> — standard interface for all connectors</li><li><strong>Scoped credentials</strong> — each connector has its own auth (no shared tokens)</li><li><strong>Rate-limited</strong> — connectors enforce service rate limits</li><li><strong>Audit-logged</strong> — every external action is logged</li></ol><h3 id="reference-implementation" tabindex="-1">Reference Implementation <a class="header-anchor" href="#reference-implementation" aria-label="Permalink to "Reference Implementation""></a></h3><p>Jeff Emanuel's <code>flywheel_connectors</code> (79★) provides a mesh-native protocol for this. His approach:</p><ul><li>Each connector is a standalone Rust binary</li><li>Connectors communicate via a shared mesh protocol</li><li>Agents discover connectors dynamically</li><li>Built-in connectors for Twitter, Linear, GitHub</li></ul><h3 id="integration-with-agent-teams" tabindex="-1">Integration with Agent Teams <a class="header-anchor" href="#integration-with-agent-teams" aria-label="Permalink to "Integration with Agent Teams""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Orchestrator → delegates to agent</span></span>
|
||
<span class="line"><span> Agent → calls service connector via MCP</span></span>
|
||
<span class="line"><span> Connector → authenticates → calls API → returns result</span></span>
|
||
<span class="line"><span> Agent → processes result → continues work</span></span>
|
||
<span class="line"><span>Orchestrator → synthesizes final output</span></span></code></pre></div><hr><h2 id="lesson-4-10-the-ceo-board-system" tabindex="-1">Lesson 4.10: The CEO Board System <a class="header-anchor" href="#lesson-4-10-the-ceo-board-system" aria-label="Permalink to "Lesson 4.10: The CEO Board System""></a></h2><p>8 specialist agents for strategic decision-making:</p><table tabindex="0"><thead><tr><th>Board Member</th><th>Focus</th><th>Time Horizon</th></tr></thead><tbody><tr><td>Revenue</td><td>Cash flow, short-term wins</td><td>30-90 days</td></tr><tr><td>Compounder</td><td>Trust, long-term value</td><td>6-24 months</td></tr><tr><td>Contrarian</td><td>Assumptions, blind spots</td><td>3x weight on dissent</td></tr><tr><td>Technical Architect</td><td>System durability</td><td>Ongoing</td></tr><tr><td>Product Strategist</td><td>Problem selection</td><td>Quarterly</td></tr><tr><td>Customer Oracle</td><td>User behavior</td><td>Ongoing</td></tr><tr><td>Market Strategist</td><td>Positioning</td><td>Quarterly</td></tr><tr><td>Moonshot</td><td>Asymmetric upside</td><td>1-5 years</td></tr></tbody></table><h3 id="flow" tabindex="-1">Flow <a class="header-anchor" href="#flow" aria-label="Permalink to "Flow""></a></h3><ol><li>CEO frames the decision</li><li>Board debates (sources required, no "I think")</li><li>Verifier checks facts (2+ sources per claim)</li><li>Executor creates execution plan</li><li>Tracker logs for quarterly review</li></ol><hr><h2 id="lesson-4-11-ui-agents-system" tabindex="-1">Lesson 4.11: UI Agents System <a class="header-anchor" href="#lesson-4-11-ui-agents-system" aria-label="Permalink to "Lesson 4.11: UI Agents System""></a></h2><p>12 agents across 4 teams for brand-consistent UI generation:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Brand → Product → Tree → Branch → Leaf</span></span></code></pre></div><p>Each level has its own <code>brand.yaml</code> with CSS custom properties. Zero hardcoded values. Agents generate Vue components that use only CSS custom properties from the brand config.</p><h2 id="lab-4-12-build-an-agent-chain" tabindex="-1">Lab 4.12: Build an Agent Chain <a class="header-anchor" href="#lab-4-12-build-an-agent-chain" aria-label="Permalink to "Lab 4.12: Build an Agent Chain""></a></h2><p><strong>Objective</strong>: Create a plan→build→review pipeline in YAML.</p><p><strong>Starter</strong>: <code>course/labs/L4-agent-chain/starter.yaml</code><strong>Solution</strong>: <code>course/labs/L4-agent-chain/solution.yaml</code></p><p><strong>Checkpoints</strong>:</p><ol><li>Planner produces structured plan with tasks and file paths</li><li>Builder creates code matching the plan</li><li>Reviewer identifies issues with severity (critical/major/minor)</li><li>Verifier confirms each claim with file:line evidence</li></ol><h2 id="lab-4-13-deploy-a-multi-team-system" tabindex="-1">Lab 4.13: Deploy a Multi-Team System <a class="header-anchor" href="#lab-4-13-deploy-a-multi-team-system" aria-label="Permalink to "Lab 4.13: Deploy a Multi-Team System""></a></h2><p><strong>Objective</strong>: Set up orchestrator + 2 teams with domain locking.</p><p><strong>Starter</strong>: <code>course/labs/L4-multi-team/starter-config.yaml</code><strong>Solution</strong>: <code>course/labs/L4-multi-team/solution-config.yaml</code></p><p><strong>Checkpoints</strong>:</p><ol><li>Orchestrator delegates, never executes</li><li>Each team has lead + members with distinct roles</li><li>Domain permissions restrict each agent to its scope</li><li>Mental model files exist for each agent</li></ol>`,135)])])}const g=e(t,[["render",l]]);export{k as __pageData,g as default};
|