Skip to main content
Call the agent’s stream method instead of run to show text and tool activity while the run is in progress. It runs the same resumable loop over the gateway’s Responses SSE stream, and the continue-stream method does the same for a paused run. Rust has no streaming.

Stream text

The final result is the same run result that run returns. How the stream runs differs by language:
agent.stream() and agent.continueStream() return a stream result straight away. getResult() resolves when the run finishes.

Choose a stream

Every consumer replays events from the start, so a UI renderer, a logger, and persistence code can read the same run without a second model request. TypeScript also has getText() to await the whole answer, so rendering and persistence can run side by side:
Model events are response.output_text.delta, response.reasoning.delta, and response.item; Items has their fields. Model events are streamed only when the client supports streaming, as every gateway client does. With another model client (one that doesn’t implement StreamingModelClient, IStreamingModelClient, or respond to stream), the stream still emits lifecycle events but no text deltas.

Stream tool progress

Tools that report progress publish tool.preliminary_result events, which appear in the full stream (and in TypeScript’s tool stream) and stay attached to the completed step. Tools shows how each language reports progress.

Cancel a stream

Each completed step keeps its request ID, provider, model, finish reason, warnings, and usage.
Last modified on November 5, 2026