Streaming

The Client SDK provides real-time access to streaming content through the message parts array. Each part has its own status, enabling responsive UIs that update as the agent generates responses.

Streaming State

tsx

Building a Streaming UI

tsx

Rendering Streaming Parts

Parts update in real-time during streaming. Use the part's status to show appropriate UI:

tsx

Tool Call States

Tool calls progress through multiple states:

tsx

Status Indicator

tsx

Handling Completion

tsx

Stop Function

Stop the current stream and finalize any partial message:

tsx

When stop() is called:

  1. The current request is aborted
  2. Any partial message is finalized with current content
  3. Status changes to 'idle'

Named Thread Content

Content from named threads (like "summary") streams separately and is identified by the thread property:

tsx