Skip to main content
All agents stream by default - astream() yields Event objects as they occur:
Partial events are suppressed automatically if the LLM decides to call a tool instead of answering - only real text chunks are streamed.

Sub-agent streaming via AgentTool

When using AgentTool, sub-agent events stream through the parent in real-time via ctx.event_callback. Events carry branch and agent_name fields so you can distinguish which sub-agent is producing output:
Sub-agents run in parallel when the LLM calls multiple tools at once - their events are interleaved in the stream as they arrive.

How it works

  1. Before tool execution, LlmAgent creates an asyncio.Queue and sets ctx.event_callback = queue.put_nowait on the tool context.
  2. AgentTool calls ctx.event_callback(event) for each child event as it streams.
  3. LlmAgent yields events from the queue concurrently while tools run, so events appear in real-time.
  4. The event_callback propagates through ctx.derive(), so nested sub-agents also push events up to the root.
Any custom tool can use ctx.event_callback to push events - it’s not limited to AgentTool.

With Runner