seq within its session, so the stream is fully resumable: reconnect from the last seq you saw and never miss or duplicate an event.
Because every event is sequence-keyed, a dropped connection is not a lost event — you reconnect with the last seq you handled and the stream picks up exactly where you left off:
Event shape
Events follow a{domain}.{action} naming scheme.
Streaming
Streams are delivered as Server-Sent Events. Passafter_seq (exclusive) to replay from a point in history — new consumers pass 0 to get the whole session. The SDK’s stream ends at the turn’s session.idle; a resume on a session that is already idle or ended returns once it has caught up to the session’s last event.
The agent’s final answer
message.completed fires for your message too (data.role is "user"). The agent’s reply is the message.completed without role: "user"; its text is data.content. Keep the last one before session.idle:
TypeScript
Reading history
Events are also available as a paginated list for auditing or replay without a live connection.CLI
Sending events in
You drive a session by sending events too — a user message, a tool confirmation, or an interrupt.TypeScript
Common event types
See the full list in the Event reference.
Next: completion window
Three prices for one model.