Events
Each Session has an append-only journal. Sequence numbers (seq) are allocated
inside the same transaction as the state change, so the journal and the
projections never disagree. Runtime and browser caches are never authoritative.
Endpoint
Section titled “Endpoint”GET /api/sessions/{session_id}/events
| Parameter | Meaning |
|---|---|
after |
Return events with seq greater than this (default 0). |
limit |
Page size, 1 to 1000 (default 500). |
types |
Comma-separated event types to include. |
turn_id |
Only events for one Turn. |
max_seconds |
SSE only: how long the stream stays open (max 600). |
Without Accept: text/event-stream the response is JSON:
{"items": [], "next_after": 12, "event_watermark": 12}With Accept: text/event-stream each event is an SSE frame with id set to
seq, event set to the type and data set to the JSON envelope. Comment lines
(: watermark N, : heartbeat) are keep-alives to ignore. Last-Event-ID
resumes like after; if both are given they must agree.
Watermarks
Section titled “Watermarks”event_watermark is the highest committed seq. Initial reads return the
snapshot and its watermark from one database snapshot, so replay from after=W
is gap-free. Clients dedupe by seq.
Envelope
Section titled “Envelope”id, workspace_id, session_id, seq, type, schema_version,
recorded_at, observed_at, actor, source, causation_id,
correlation_id, turn_id, execution_id, executor_lease_id,
lease_generation, delegation_id, changeset_id, delivery_id,
runtime_epoch, local_seq and payload.
Event types
Section titled “Event types”| Family | Types |
|---|---|
session. |
created, settings_changed, archived, unarchived, closed |
message. |
accepted, routed, part_added, part_updated, completed |
turn. |
queued, preparing, started, cancel_requested, succeeded, failed, cancelled, interrupted |
execution. |
preparing, started, native_bound, observed_terminal, stopped |
tool. |
started, updated, completed |
usage., diagnostic. |
usage.observed, diagnostic.reported |
executor. |
bound, quiescing, released, unavailable |
worktree. |
restored, changed, apply_requested, applied |
snapshot. |
requested, ready, failed |
changeset. |
capture_requested, ready, capture_failed |
delivery. |
requested, progressed, blocked, succeeded, failed, cancelled, merge_requested, merged, merge_failed |
delegation. |
created, waiting, result_published, failed, cancel_requested, cancelled |
service. |
requested, ready, degraded, failed, stopped |
message.part_added and message.part_updated carry part_key, a revision
that only grows per part, and a mode. With mode: "replace" the payload’s
content is the whole part; with mode: "append" it is a delta to add to the
content you already hold. Apply an event only when its revision is greater than
the one you last applied for that part, and never apply to a sealed part: a
replayed or duplicated event is then a no-op and streamed text is never
duplicated. Claude Code and Grok Build stream replies and visible reasoning as
append deltas (about ten per second) and end each block with the completed text
only if it differs; other CLIs report whole blocks. A turn is
terminal at turn.succeeded, turn.failed, turn.cancelled or
turn.interrupted; execution.observed_terminal with verdict unknown
corresponds to an outcome_unknown Turn.
Errors
Section titled “Errors”invalid_cursor (400) for a negative cursor, a cursor ahead of the journal, or
mismatched after and Last-Event-ID. The Console treats invalid_cursor and
history_reset_required as the signal to fetch a fresh snapshot instead of
replaying.