Stream tokens from an Agent the moment the LLM produces them — across every internal loop including tool-call turns, synthesis turns, and the autonomous plan/execute/summary cycle.
The Agent exposes two generator methods:
agent.run_stream(task) — sync generator yielding str tokens
agent.arun_stream(task) — async generator yielding str tokens
Both work for any max_loops value (1, integer > 1 with tools, or "auto").
Tokens stream during the tool-call turn AND the synthesis turn that runs after the tool returns.
Async Streaming
Drop-in for any async caller. The agent loop runs in a thread executor; tokens flow through an asyncio.Queue so the caller’s event loop is never blocked.
Streaming Through the Autonomous Loop
When max_loops="auto", the agent runs a plan→execute→summary cycle. All phases stream their tokens — including the final summary phase.
run_stream and arun_stream are real LLM streaming, not buffered chunking. Tokens arrive over the wall-clock duration of the LLM call (typically 10–80 ms apart inside a network burst), not all at once at the end.