Summary
Refactor the multi-agent swarm to use a strict actor-model architecture with message-passing for complex asynchronous negotiations between specialized agents.
Problem
The current swarm implementation dispatches tasks to agents but lacks structured inter-agent communication. Agents can't negotiate, argue, or collaborate in real-time — for example, a "Cargo Test" agent can't communicate lifetime error context back to a "Code Writer" agent mid-task.
Proposal
Implement an actor-model architecture using message-passing (via tokio::sync::mpsc channels or an actor framework like actix) that enables:
- Inter-agent messaging: Agents send typed messages to each other (e.g.,
CompileError, ReviewFeedback, ArchitectureProposal)
- Negotiation protocols: Structured back-and-forth between agents to resolve conflicts (e.g., Tester reports failing test → Coder proposes fix → Reviewer evaluates → consensus)
- Supervision trees: Parent agents supervise children, restart failed agents, escalate unresolvable conflicts
- Backpressure: Slow agents don't block the swarm; mailboxes buffer messages with configurable limits
- Observable state: Each agent's mailbox and state is visible in the swarm visualization
Implementation Ideas
- Define
AgentMessage enum with variants for each interaction type
- Each agent gets an
AgentMailbox (tokio mpsc sender/receiver pair)
SwarmSupervisor routes messages and monitors agent health
- Implement negotiation as a state machine: Propose → Counter → Accept/Reject
- Use the existing
SwarmDispatchTool as the entry point, extend with message routing
- Integrate with
src/ui/swarm_viz.rs to show message flow in real-time
Example Agent Interaction
Architect → Coder: "Implement UserService with these 4 methods"
Coder → Tester: "UserService ready at src/user.rs, please write tests"
Tester → Coder: "test_create_user fails: lifetime error on line 42"
Coder → Tester: "Fixed, retry"
Tester → Reviewer: "All 8 tests pass, ready for review"
Reviewer → Architect: "Approved with minor style suggestions"
Architect → Supervisor: "Task complete, 4/4 methods implemented and tested"
Relevant Code
src/tools/swarm_tool.rs — current swarm dispatch
src/orchestration/ — multi-agent orchestration
src/ui/swarm_viz.rs — swarm visualization (would show message flow)
src/supervision/ — existing circuit breaker and health monitoring
Summary
Refactor the multi-agent swarm to use a strict actor-model architecture with message-passing for complex asynchronous negotiations between specialized agents.
Problem
The current swarm implementation dispatches tasks to agents but lacks structured inter-agent communication. Agents can't negotiate, argue, or collaborate in real-time — for example, a "Cargo Test" agent can't communicate lifetime error context back to a "Code Writer" agent mid-task.
Proposal
Implement an actor-model architecture using message-passing (via
tokio::sync::mpscchannels or an actor framework likeactix) that enables:CompileError,ReviewFeedback,ArchitectureProposal)Implementation Ideas
AgentMessageenum with variants for each interaction typeAgentMailbox(tokio mpsc sender/receiver pair)SwarmSupervisorroutes messages and monitors agent healthSwarmDispatchToolas the entry point, extend with message routingsrc/ui/swarm_viz.rsto show message flow in real-timeExample Agent Interaction
Relevant Code
src/tools/swarm_tool.rs— current swarm dispatchsrc/orchestration/— multi-agent orchestrationsrc/ui/swarm_viz.rs— swarm visualization (would show message flow)src/supervision/— existing circuit breaker and health monitoring