Stream text
- TypeScript
- Python
- Go
- C#
- PHP
- Ruby
- Java
- Rust
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:
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 publishtool.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.