Skip to main content
Iterate the run to get events as data — route them to a GUI, a websocket, metrics, or break mid-stream to cancel. Each iteration yields a typed event: ToolCall (a tool-call boundary, finished=False on start and True on finish) or TextChunk (the answer, as it streams).
A run is single-use: iterate it or call .text(), not both. The TextChunks reconstruct the same answer .text() returns.

Guide: streaming the run

Observe vs respond, agent attribution, and cancelling mid-stream.