Skip to main content

Overview

During a prompt turn, the agent sends real-time updates via the sessionUpdate notification. These updates allow your client to provide live feedback to the user as the agent works.

Session Update Flow

When you call connection.prompt(), the agent processes the request and sends multiple sessionUpdate notifications before finally responding:
Clients SHOULD continue accepting tool call updates even after sending a session/cancel notification, as the agent may send final updates before responding with the cancelled stop reason.

Update Types

The SessionNotification contains an update field with a sessionUpdate discriminator:

AgentMessageChunk

Streaming chunks of the agent’s response message.
'agent_message_chunk'
Discriminator value.
number
Message index in the conversation.
MessageContent
The content chunk:
  • { type: "text", text: string } - Text chunk
  • { type: "image", ... } - Image content
  • { type: "audio", ... } - Audio content

Example

AgentThoughtChunk

Streaming chunks of the agent’s internal reasoning (thinking process).
'agent_thought_chunk'
Discriminator value.
number
Message index.
MessageContent
Thought content (typically text).

Example

UserMessageChunk

Streaming chunks of user messages (used when loading sessions).
'user_message_chunk'
Discriminator value.
number
Message index.
MessageContent
User message content.

ToolCall

A new tool call has been initiated.
'tool_call'
Discriminator value.
string
Unique identifier for this tool call.
string
Human-readable title (e.g., “Read file: config.ts”).
ToolCallStatus
Initial status: "pending", "running", "requires_permission", etc.
ToolCallContent[]
Tool call content (text, code blocks, patches, terminals, etc.).

Example

ToolCallUpdate

A tool call’s status or content has been updated.
'tool_call_update'
Discriminator value.
string
The tool call being updated.
ToolCallStatus
New status if changed: "running", "completed", "failed", "cancelled", etc.
ToolCallContent[]
Content to append to the tool call.

Example

Plan

The agent has created an execution plan.
'plan'
Discriminator value.
string
Human-readable plan description.
PlanStep[]
Array of planned steps.

Example

CurrentModeUpdate

The session’s mode has changed.
'current_mode_update'
Discriminator value.
SessionMode
The new current mode.

ConfigOptionsUpdate

Session configuration options have changed.
'config_options_update'
Discriminator value.
ConfigOption[]
Updated configuration options.

AvailableCommandsUpdate

Available slash commands have changed.
'available_commands_update'
Discriminator value.
AvailableCommand[]
Commands the agent can execute.

Implementation Example

Here’s a complete implementation of sessionUpdate:

Rendering Tool Call Content

Tool calls contain various content types:

Handling Cancellation

When the user cancels a prompt:

Performance Considerations

Debouncing UI Updates

For high-frequency updates like text chunks, consider debouncing:

Virtual Scrolling

For long conversations, use virtual scrolling to render only visible messages.

See Also