Event Bus
The RAPID Event Bus enables multiple AI agents to communicate and coordinate their work in real-time. This is a foundational feature for advanced multi-agent workflows.
Why an Event Bus?
Section titled “Why an Event Bus?”Traditional AI coding assistants work in isolation. Each agent has its own context and cannot see what other agents are doing. This creates problems:
- Duplication: Two agents might work on the same problem
- Conflicts: Agents might make incompatible changes
- Inefficiency: No way to delegate tasks to specialized agents
The event bus solves these problems by providing a shared communication channel.
Architecture
Section titled “Architecture”flowchart TB
subgraph EventBus["RAPID Event Bus"]
Redis["Redis Storage"]
Queue["Message Queue"]
Registry["Agent Registry"]
Presence["Presence Tracking"]
Redis <--> Queue <--> Registry <--> Presence
end
Claude["Claude Agent"]
OpenCode["OpenCode Agent"]
Aider["Aider Agent"]
Claude --> EventBus
OpenCode --> EventBus
Aider --> EventBus
Components
Section titled “Components”Redis Storage : Persistent message storage using Redis. Messages are retained for the session lifetime, allowing agents to catch up on missed messages.
Message Queue : FIFO queue for message delivery. Ensures messages are delivered in order and not lost.
Agent Registry : Tracks which agents are connected and their capabilities. Enables targeted messaging.
Presence Tracking : Monitors agent health and activity. Detects when agents disconnect.
Message Flow
Section titled “Message Flow”- Registration: When an agent starts, it registers with the bus
- Publishing: Agents publish messages to the bus
- Routing: The bus routes messages to recipients (all or specific)
- Delivery: Recipients receive messages via their MCP connection
- Acknowledgment: Messages are marked as delivered
Message Types
Section titled “Message Types”Messages have a type field that indicates their purpose:
Task Messages
Section titled “Task Messages”| Type | Description |
|---|---|
task_start | Agent beginning work on a task |
task_progress | Progress update on a task |
task_complete | Task finished successfully |
task_failed | Task failed with error |
task_blocked | Task blocked, needs assistance |
Collaboration Messages
Section titled “Collaboration Messages”| Type | Description |
|---|---|
review_request | Request code review from another agent |
review_complete | Review finished with feedback |
question | Ask a question to other agents |
answer | Answer a question |
suggestion | Suggest an approach or solution |
Notification Messages
Section titled “Notification Messages”| Type | Description |
|---|---|
file_changed | File was modified |
test_result | Test run completed |
build_result | Build completed |
error | Error occurred |
Addressing
Section titled “Addressing”Messages can be addressed in two ways:
Broadcast
Section titled “Broadcast”Send to all connected agents:
{ "type": "file_changed", "content": "Modified src/auth/login.ts"}Direct
Section titled “Direct”Send to a specific agent:
{ "type": "review_request", "to": "opencode", "content": "Please review the auth changes"}Persistence
Section titled “Persistence”The event bus uses Redis for persistence:
- Session Persistence: Messages persist for the session lifetime
- Reconnection: Agents can retrieve missed messages after reconnection
- History: Full message history available via
rapid bus history
Auto-Management
Section titled “Auto-Management”RAPID automatically manages the event bus:
- Auto-Start: When you run
rapid dev, the event bus starts automatically - Docker Container: Redis runs in a Docker container (
rapid-redis) - Health Monitoring: RAPID monitors Redis health
- Cleanup: Stopped when you run
rapid stop
You never need to manually start or configure Redis.
Integration with MCP
Section titled “Integration with MCP”Agents interact with the event bus through MCP (Model Context Protocol) tools provided by the RAPID MCP server:
| Tool | Description |
|---|---|
bus_register | Register agent with the bus |
bus_send | Send a message |
bus_messages | Retrieve messages |
bus_agents | List connected agents |
See the Multi-Agent Guide for usage examples.
Configuration
Section titled “Configuration”Basic configuration (enabled by default):
{ "eventBus": { "enabled": true }}Advanced configuration:
{ "eventBus": { "enabled": true, "redis": { "port": 6379, "dataDir": "~/.rapid/redis-data" }, "injection": { "enabled": true, "promptTemplate": "Connected agents: {{agents}}\nRecent activity: {{recent}}" }, "autoCheck": { "enabled": true, "intervalMs": 30000 } }}Configuration Reference
Section titled “Configuration Reference”| Option | Default | Description |
|---|---|---|
enabled | true | Enable the event bus |
redis.port | 6379 | Redis port number |
redis.dataDir | none | Directory for Redis persistence |
injection.enabled | true | Inject agent context into prompts |
injection.promptTemplate | built-in | Custom prompt template |
autoCheck.enabled | true | Auto-check for new messages |
autoCheck.intervalMs | 30000 | Check interval in milliseconds |
Use Cases
Section titled “Use Cases”Specialist Collaboration
Section titled “Specialist Collaboration”Different agents have different strengths:
- Claude: Architecture, complex reasoning
- Aider: Quick edits, git operations
- OpenCode: Refactoring, code analysis
The event bus lets them work together:
Claude: "I've designed the auth module, delegating implementation to Aider" → sends task_start to Aider
Aider: Implements the module → sends task_complete with file list
Claude: "Please review the implementation, OpenCode" → sends review_request to OpenCode
OpenCode: Reviews and provides feedback → sends review_complete with suggestionsParallel Development
Section titled “Parallel Development”Multiple agents working on different features:
Claude: Working on feature A (src/features/a/)Aider: Working on feature B (src/features/b/)
When Claude modifies shared types: → sends file_changed notification
Aider receives notification: → Updates imports in feature BQuality Assurance
Section titled “Quality Assurance”One agent writes, another reviews:
Claude: Writes new code → sends review_request
OpenCode: Reviews code → sends review_complete with issues
Claude: Addresses issues → sends task_completeLimitations
Section titled “Limitations”- Single Project: The event bus is scoped to a single RAPID project
- Local Only: Agents must be on the same machine (for now)
- Session Lifetime: Messages are lost when Redis stops (unless persistence is configured)
Related
Section titled “Related”- Multi-Agent Guide - Practical guide to using multiple agents
- RAPID MCP Server - MCP tools reference
- CLI Reference - Event bus CLI commands