Skip to main content
Folds raw session/update notifications into typed SessionEvents, correlating tool calls by id and accumulating message text. One reducer per consumer — a turn, a replay, or a session-wide events() stream; feed updates in arrival order.

Constructor

Returns

SessionEventReducer

Properties

undefined | string
required
The full text of the most recent message with any text, if any. Messages that carry only non-text content (citation resources, for instance) are skipped.
string
required
The agent’s message text accumulated so far; distinct messages are separated by blank lines.
ToolCall[]
required
Type: ToolCallMerged tool-call snapshots seen so far, in first-seen order.

Methods

handle()

Fold one raw update into the state and return its typed event.

Parameters

Returns

SessionEvent

toolCall()

The merged snapshot for a tool call id, if seen.

Parameters

string
required

Returns

ToolCall