Multi-Agent Coordinator
by @michealxie001
Production-ready multi-agent orchestration system for OpenClaw. Implements Coordinator Mode with real parallel worker spawning via sessions_spawn, XML task n...
clawhub install multi-agent๐ About This Skill
name: multi-agent description: Production-ready multi-agent orchestration system for OpenClaw. Implements Coordinator Mode with real parallel worker spawning via sessions_spawn, XML task notifications, state persistence, and four-phase workflow (Research โ Synthesis โ Implementation โ Verification).
Multi-Agent Skill (Phase 2.5 - Production Ready)
็ไบง็บงๅคๆบ่ฝไฝๅ่ฐ็ณป็ป๏ผๆฏๆ็ๅฎ็ๅนถ่ก Worker ๆง่กๅๅฎๆด็ๅ้ถๆฎตๅทฅไฝๆตใ
Quick Start
1. ๅๅค Worker
cd skills/multi-agent
python3 scripts/coordinator_v2.py prepare "Your task description" --role researcher
่ฟไผ็ๆ๏ผ
.openclaw/scratchpad/workers/{id}.json.openclaw/scratchpad/prompts/prompt-{id}.txt2. ๆดพ็ Worker๏ผ็ๅฎๆง่ก๏ผ
# ่ฏปๅ็ๆ็ prompt ๅนถๆดพ็
prompt=$(cat .openclaw/scratchpad/prompts/prompt-{worker-id}.txt)sessions_spawn --label "multi-agent-worker-{worker-id}" \
--task "$prompt" \
--timeout 300 \
--cleanup keep
3. ๅค็ๅฎๆ้็ฅ
ๅฝ Worker ๅฎๆๆถ๏ผๅฎไผ่พๅบ XML ๆ ผๅผ็้็ฅใๆถ้ๅนถๅค็๏ผ
python3 scripts/coordinator_v2.py notify {worker-id} --file notification.xml
4. ็ๆ่งๆ ผๆๆกฃ
# ไปๅทฒๅฎๆ็ Research Workers ็ๆ่งๆ ผ
python3 scripts/coordinator_v2.py spec {worker-id-1} {worker-id-2} {worker-id-3}
5. ่ฟ่กๆผ็คบ
# ๅ้ถๆฎตๅทฅไฝๆตๆผ็คบ๏ผๆจกๆๆง่ก๏ผ
python3 scripts/demo_workflow.py "Your task here"
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ COORDINATOR โ
โ - spawn_worker() : Prepare worker spec and prompt โ
โ - process_notification() : Handle worker completion โ
โ - generate_spec() : Synthesize findings from workers โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ
โ Worker 1โ โ Worker 2โ โ Worker 3โ ... (parallel)
โ(Researchโ โ(Researchโ โ(Researchโ
โ 1) โ โ 2) โ โ 3) โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโ
โ SYNTHESIS โ Coordinator generates spec
โ (generate_spec)โ
โโโโโโโโโโฌโโโโโโโโโ
โผ
โโโโโโโโโโโโโดโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโ
โWorker 4 โ โWorker 5 โ
โ(Impl 1) โ โ(Impl 2) โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโ
โ VERIFICATION โ
โ (Worker 6, 7...)โ
โโโโโโโโโโโโโโโโโโโ
File Structure
skills/multi-agent/
โโโ SKILL.md # ๆฌๆไปถ
โโโ test-report-phase2.5.md # ๆต่ฏๆฅๅ
โโโ scripts/
โ โโโ coordinator_v2.py # โญ ไธปๅ่ฐๅจ๏ผ็ไบง็บง๏ผ
โ โโโ demo_workflow.py # ๅ้ถๆฎตๅทฅไฝๆตๆผ็คบ
โ โโโ coordinator.py # Phase 1: ๆจกๆ็
โ โโโ coordinator_phase2.py # Phase 2: ่ฟๆธก็
โ โโโ worker.py # Worker ๅ่ๅฎ็ฐ
โ โโโ protocol.py # XML ๅ่ฎฎ
โโโ references/
โโโ ARCHITECTURE.md # ๆถๆ่ฎพ่ฎกๆๆกฃ.openclaw/scratchpad/ # ่ฟ่กๆถ็ๆ็ๅ
ฑไบซ็ฅ่ฏ
โโโ workers/ # Worker ็ถๆ
โโโ results/ # Worker ็ปๆ
โโโ specs/ # ่งๆ ผๆๆกฃ
โโโ prompts/ # Worker ๆ็คบ่ฏ
โโโ coordinator_state.json # ๅ่ฐๅจ็ถๆ
XML Protocol
Worker ๅฟ ้กปๆไปฅไธๆ ผๅผ่ฟๅ็ปๆ๏ผ
{worker-id}
completed|failed
One-line summary
Detailed findings, changes made, or test results...
Include specific file paths and code snippets.
Four-Phase Workflow
Phase 1: Research (ๅนถ่กๆข็ดข)
Phase 2: Synthesis (็ปผๅ)
Phase 3: Implementation (ๅฎ็ฐ)
Phase 4: Verification (้ช่ฏ)
Commands
coordinator_v2.py
# ๅๅค Worker๏ผๅๅปบ่งๆ ผๅๆ็คบ่ฏ๏ผ
python3 coordinator_v2.py prepare "Task description" --role researcherๅค็ Worker ๅฎๆ้็ฅ
python3 coordinator_v2.py notify {worker-id} --file notification.xmlๅๅบ Workers
python3 coordinator_v2.py list
python3 coordinator_v2.py list --status completedไป Workers ็ๆ่งๆ ผ
python3 coordinator_v2.py spec {id1} {id2} {id3}
demo_workflow.py
# ่ฟ่กๅฎๆดๆผ็คบ๏ผๆจกๆๆง่ก๏ผ
python3 demo_workflow.py "Your task"ๆฅ็็ๅฎไฝฟ็จ็คบไพ
python3 demo_workflow.py --real
Integration with OpenClaw
This skill leverages OpenClaw's native capabilities:
| OpenClaw Feature | Multi-Agent Usage |
|-----------------|-------------------|
| sessions_spawn | Spawn real worker agents |
| sessions_send | Send messages to workers |
| sessions_list | List active workers |
| sessions_history | Collect worker results |
State Persistence
.openclaw/scratchpad/workers/.openclaw/scratchpad/coordinator_state.jsonTesting
# ่ฟ่กๆผ็คบ
python3 scripts/demo_workflow.pyๆฃๆฅ็ๆ็ๆไปถ
ls -la .openclaw/scratchpad/
cat .openclaw/scratchpad/specs/spec-*.md
Next Steps
1. Use it: ็จ็ๅฎไปปๅกๆต่ฏๅ้ถๆฎตๅทฅไฝๆต 2. Improve prompts: ไผๅ Worker ๆ็คบ่ฏๆจกๆฟ 3. Add features: ๅฎ็ฐ Agent Teams๏ผPhase 3๏ผ 4. Monitor: ๆทปๅ Token ๆถ่ๅ่ๆถ็ป่ฎก
References
๐ก Examples
1. ๅๅค Worker
cd skills/multi-agent
python3 scripts/coordinator_v2.py prepare "Your task description" --role researcher
่ฟไผ็ๆ๏ผ
.openclaw/scratchpad/workers/{id}.json.openclaw/scratchpad/prompts/prompt-{id}.txt2. ๆดพ็ Worker๏ผ็ๅฎๆง่ก๏ผ
# ่ฏปๅ็ๆ็ prompt ๅนถๆดพ็
prompt=$(cat .openclaw/scratchpad/prompts/prompt-{worker-id}.txt)sessions_spawn --label "multi-agent-worker-{worker-id}" \
--task "$prompt" \
--timeout 300 \
--cleanup keep
3. ๅค็ๅฎๆ้็ฅ
ๅฝ Worker ๅฎๆๆถ๏ผๅฎไผ่พๅบ XML ๆ ผๅผ็้็ฅใๆถ้ๅนถๅค็๏ผ
python3 scripts/coordinator_v2.py notify {worker-id} --file notification.xml
4. ็ๆ่งๆ ผๆๆกฃ
# ไปๅทฒๅฎๆ็ Research Workers ็ๆ่งๆ ผ
python3 scripts/coordinator_v2.py spec {worker-id-1} {worker-id-2} {worker-id-3}
5. ่ฟ่กๆผ็คบ
# ๅ้ถๆฎตๅทฅไฝๆตๆผ็คบ๏ผๆจกๆๆง่ก๏ผ
python3 scripts/demo_workflow.py "Your task here"