Skip to main content

Module 05: Streaming Updates

Receive real-time updates from an agent while it processes your prompt.

What You’ll Learn

  • Registering a sessionUpdateConsumer on the client
  • Dispatching on SessionUpdate types with instanceof
  • Handling message chunks, thoughts, tool calls, and plans

The Code

The client registers an update consumer that receives each SessionUpdate as it arrives:
The handler uses instanceof to dispatch on the SessionUpdate type:

Session Update Types

TypeDescription
AgentMessageChunkIncremental response text (the main output)
AgentThoughtChunkAgent’s thinking process
ToolCallTool execution starting
ToolCallUpdateNotificationTool progress update
PlanAgent’s planned steps with priorities and status
AvailableCommandsUpdateSlash commands the agent supports
CurrentModeUpdateAgent mode change
UsageUpdateContext window and cost usage
Updates arrive during client.prompt(). The prompt call blocks until the agent returns a PromptResponse, but updates stream in continuously through the consumer.

Source Code

View on GitHub

Running the Example

Next Module

Module 12: Echo Agent — build your first ACP agent (no API key required).