events.*
Event subscription and streaming RPC methods
events.* manages real-time event subscriptions over a WebSocket connection. All events flow through a single topic bus (src/gateway/event_bus.rs) and are filtered per connection by a SubscriptionManager.
Methods
| Method | Description |
|---|---|
events.subscribe | Add topic subscriptions (additive) |
events.unsubscribe | Remove topic subscriptions |
events.list | List active subscriptions on this connection |
Event Delivery
Events are delivered as JSON-RPC notifications (no id) over WebSocket, serialised from TopicEvent:
{
"jsonrpc": "2.0",
"method": "event",
"params": {
"topic": "agent.run.complete",
"data": { "run_id": "run-uuid-123", "duration_ms": 5000 },
"timestamp": 1706400000000
}
}Events are fire-and-forget: the server pushes without waiting for acknowledgement; events that fire while a client is disconnected are lost. Topic names come from GatewayEventFrame::topic_name() — see Event Topics.
events.subscribe
Subscribe to one or more topics. Subscriptions are additive — repeated calls append patterns without affecting existing ones.
Request (patterns only):
{
"jsonrpc": "2.0",
"id": 1,
"method": "events.subscribe",
"params": {
"topics": ["agent.run.*", "session.*"]
}
}Request (with field filter):
{
"jsonrpc": "2.0",
"id": 1,
"method": "events.subscribe",
"params": {
"topics": [
"agent.run.*",
{ "topic": "tools.changed", "where": [{ "field": "scope", "equals": "extension" }] }
]
}
}Response:
{ "jsonrpc": "2.0", "id": 1, "result": { "subscribed": ["agent.run.*", "session.*"], "changed": 2 } }Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
topics | array | Yes | Array of topic selectors; each is a string pattern or {topic, where} filter object |
Each where predicate is { "field": "<json_path>", "equals": <value> }; the event is delivered only when the payload field strictly equals the value. When no payload is available, predicates are skipped (the event is dropped, never blindly passed through).
events.unsubscribe
Remove patterns by exact match. A pattern is removed only if it matches the subscribed form exactly.
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "events.unsubscribe",
"params": { "topics": ["agent.run.*"] }
}Response:
{ "jsonrpc": "2.0", "id": 2, "result": { "subscribed": ["session.*"], "changed": 1 } }events.list
List every active pattern on this connection.
Request:
{ "jsonrpc": "2.0", "id": 3, "method": "events.list" }Response:
{ "jsonrpc": "2.0", "id": 3, "result": { "subscribed": ["session.*"] } }Event Topics
Topics are grouped by namespace; a single events.subscribe call can subscribe to multiple groups via wildcards.
Run / Agent Lifecycle (run.*, agent.*)
| Topic | Description |
|---|---|
run.accepted | Run queued and started |
agent.reasoning | Reasoning-phase output |
agent.reasoning.block | Reasoning block (dual-process cognition) |
agent.tool.start | Tool call begins |
agent.tool.update | Tool progress update |
agent.tool.end | Tool call ends |
agent.trace | Execution-trace event |
agent.response.chunk | Response text chunk |
agent.context.gauge | Context-window utilisation |
agent.run.complete | Run completed successfully |
agent.run.error | Run failed |
agent.run.retrying | Failure-driven retry |
agent.ask.user | ask_user clarification request |
agent.clarification.ended | Clarification round resolved |
agent.uncertainty | Model uncertainty signal |
agent.model.resolved | Model selection resolved |
Session / Running Set
| Topic | Description |
|---|---|
session.updated | Session metadata update |
session.lifecycle.changed | Session lifecycle phase change |
running.set.changed | Active-run set change |
Channels
| Topic | Description |
|---|---|
channel.message | Inbound message |
channel.typing | Typing indicator |
channel.status | Channel runtime status |
channel.error | Channel error |
Config / Approvals
| Topic | Description |
|---|---|
config.changed | Configuration change (file-watcher hot-reload or RPC) |
approval.requested / approval.resolved / approval.expired | Approval lifecycle |
Cron / Heartbeat
| Topic | Description |
|---|---|
cron.job.changed | Cron job change (including cron.run triggers) |
heartbeat.task.changed | Heartbeat task change |
Teams / ACP / Gateway Credentials
| Topic | Description |
|---|---|
team.changed | Team composition or task change |
acp.sessions.changed | ACP session set change |
gateway.token.rotated | Gateway token rotation |
gateway.device.revoked | Device revocation |
Surfaces / Runtimes
| Topic | Description |
|---|---|
surface.notify | Surface-level notification |
surface.approval | Surface approval request |
runtimes.install.progress | Runtime install progress (step / log / done / failed) |
Glob Pattern Matching
Subscription patterns use glob-style matching (src/gateway/event_bus.rs::topic_matches):
| Pattern | Matches |
|---|---|
agent.run.* | agent.run.started, agent.run.complete, etc. |
agent.* | Every event under the agent. prefix |
* | Every event |
agent.run.complete | Exact match only |
*.complete | Any event ending in .complete |
* matches a single non-dot segment; patterns match against the full topic string.
Typical Client Flow
// 1. Subscribe to relevant topics
{ "jsonrpc": "2.0", "id": 1, "method": "events.subscribe", "params": { "topics": ["agent.*", "session.*"] } }
// 2. Start a run
{ "jsonrpc": "2.0", "id": 2, "method": "agent.run", "params": { "input": "Check disk usage" } }
// 3. Receive events (no id = notification)
{ "jsonrpc": "2.0", "method": "event", "params": { "topic": "run.accepted", "data": { "run_id": "run-123" } } }
{ "jsonrpc": "2.0", "method": "event", "params": { "topic": "agent.response.chunk", "data": { "run_id": "run-123", "content": "Disk usage is at 45%..." } } }
{ "jsonrpc": "2.0", "method": "event", "params": { "topic": "agent.run.complete", "data": { "run_id": "run-123", "duration_ms": 4200 } } }See Also
- Protocol -- Event delivery format and WebSocket transport
- agent.* -- Agent methods that emit events
- Methods Reference -- All method namespaces