Skip to content

feat(swarm): implement parallel-spawn swarm coordinator (profiles = fast/precise/creative/audit) #2

Description

@Delqhi

Context

Current autodev swarm is a stub (see docs/SWARM.md Status note). The
canonical use case is first-verified-wins race: N agents run with
different profiles in parallel; the first to pass verify_cmd keeps its
diff, all others are exported (to lessons) and dropped.

Goal

Implement Swarm Coordinator that:

  1. Loads profiles from .autodev/profiles.toml
  2. Launches N AgentLoops in parallel (each with its own profile + verify_cmd)
  3. First to validate → keeps diff via git, drops competitors gracefully
  4. Conserves token spend: cancel losers on first verified win

Acceptance criteria

  • agent_loop.AgentLoop accepts profile constructor arg (model,
    temperature, max_tokens) without breaking existing tests
  • swarm.py (new) launches agents via asyncio.gather + per-task
    subprocess.run boundaries
  • Profile config: .autodev/profiles.toml parser covered by tests
  • Graceful winner-takes-all via a shared Event or asyncio.Future
  • Losers' diffs are saved to .autodev/swarm-lost/<ts>.diff for forensics
  • Lessons from losers are still added to the SQLite KB (SOTA learning)
  • autodev swarm -p "..." --agents fast,precise --budget-minutes 20
    CLI surface unchanged
  • CLI --json output emits per-agent winner + losers + total time
  • Tests: ≥12 new tests across test_swarm.py (profile loader, race
    resolution, loser forensics)
  • ruff ✓ pyright ✓ pytest ✓ ("≥80 passed" target)

Sister project linkage

OpenSIN-Code/SIN-Code-WebUI-v2 already consumes autodev-mcp for
single-agent experiments. This swarm work adds a new MCP tool
autodev_swarm exposing the same multi-agent run in JSON-RPC. Coord
issue: SIN-Code-WebUI-v2#94.

Threat model

  • N parallel LLM calls may exhaust OPENAI_API_KEY rate-limit. Counter:
    exponential backoff + per-key chunk (OpenSIN-Code/SINator keypool pattern).
  • Losers may leave half-applied git state. Counter: each agent has its own
    AgentLoop with own snapshot/rollback + workspace copy under .autodev/swarm/<agent-id>/.

Refs: docs/SWARM.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions