๐ŸŽ Get the FREE AI Skills Starter Guide โ€” Subscribe โ†’
BytesAgainBytesAgain
๐Ÿฆ€ ClawHub

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...

Versionv0.1.0
Downloads1,342
TERMINAL
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

่ฟ™ไผš็”Ÿๆˆ๏ผš

  • Worker ่ง„ๆ ผๆ–‡ไปถ .openclaw/scratchpad/workers/{id}.json
  • Worker ๆ็คบ่ฏ .openclaw/scratchpad/prompts/prompt-{id}.txt
  • 2. ๆดพ็”Ÿ 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 (ๅนถ่กŒๆŽข็ดข)

  • ๆดพ็”Ÿ 2-4 ไธช Researcher Worker
  • ๆฏไธชไปŽไธๅŒ่ง’ๅบฆๆŽข็ดข้—ฎ้ข˜
  • ๅนถ่กŒๆ‰ง่กŒ๏ผŒๆ”ถ้›†ๅ‘็Žฐ
  • Phase 2: Synthesis (็ปผๅˆ)

  • Coordinator ่ฏปๅ–ๆ‰€ๆœ‰ Researcher ็š„ๅ‘็Žฐ
  • ็”Ÿๆˆ Implementation Specification
  • ๅฎšไน‰ๅ…ทไฝ“็š„ๅฎž็Žฐๆญฅ้ชค
  • Phase 3: Implementation (ๅฎž็Žฐ)

  • ๆดพ็”Ÿ 1-2 ไธช Implementer Worker
  • ๅŸบไบŽ่ง„ๆ ผๆ‰ง่กŒไปฃ็ ไฟฎๆ”น
  • ๅฏไปฅๅนถ่กŒๅค„็†ไธๅŒๆจกๅ—
  • Phase 4: Verification (้ชŒ่ฏ)

  • ๆดพ็”Ÿ 1-2 ไธช Verifier Worker
  • ่ฟ่กŒๆต‹่ฏ•๏ผŒๆฃ€ๆŸฅๅ›žๅฝ’
  • ้ชŒ่ฏๅฎž็Žฐๆญฃ็กฎๆ€ง
  • 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

  • Worker ็Šถๆ€่‡ชๅŠจไฟๅญ˜ๅˆฐ .openclaw/scratchpad/workers/
  • Coordinator ็Šถๆ€ไฟๅญ˜ๅˆฐ .openclaw/scratchpad/coordinator_state.json
  • ๆ”ฏๆŒๆ–ญ็‚น็ปญไผ ๏ผš้‡ๅฏๅŽๅฏไปฅๆขๅคไน‹ๅ‰็š„ Workers
  • Testing

    # ่ฟ่กŒๆผ”็คบ
    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

  • Architecture Design
  • Test Report
  • Claude Code Coordinator Mode
  • ๐Ÿ’ก Examples

    1. ๅ‡†ๅค‡ Worker

    cd skills/multi-agent
    python3 scripts/coordinator_v2.py prepare "Your task description" --role researcher
    

    ่ฟ™ไผš็”Ÿๆˆ๏ผš

  • Worker ่ง„ๆ ผๆ–‡ไปถ .openclaw/scratchpad/workers/{id}.json
  • Worker ๆ็คบ่ฏ .openclaw/scratchpad/prompts/prompt-{id}.txt
  • 2. ๆดพ็”Ÿ 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"