What you see in a turn
A typical turn produces:start— the turn began.thinking(only for reasoning models) — the model’s plan or reasoning trace.delta— streaming assistant text, one chunk at a time.tool— one card per tool call, updated as the tool runs.state— session state changed (branch, resume, compaction).done— turn finished. Errors arrive here or as anerrorevent.
Consuming the stream
In the web app: the browser subscribes to NDJSON over an HTTP route (web/app/src/routes/api/). The BEUI renderer in web/design turns each event into a card.
From the CLI: run in json mode to get one JSON object per line on stdout, or rpc mode for a JSON-RPC framing:
jq for a quick shell UI:
DaemonClient and subscribe to AgentSessionEvent. See Daemon.
Partial messages
The runtime emitsmessage_update events carrying the growing streamingMessage as the model streams tokens. On message_end you get the final AgentMessage. Render the partial one until the final one arrives.
Errors are events
The stream never throws mid-turn. Failures arrive asdone (with an error status) or as an explicit error event. Clients don’t need to distinguish between transport and agent errors — both are on the same channel.