Skip to main content

Agent Streaming

All agents stream via astream(), yielding Event objects.

Basic streaming

Sub-agent streaming via AgentTool

Sub-agent events stream through the parent in real-time. Events carry branch and agent_name fields.

How it works

  1. LlmAgent creates an asyncio.Queue and sets ctx.event_callback = queue.put_nowait.
  2. AgentTool calls ctx.event_callback(event) for each child event.
  3. Events yield from the queue concurrently while tools run.
  4. event_callback propagates through ctx.derive() for nested sub-agents.
Any custom tool can use ctx.event_callback to push events.

With Runner