Multi-Agent Communication
RAPID includes a built-in event bus that allows multiple AI agents to communicate and coordinate their work on the same project.
Overview
Section titled “Overview”The event bus enables scenarios like:
- Specialist collaboration: Have Claude handle architecture while Aider focuses on tests
- Parallel development: Multiple agents working on different features simultaneously
- Review workflows: One agent writes code, another reviews it
- Task delegation: Agents can request help from other agents
Quick Start
Section titled “Quick Start”-
Enable the event bus (enabled by default):
rapid.json {"eventBus": {"enabled": true}} -
Start multiple agents:
Terminal window # Terminal 1rapid dev# Terminal 2rapid dev --agent opencode -
Check connected agents:
Terminal window rapid bus agents
How It Works
Section titled “How It Works”The event bus uses Redis (managed automatically in Docker) to provide:
- Persistent messaging: Messages are stored and can be retrieved by agents that connect later
- Agent presence: Track which agents are currently active
- Message routing: Send messages to specific agents or broadcast to all
Architecture
Section titled “Architecture”flowchart LR
Claude["Claude Agent"]
OpenCode["OpenCode Agent"]
Aider["Aider Agent"]
Redis["Redis Event Bus"]
Claude <--> Redis
OpenCode <--> Redis
Aider <--> Redis
MCP Tools for Agents
Section titled “MCP Tools for Agents”When the RAPID MCP server is connected, agents have access to these event bus tools:
bus_register
Section titled “bus_register”Register the agent with the event bus.
// Called automatically when agent startsbus_register({ name: 'claude', capabilities: ['code', 'review'] });bus_send
Section titled “bus_send”Send a message to other agents.
// Send to all agentsbus_send({ type: 'task_complete', content: 'Finished implementing auth module',});
// Send to specific agentbus_send({ type: 'review_request', content: 'Please review src/auth.ts', to: 'opencode',});bus_messages
Section titled “bus_messages”Get recent messages from the bus.
// Get all messagesbus_messages({ limit: 50 });
// Get messages from specific agentbus_messages({ from: 'aider', limit: 10 });bus_agents
Section titled “bus_agents”List currently connected agents.
bus_agents();// Returns: [{ id: "claude-abc", name: "claude", lastSeen: "..." }, ...]Message Types
Section titled “Message Types”Common message types for agent coordination:
| Type | Description |
|---|---|
task_start | Agent starting a task |
task_complete | Agent finished a task |
task_blocked | Agent blocked, needs help |
review_request | Request code review |
review_complete | Review finished |
question | Ask other agents a question |
answer | Response to a question |
file_changed | Notify about file changes |
test_result | Share test results |
Configuration
Section titled “Configuration”Basic Configuration
Section titled “Basic Configuration”{ "eventBus": { "enabled": true }}Advanced Configuration
Section titled “Advanced Configuration”{ "eventBus": { "enabled": true, "redis": { "port": 6379, "dataDir": "~/.rapid/redis-data" }, "injection": { "enabled": true, "promptTemplate": "Connected agents: {{agents}}" } }}Configuration Options
Section titled “Configuration Options”| Option | Default | Description |
|---|---|---|
enabled | true | Enable/disable the event bus |
redis.port | 6379 | Redis port |
redis.dataDir | none | Persist Redis data |
injection.enabled | true | Inject agent info into prompts |
injection.promptTemplate | default | Custom prompt template |
CLI Commands
Section titled “CLI Commands”Check Status
Section titled “Check Status”rapid bus statusOutput:
RAPID Event Bus Status────────────────────────────────
Project: my-projectMode: Redis (persistent)URL: redis://localhost:6379Container: d5263f2e5c71
Messages: 42Agents: 3View Message History
Section titled “View Message History”# Recent messagesrapid bus history
# Last 10 messagesrapid bus history --limit 10
# Messages from specific agentrapid bus history --agent claude-abc123
# Filter by typerapid bus history --type review_requestList Connected Agents
Section titled “List Connected Agents”rapid bus agentsOutput:
Connected Agents────────────────
claude-abc123 Name: claude Connected: 2 hours ago Last active: just now Capabilities: code, review, test
opencode-def456 Name: opencode Connected: 1 hour ago Last active: 5 minutes ago Capabilities: code, refactorWorkflows
Section titled “Workflows”Code Review Workflow
Section titled “Code Review Workflow”-
Claude writes code:
Claude: Sends message type "review_request" with file path -
OpenCode reviews:
OpenCode: Receives message, reviews code, sends "review_complete" -
Claude addresses feedback:
Claude: Receives review, makes changes
Parallel Feature Development
Section titled “Parallel Feature Development”-
Start both agents on different features:
Terminal window # Terminal 1 - Claude on authrapid dev# Claude works on src/auth/# Terminal 2 - Aider on APIrapid dev --agent aider# Aider works on src/api/ -
Agents notify each other of changes:
Claude: "file_changed" - src/auth/types.tsAider: Sees notification, updates API imports
Task Delegation
Section titled “Task Delegation”-
Claude encounters a task better suited for another agent:
Claude: Sends "task_blocked" with context -
OpenCode picks up the task:
OpenCode: Receives message, handles the taskOpenCode: Sends "task_complete" when done
Best Practices
Section titled “Best Practices”- Use clear message types: Stick to standard types for interoperability
- Include context: Messages should have enough context to act on
- Avoid conflicts: Coordinate which agent works on which files
- Monitor the bus: Use
rapid bus statusto check health - Clean up: Messages are cleared when you restart the event bus
Troubleshooting
Section titled “Troubleshooting”Event bus not starting
Section titled “Event bus not starting”# Check if Docker is runningdocker ps
# Check Redis containerdocker logs rapid-redis
# Manually restartrapid stop --removerapid devAgents not seeing messages
Section titled “Agents not seeing messages”# Verify agents are registeredrapid bus agents
# Check message historyrapid bus history --limit 100High memory usage
Section titled “High memory usage”Redis stores all messages in memory. If you have many messages:
# Stop and remove to clear messagesrapid stop --remove
# Or configure data persistence# rapid.json: eventBus.redis.dataDir = "~/.rapid/redis"Disabling the Event Bus
Section titled “Disabling the Event Bus”If you don’t need multi-agent features:
{ "eventBus": { "enabled": false }}This skips Redis startup and event bus initialization.