The event envelope
Every durable entry of a room’s log is one event envelope, version 1. Writers hand the broker a
type, a payload and an idempotency key; the broker assigns seq, id and ts and stamps actor
from the authenticated credential. A value a client sends for those fields is ignored. The room
broker owns the shape and it is frozen: changing it is a breaking contract change.
Fields
| Field | Type | Set by | Rule |
|---|---|---|---|
v | integer | broker | Always 1 |
id | string | broker | A ULID (26 characters, Crockford base32), unique per event |
seq | integer | broker | Gapless per room, from 1. Assigned under the room’s row lock |
roomId | string | broker | An 8-character base32 room id, ^[a-z2-7]{8}$ |
runId | string | broker | The run the event belongs to (^[a-z2-7]{8}$). Omitted when the event belongs to no run |
actor | object | broker | {kind, id, role?}, from the credential. See actors |
type | string | writer | One of the ten types |
causedBy | integer | writer | The seq this event answers, when there is one. Omitted otherwise |
origin | string | broker | harness, client or broker. See origins |
ts | string | broker | RFC 3339, UTC, up to microsecond precision (Go drops trailing zeros) |
redactions | array of strings | broker | The redaction rule ids that fired on this payload. Always present, [] when none |
payload | object | writer, then redacted | The type’s payload, at most 64 KiB |
{
"v": 1,
"id": "01JB6QM9S346Q3D25VT4F5V37E",
"seq": 1842,
"roomId": "3kq7x2ma",
"runId": "7f3cq2xz",
"actor": { "kind": "agent", "id": "agent:7f3cq2xz", "role": "reviewer" },
"type": "tool_result",
"causedBy": 1840,
"origin": "harness",
"ts": "2026-09-23T14:02:11.482913Z",
"redactions": ["github-app-token"],
"payload": { "callId": "call_42", "status": "ok", "output": "token=[REDACTED:github-app-token]", "truncated": false, "bytes": 51 }
}A unit test pins exactly these twelve keys on the wire.
Actors
kind | id | role | Who |
|---|---|---|---|
agent | agent:<runId> | The run’s spec.role (implementer, reviewer, tester, triager) | A run, through its bridge or a room tool |
human | human:<zitadel sub> | — | A person, through the web UI or maku |
system | system:<component> | — | system:room-broker for the broker’s own events; system:factory for the factory; system:policy for deterministic approval rules |
The broker derives agent:<runId> from the token’s sub
(system:serviceaccount:agents:run-<runId>, after runs.namePrefix), never from a header or a request body.
Agent-originated events are untrusted content attributed to that agent.
Origins
origin | Meaning | Examples |
|---|---|---|
harness | Mirrored from a run’s harness by its bridge | message, tool_call, tool_result, turn, state_changed{harness_status} |
client | Written by a participant through an API | A system caller’s task_state and task facts; a human’s message; a room tool’s handoff, verdict or progress note |
broker | Written by the broker itself | room_phase, run_phase, participant, the seal, limit, verdict outcomes |
Idempotency
Every append carries an idempotency key, (roomId, originClient, originSeq), held in a unique
database index rather than in the envelope. A key already stored returns the stored event, appends
nothing and consumes no seq, so retries, restarts and a new leader never duplicate an event.
originClient | originSeq | Writer |
|---|---|---|
agent:<runId> | Item key of the harness event: event i owns 4i … 4i+3 | The bridge, harness events |
agent:<runId>:status | A counter of status transitions | The bridge, status tracker |
system:<name> | The caller’s clientSeq | The system API |
system:<name>:task | The caller’s clientSeq | The system API’s task facts |
broker:room | 1 | The Room controller, room_phase: Open |
broker:run:<runId> | 1 joined, 2 running, 3 ended, 4 left | The leader’s run events |
broker:seal | 1 | The seal |
broker:busy:<runId> | 1 | The concurrent_run limit event |
human:<sub> | The browser’s clientSeq | Human actions |
agent:<runId>:tools | Unix nanoseconds (MCP has no retry key) | Room tools |
agent:<runId>:approvals | Unix nanoseconds; the approval itself is unique per (room, run, eventId) | The bridge’s approval requests |
broker:approval:<approvalId> | 1 | The broker’s close of an approval: expired or superseded |
broker:verdicts | The verdict’s seq | The verdict poster’s outcome |
Limits
| Limit | Value | What happens |
|---|---|---|
| Payload | 64 KiB | Stored as a stub, {"oversize": true, "bytes": N, "type": "<type>"}, never refused: a refused harness event would block the bridge’s cursor forever. The content stays in the pod until it ends |
| Tool output | 16 KiB | Truncated by the bridge; truncated: true and bytes keeps the original length |
| Human message, system message text | 16 KiB | 400 bad_message |
| A value Postgres refuses (SQLSTATE class 22), or keys that collide once redacted | — | Stored as {"refused": true, "type": "<type>", "reason": "invalid_value" | "key_collision"} so the cursor moves on |
| NUL characters | — | Stripped from every string and key before storage (jsonb refuses them) |
| Room size | 100 000 events or 256 MiB | The room is sealed with a final state_changed{kind: limit, events, bytes} |
| Bridge batch | 2 MiB per request; the bridge sends at most 100 items | 413 batch_too_large above 2 MiB or 500 items |
Streaming deltas, presence and typing never enter the log. No writer records human presence.
Payloads by type
The payload shape of every type.
type | Payload | Written by |
|---|---|---|
message | {kind: chat | review_verdict | task_state | progress | judge_verdict, text, to[], delivery: none | queued | steering}. review_verdict adds {verdict: approve | changes, commit}, and pullRequest and checks (additive): checks is the acceptance the factory asked the reviewer to check, carried on an approve with no text only. judge_verdict adds {verdict: met | not_yet | impossible, evidence[]}: the harness’s completion judge’s answer, text its reason. The factory defines task_state’s text. progress is a run’s one-line note for the humans following the room, at most 280 characters, delivered to nobody: the agent’s claim, rendered as text | Harness (chat), system callers (task_state), room tools (progress through room_progress only) and humans |
turn | {runId, turnId, phase: started | completed | cancelled | failed} | The bridge’s status tracker |
tool_call | {callId, tool, args, class, risk, decidedBy: policy | human | null} | The bridge |
tool_result | {callId, status: ok | error | rejected, output, truncated, bytes} | The bridge |
approval_requested | {approvalId, callId, class, action, expiresAt, prompters}. action is the raw call, redacted; prompters are the principals who prompted the turn (four-eyes: none of them decides) | The broker, from the bridge |
approval_decided | {approvalId, decision: approved | denied | expired | superseded, reason}. superseded: the call already has a tool_result, or its run has ended, so nobody decides it | A human, or system:room-broker for an expiry or a supersede |
participant | {principal, change: joined | left | role_changed, role, approver} | The broker |
driver | {from, to, epoch, reason: given | requested | taken: <the owner's reason, redacted> | lease_expired} | The broker |
handoff | {fromRole, toRole, summary, commit, branch, scope?, split?} (scope: the scoper’s bounded task, from a triager run; split: the scoper’s split of the task into parts, from a triager run, always beside scope) | room_handoff |
state_changed | {kind, …}, one of the kinds below | Broker or bridge |
state_changed kinds
kind | Fields | Written by |
|---|---|---|
room_phase | phase: Open, owner, driver, dataClass; or phase: Closed, reason (the seal) | Broker |
run_phase | phase, and when it ended a reason (see end reasons); on phase: Running, model? (additive): the run’s AgentRun spec.model, absent when the claim has none or one outside 1 to 64 of A-Za-z0-9._:/@+- starting with a letter or digit. The claim’s, never the sandbox’s; and unsandboxed: true for a run the controller placed without a RuntimeClass (ALLOW_UNSANDBOXED=1) | Broker (leader) |
limit | events, bytes (the seal of a full room); or reason: concurrent_run, running | Broker |
harness_status | status, previous (the harness’s execution_status); effort? (additive): the reasoning effort the run sends the gateway, as agent-run set it in its conversation’s effort tag, one of none, minimal, low, medium, high, xhigh, max. The agent can rewrite the tag, so it is the run’s claim, bounded by that set: the bridge leaves out a value outside it, and the broker strips one after redaction (a secret redacted there included) and keeps the status. A model here is stripped: a run’s model is its claim’s, on run_phase. An older harness sends no effort | Bridge |
harness_error | code, detail: the harness’s own error, or the bridge’s stall on its log (event_too_large, cursor_lost, next_page_unreadable), told once per stall | Bridge |
harness_paused | — | Bridge |
harness_end | reason: judge_impossible, stalled or not_met, the loop policy’s end of an implementer run, or budget_calls, a scoper stopped at its tool-call limit, from agent-run’s final read; recorded once per value | Bridge |
harness_event | harnessKind: an event kind the pinned harness version did not have, recorded without its content; or malformed, oversize or refused, a stub keeping the slot of an item the broker could not take, with detail (its type), bytes and the broker’s reason | Bridge |
verdict_posted, verdict_not_posted | verdictSeq, and url or reason: no_pull_request, github_refused with detail http_<status> or too_many_comments, or expired with detail: window_24h | Broker (leader) |
interrupt | runId | Broker, on the driver’s interrupt |
delivered, interrupted | ref, runId: the bridge’s acknowledgement of a delivery; interrupted without ref is the harness’s own InterruptEvent | Bridge |
undeliverable | ref, runId, code: the harness refused the delivery for good, with that HTTP status; the stream goes on past it | Bridge |
queued_removed | ref | Broker |
queued_consumed | runId, refs: the queued messages a factory run’s brief quoted, moved to consumed by that run in the same transaction, oldest first; never recorded for a call that moved none | Broker, on the factory’s POST /v1/rooms/{id}/queue/consume |
run_requested | role, runId, via: manifest | factory, baseRef, taskUrl (a reviewer’s PR), consumed: the refs of the queued messages its brief quoted, moved to consumed in the same transaction | Broker, on a human’s start_run |
policy_decision, decision_applied | callId, class, decision (allow or deny, the bridge’s local verdict; a human class shows as approval_requested instead); or ref, runId: an approver’s decision the bridge answered the harness with | Bridge |
task | phase, reason?, run?{id, role, persona?, trigger?, startedAt?, endedAt?, outcome?, verdict?, microUSD?, provenance?{factoryVersion?, compositionRevision?, harnessImage?, servedModels?}}, runs?[] (persona is what the run is for, a lowercase name of 1 to 32 characters [a-z][a-z0-9-], set by the factory alone; the run history, oldest first, at most 20, each shaped like run; outcome is succeeded, failed, budget_exhausted, revoked, lost or ended, empty while the run goes on; verdict at most 32 bytes; microUSD the run’s dollars), budget?{usedTokens, limitTokens}, profile?{name, source, cohort, recommended?, reason?, why?} (the active harness profile and evaluation cohort from the Task’s status; source is label, floor, control, treatment, scoper or escalation, cohort is labeled, control or treatment; recommended and why record the scoper’s choice even when observe mode keeps the floor; omitted for older tasks and classes without harness profiles), spend?{usedMicroUSD, limitMicroUSD?} (the task’s dollars), spendFinal? (true when the factory claims that spend is the task’s last figure: its runs priced again, after the settle window, and the figure left unbucketed by the factory’s facts key; absent while the dollars may still move and for a task whose runs the meter could not price, so a surface that prints dollars reads it first and says spend settling or spend unpriced in place of a figure), issue?{number, url, author?, labelledBy?} (author as GitHub reports it; a view names it only when it is a GitHub login, 1 to 39 letters and digits with single inner hyphens, or an App’s <slug>[bot], and otherwise says “the issue’s author”), pr?{number, url, author?, reviewers?, approvedBy?, approvedCommit?, approvalStale?} (the maintainer’s approval an AwaitingHuman agents pull request shows with merge.approveToMerge off, beside its reason, which stands: approvedBy a GitHub login, approvedCommit up to 64 lowercase hex characters, approvalStale empty while current, else older_commit (newer commits landed) or before_runs_ended (an approval of the head submitted before the task’s last pushing run ended); neither of the last two without approvedBy), origin? (the room id of the investigate task whose published issue started this task; the webhook tracker repeats it on every event of the room), plan? (the personas the task expects to run, in order, each a persona name, at most 8), split?{of, parts?[]} (a split parent’s parts: of 2 to 5, at most of parts, each {index, issue, room, outcome?} with index 1 to of, room a room id, outcome landed, dropped or reverted, empty while open), parent?{room, issue, index, of} (on a part’s room: the task it was split from, room a room id, of 2 to 5, index 1 to of), monitor? (the post-merge monitor’s verdict, healthy, regression or inconclusive, only for a task with an origin; final once set, so the webhook tracker sends room.monitor_verdict once), mergeByApproval? (an AwaitingHuman pull request a maintainer’s approval returns to the gate, as the hand-off comment says: merge.approveToMerge on, an agents class, a reason no human must fix on the PR), retryHeld? (an Escalated budget-task task whose enforced task cap still leaves less than a whole run: a plain retry is refused task_cap_holds, so no view offers one), policy?{class?, mode, gateOff?, approveToMerge?, adopted?, conditions?{allowedFiles?, protectedFiles?, modifyOnly?, maxPatchFiles?, maxModifiedLines?, diffShape?, holdoutChecks?, maxPerDay?, adoptLogins?, requiredLabel?, oracle?}, classes?[]{name, mode, adopted?}, mergedHow?, name?, decision?, signal?, truncated?} (the merge policy that governs the task, from the factory’s config: mode live, shadow or unarmed; signal is what checks the meaning of the policy named by name (links-only, semver-patch, semver-minor, oracle, contract or none, see merge policies); at most 16 classes, each list at most 8 entries of at most 120 characters, class names [a-z0-9-], mergedHow class or approved; the room’s own repository only, so it is as visible as the room): the factory’s facts about the room’s task, which the room summary and the Room’s status.task read. The latest by seq wins; a fork reads only its own, after forked_from | The factory, through the system route POST /v1/rooms/{id}/task: no bridge, room tool or human can write it |
forked_from | room, seq, commit? (the latest agent commit at or before seq: the fork’s first baseRef, and its PRs’ Forked-from: agent/<room>@<commit>), note? (redacted) | The forker, a human |
commit | — (no writer sets it yet) | — |
A bridge may push only message{kind: chat, delivery: none}, turn, tool_call, tool_result, and
the state_changed kinds harness_*, delivered, interrupted, undeliverable, policy_decision and
decision_applied. Anything else is 400 bad_item, so a compromised sandbox cannot forge a verdict,
a driver change or a decision.
Where harness events come from
The bridge maps each OpenHands agent-server event to zero, one or two envelope items.
| Harness event | Envelope |
|---|---|
MessageEvent | message{kind: chat}; from the user source it is addressed to: ["agent:<runId>"] |
ActionEvent | tool_call, preceded by a message holding the agent’s thought when it has one |
ObservationEvent | tool_result, status: ok or error |
UserRejectObservation | tool_result, status: rejected |
AgentErrorEvent | tool_result, status: error |
ConversationErrorEvent | state_changed{harness_error} |
PauseEvent | state_changed{harness_paused} |
InterruptEvent | state_changed{interrupted, runId}; the status tracker ends the turn |
| Any other kind | state_changed{harness_event, harnessKind} |
| System prompt, token, condensation and completion-log events; streaming deltas | Dropped |
A change of execution_status | state_changed{harness_status}, with the conversation’s effort tag when agent-run set it, plus turn{started} on entering running, and turn{completed | cancelled | failed} on leaving it |
One example per type
message, a chat line mirrored from the harness:
{"v":1,"id":"01JB6Q3S3E28JT97KB6CQ643DZ","seq":5,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"message",
"origin":"harness","ts":"2026-09-23T14:00:03.120044Z","redactions":[],
"payload":{"kind":"chat","text":"I will list the docs directory first.","delivery":"none"}}message, a reviewer’s verdict through room_verdict:
{"v":1,"id":"01JB6QVMXXQKFBF5KZNWJ47TAN","seq":1860,"roomId":"3kq7x2ma","runId":"aaaaaaaa",
"actor":{"kind":"agent","id":"agent:aaaaaaaa","role":"reviewer"},"type":"message",
"origin":"client","ts":"2026-09-23T15:10:44.002311Z","redactions":[],
"payload":{"kind":"review_verdict","text":"Add a test for the empty case.","delivery":"none",
"verdict":"changes","commit":"4be1c9d","pullRequest":"https://github.com/Smana/cloud-native-ref/pull/2114"}}turn:
{"v":1,"id":"01JB6Q9ZT24MNPZX45HY43KWJR","seq":4,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"turn",
"origin":"harness","ts":"2026-09-23T14:00:02.884301Z","redactions":[],
"payload":{"runId":"7f3cq2xz","turnId":"t1","phase":"started"}}tool_call:
{"v":1,"id":"01JB6QP1XPA7Z3DJ8FSSZ5AWSH","seq":6,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"tool_call",
"origin":"harness","ts":"2026-09-23T14:00:03.120101Z","redactions":[],
"payload":{"callId":"call_42","tool":"terminal","args":{"command":"ls docs"},"risk":"LOW","decidedBy":null}}tool_result:
{"v":1,"id":"01JB6Q8VHTPRE95B9EE0ZBGJ09","seq":7,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"tool_result",
"causedBy":6,"origin":"harness","ts":"2026-09-23T14:00:04.41773Z","redactions":[],
"payload":{"callId":"call_42","status":"ok","output":"README.md\narchitecture\nrunbooks","truncated":false,"bytes":31}}approval_requested:
{"v":1,"id":"01JB6QTQM83XSSSS6YS3C4DWA7","seq":1850,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"approval_requested",
"origin":"harness","ts":"2026-09-23T14:30:00.00012Z","redactions":[],
"payload":{"approvalId":"01JB6QN36096Q14DR9GPQY77ZX","callId":"call_97","class":"forge.pr",
"action":{"tool":"terminal","args":{"command":"gh pr create --fill"}},"expiresAt":"2026-09-23T15:00:00Z"}}approval_decided:
{"v":1,"id":"01JB6QYYK596NGYA1DQ91K5GQA","seq":1851,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"human","id":"human:291847362183"},"type":"approval_decided",
"causedBy":1850,"origin":"client","ts":"2026-09-23T14:31:12.55Z","redactions":[],
"payload":{"approvalId":"01JB6QN36096Q14DR9GPQY77ZX","decision":"approved","reason":"PR scope matches the task"}}participant:
{"v":1,"id":"01JB6QPENECFSECZP11HYGCPWP","seq":2,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"system","id":"system:room-broker"},"type":"participant",
"origin":"broker","ts":"2026-09-23T13:59:58.0012Z","redactions":[],
"payload":{"principal":"agent:7f3cq2xz","change":"joined","role":"implementer"}}driver:
{"v":1,"id":"01JB6QQ5E6EYCNDY0YP57RCYBV","seq":1845,"roomId":"3kq7x2ma",
"actor":{"kind":"human","id":"human:291847362183"},"type":"driver",
"origin":"client","ts":"2026-09-23T14:20:01.0003Z","redactions":[],
"payload":{"from":"system:factory","to":"human:291847362183","epoch":8,"reason":"requested"}}handoff:
{"v":1,"id":"01JB6QN5SXS5AA819X9YP98106","seq":1848,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"agent","id":"agent:7f3cq2xz","role":"implementer"},"type":"handoff",
"origin":"client","ts":"2026-09-23T14:45:09.31Z","redactions":[],
"payload":{"fromRole":"implementer","toRole":"reviewer","summary":"Fixed the broken link and added a check.",
"commit":"4be1c9d","branch":"agent/3kq7x2ma"}}state_changed, a run’s end reason:
{"v":1,"id":"01JB6QD7W2K4M6P8R0T2V4X6Z8","seq":1849,"roomId":"3kq7x2ma","runId":"7f3cq2xz",
"actor":{"kind":"system","id":"system:room-broker"},"type":"state_changed",
"origin":"broker","ts":"2026-09-23T14:46:30Z","redactions":[],
"payload":{"kind":"run_phase","phase":"Succeeded","reason":"agent_finished"}}