Skip to content

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.

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.

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

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.

  1. Registration: When an agent starts, it registers with the bus
  2. Publishing: Agents publish messages to the bus
  3. Routing: The bus routes messages to recipients (all or specific)
  4. Delivery: Recipients receive messages via their MCP connection
  5. Acknowledgment: Messages are marked as delivered

Messages have a type field that indicates their purpose:

TypeDescription
task_startAgent beginning work on a task
task_progressProgress update on a task
task_completeTask finished successfully
task_failedTask failed with error
task_blockedTask blocked, needs assistance
TypeDescription
review_requestRequest code review from another agent
review_completeReview finished with feedback
questionAsk a question to other agents
answerAnswer a question
suggestionSuggest an approach or solution
TypeDescription
file_changedFile was modified
test_resultTest run completed
build_resultBuild completed
errorError occurred

Messages can be addressed in two ways:

Send to all connected agents:

{
"type": "file_changed",
"content": "Modified src/auth/login.ts"
}

Send to a specific agent:

{
"type": "review_request",
"to": "opencode",
"content": "Please review the auth changes"
}

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

RAPID automatically manages the event bus:

  1. Auto-Start: When you run rapid dev, the event bus starts automatically
  2. Docker Container: Redis runs in a Docker container (rapid-redis)
  3. Health Monitoring: RAPID monitors Redis health
  4. Cleanup: Stopped when you run rapid stop

You never need to manually start or configure Redis.

Agents interact with the event bus through MCP (Model Context Protocol) tools provided by the RAPID MCP server:

ToolDescription
bus_registerRegister agent with the bus
bus_sendSend a message
bus_messagesRetrieve messages
bus_agentsList connected agents

See the Multi-Agent Guide for usage examples.

Basic configuration (enabled by default):

rapid.json
{
"eventBus": {
"enabled": true
}
}

Advanced configuration:

rapid.json
{
"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
}
}
}
OptionDefaultDescription
enabledtrueEnable the event bus
redis.port6379Redis port number
redis.dataDirnoneDirectory for Redis persistence
injection.enabledtrueInject agent context into prompts
injection.promptTemplatebuilt-inCustom prompt template
autoCheck.enabledtrueAuto-check for new messages
autoCheck.intervalMs30000Check interval in milliseconds

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 suggestions

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 B

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_complete
  • 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)