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":null}'),t={name:"modules/reference-stack.md"};function l(o,s,p,r,d,h){return e(),n("div",null,[...s[0]||(s[0]=[i(`
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).
┌──────────────────────────────────────────────────────────────────┐
│ 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 │
└──────────────────────────────────────────────────────────────────┘~/mprocs-teams.yamlclaude-lead: Claude Code (primary agent)gemini: Gemini CLI (backup/alternative model)opencode: OpenCode CLI (open-source alternative)qwen: Qwen model (specialist/fast tasks)sidecar: agent-mux IPC proxyagent-mux: Tauri UI processtmux.exe at ~/.cargo/bin/tmuxClaude Code --teammate-mode tmux — Claude's native multi-agent split-pane mode--teammate-mode invocation creates split panes, each running a separate Claude session# 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/# 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/# 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# 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"| Tool | Best For | Est. Cost/Task | Autonomy Level |
|---|---|---|---|
| Claude Code | Complex multi-step tasks | $0.05-$0.30 | High (with hooks) |
| Pi Agent | Custom workflows, safety-critical | $0.02-$0.15 | Very high (extensible) |
| OpenCode | OSS-compatible, budget tasks | $0.01-$0.05 | Medium |
| Gemini | High-volume, simple tasks | $0.002-$0.01 | Low |
| OpenClaw | Scheduled, always-on tasks | $0.01-$0.10 | Autonomous |
Model heterogeneity: Different models for different roles. Claude for complex reasoning, Gemini for fast/cheap tasks, Qwen as specialist.
Tool heterogeneity: Not one agent CLI, but five. Each has different strengths. The stack uses each where it excels.
Defense in depth: psmux isolates sessions. dmux isolates files. damage-control restricts commands. mprocs restarts failed processes.
Observability: agent-mux shows live status. mprocs logs output. Session history enables replay debugging.
No single point of failure: If Claude Code fails, Pi or OpenCode can take over. The mprocs supervisor restarts crashed processes.
This architecture demonstrates every concept taught in Modules 1-7:
| Concept | Where It Appears |
|---|---|
| Agent loop | Every tool follows think→act→observe→repeat |
| Tool design | Each tool provides different tools (read, write, bash, search) |
| Security | damage-control, psmux isolation, dmux isolation |
| Multi-agent | teammate-mode, mprocs launching 5 agents |
| Production | mprocs supervision, cost tracking, worktree isolation |
| Economics | Cascade routing across 5 tools by task type |
| Advanced | agent-mux as meta-agent controlling other agents |