Skip to main content

Overview

Broker sits between an Axon and an agent process running inside a Devbox. The Axon is the system of record and Broker is the bridge that turns stream events into serialized agent work. Axon records and sequences events. Broker turns those events into agent turns. Its job is to:
  • receive user and external events from the Axon stream
  • forward them to the agent through the configured protocol adapter
  • publish agent output back to the same Axon stream
  • enforce serial turn execution so only one turn runs at a time
This separation is what lets Axon act as the shared event bus while agents remain isolated behind a stable event interface.

Event Flow

Broker owns the turn lifecycle:
  1. It reads inbound events from Axon.
  2. It starts a turn when it receives a user or external event.
  3. While that turn is running, additional inbound turn-starting events are queued.
  4. It publishes turn output back into Axon as structured events.
  5. When the turn completes, it moves back to idle and processes the next queued event.

Responsibilities

Message Forwarding

Broker consumes inbound events such as user.message from Axon and forwards them to the attached agent.

Turn Serialization

Broker enforces one active turn at a time. This prevents overlapping agent turns and gives downstream consumers a clear ordered stream of turn output.

Event Publishing

Broker republishes agent and turn lifecycle output back into Axon so clients can subscribe to the same stream they published into. Common outbound events include:
Event TypeOriginDescription
turn.startedSYSTEM_EVENTA new turn has begun
turn.message_chunkAGENT_EVENTIncremental agent text output
turn.tool_callSYSTEM_EVENTA tool call started
turn.tool_call_updateSYSTEM_EVENTTool call progress or result update
turn.completedSYSTEM_EVENTThe turn ended normally
turn.cancelledSYSTEM_EVENTThe turn was cancelled
turn.failedSYSTEM_EVENTThe turn ended with a failure condition

Loop Prevention

Broker ignores agent- and system-originated events when reading from Axon so it does not re-consume its own output.

Protocol Forwarding

Broker is protocol-agnostic. It launches agent binaries, understands each protocol to manage turn lifecycle, and forwards protocol-specific messages between the Axon stream and the agent process. Events published to and from Axon remain protocol-specific—Broker does not normalize them into a common schema. Clients should send and receive events in the format defined by the agent’s protocol.

Supported Protocols

Runloop currently supports the following Broker protocols:
  • acp for agents that implement the Agent Client Protocol over stdin/stdout
  • claude_json for Claude Code CLI in streaming JSON Lines mode
  • codex_app_server for Codex CLI in app-server mode over JSON-RPC
The choice of protocol is independent of the agent binary. Broker uses the configured protocol adapter to translate between Axon events and the agent process.
Use a broker_mount on your Devbox to select the protocol adapter and attach Broker to an Axon stream.