import{c as a,Q as e,j as n,m as i}from"./chunks/framework.BPKcPtvA.js";const k=JSON.parse('{"title":"Reference Architecture: Production Multi-Agent Stack","description":"","frontmatter":{},"headers":[],"relativePath":"modules/reference-stack.md","filePath":"modules/reference-stack.md","lastUpdated":1780488246000}'),t={name:"modules/reference-stack.md"};function l(o,s,p,r,d,h){return e(),n("div",null,[...s[0]||(s[0]=[i(`

Reference Architecture: Production Multi-Agent Stack

This document documents a real production multi-agent deployment. Use it as a reference for Module 5 (Production Patterns) and Module 4 (Multi-Agent Orchestration).

Architecture Overview

┌──────────────────────────────────────────────────────────────────┐
│                    agent-mux (Tauri UI)                           │
│              Meta-agent control plane + dashboard                 │
│         Spawns, monitors, kills agents. Human interface.          │
└─────────────────────────┬────────────────────────────────────────┘
                          │ orchestrates via sidecar

┌──────────────────────────────────────────────────────────────────┐
│                    mprocs (process monitor)                       │
│                    mprocs -c ~/mprocs-teams.yaml                  │
│          Launches and supervises all agent processes              │
├──────────────┬──────────────┬──────────────┬─────────────────────┤
│ claude-lead  │   gemini     │   opencode   │  sidecar            │
│ (primary)    │  (backup)    │  (OSS alt)   │  (agent-mux proxy)  │
└──────────────┴──────────────┴──────────────┴─────────────────────┘
                          │ each agent runs inside

┌──────────────────────────────────────────────────────────────────┐
│                    psmux (tmux session manager)                   │
│              tmux.exe at ~/.cargo/bin/tmux                        │
│          Claude Code --teammate-mode tmux                         │
├─────────┬─────────┬─────────┬─────────┬─────────┬───────────────┤
│  pane 1 │  pane 2 │  pane 3 │  pane 4 │  pane 5 │  ...          │
│  (lead) │ (worker)│(review) │(verify) │ (sidecar)│               │
└─────────┴─────────┴─────────┴─────────┴─────────┴───────────────┘
                          │ each task isolated by

┌──────────────────────────────────────────────────────────────────┐
│                    dmux (git worktree isolation)                  │
│           Each agent task gets its own isolated worktree          │
│         dmux runs inside a tmux session with agent-teams          │
└──────────────────────────────────────────────────────────────────┘

Layer-by-Layer Breakdown

Layer 1: Meta-Control Plane (agent-mux)

Layer 2: Process Orchestrator (mprocs)

Layer 3: Session Management (psmux)

Layer 4: Work Isolation (dmux)

Tool-Specific Configurations

Claude Code

bash
# Launch with teammate mode (multi-agent)
claude --teammate-mode tmux

# Headless mode (for CI/CD)
claude -p "prompt" --allowedTools "Read Write Edit Bash" --print

# With custom hooks
claude --hooks .claude/hooks/

Pi Coding Agent

bash
# Launch with extensions
pi -e extensions/damage-control.ts \\
   -e extensions/tilldone.ts \\
   -e extensions/minimal.ts

# RPC mode (programmatic control)
pi --mode rpc

# With custom skills
pi --skills-dir .pi/skills/

OpenCode

bash
# Using Go model (via proxy)
opencode --model opencode-go/deepseek-v4-flash

# Headless execution
opencode run "prompt"

# With config from shared ~/.grok/config.toml
opencode --config ~/.grok/config.toml

OpenClaw

bash
# Always-on employee mode
claw start --daemon

# One-shot task execution
claw do "task description"

# Heartbeat schedule
claw schedule --cron "0 */6 * * *" --task "daily-report"

Cost Analysis

ToolBest ForEst. Cost/TaskAutonomy Level
Claude CodeComplex multi-step tasks$0.05-$0.30High (with hooks)
Pi AgentCustom workflows, safety-critical$0.02-$0.15Very high (extensible)
OpenCodeOSS-compatible, budget tasks$0.01-$0.05Medium
GeminiHigh-volume, simple tasks$0.002-$0.01Low
OpenClawScheduled, always-on tasks$0.01-$0.10Autonomous

Key Production Patterns

  1. Model heterogeneity: Different models for different roles. Claude for complex reasoning, Gemini for fast/cheap tasks, Qwen as specialist.

  2. Tool heterogeneity: Not one agent CLI, but five. Each has different strengths. The stack uses each where it excels.

  3. Defense in depth: psmux isolates sessions. dmux isolates files. damage-control restricts commands. mprocs restarts failed processes.

  4. Observability: agent-mux shows live status. mprocs logs output. Session history enables replay debugging.

  5. No single point of failure: If Claude Code fails, Pi or OpenCode can take over. The mprocs supervisor restarts crashed processes.

What This Stack Proves

This architecture demonstrates every concept taught in Modules 1-7:

ConceptWhere It Appears
Agent loopEvery tool follows think→act→observe→repeat
Tool designEach tool provides different tools (read, write, bash, search)
Securitydamage-control, psmux isolation, dmux isolation
Multi-agentteammate-mode, mprocs launching 5 agents
Productionmprocs supervision, cost tracking, worktree isolation
EconomicsCascade routing across 5 tools by task type
Advancedagent-mux as meta-agent controlling other agents
`,29)])])}const u=a(t,[["render",l]]);export{k as __pageData,u as default};