Skip to main content

Overview

Streaming execution provides real-time visibility into agent operations. Instead of waiting for completion, you see text output and tool calls as they happen. Combine streaming callbacks with the AgentCtrlConsoleLogger for full execution introspection. Key concepts:
  • executeStreaming(): Execute with real-time output instead of waiting for completion
  • onText(): Callback for each text chunk as it arrives
  • onToolUse(): Callback for each tool call with inputs and outputs
  • AgentCtrlConsoleLogger: Shows execution lifecycle alongside streaming output
  • withMaxTurns(): Limit the number of agent loop iterations

Example

Expected Output

Key Points

  • Real-time output: Text appears as the agent generates it, not after completion
  • Console logger: AgentCtrlConsoleLogger shows execution lifecycle alongside streaming output
  • Tool visibility: See each tool call with its arguments as it executes
  • Progress tracking: Know what the agent is doing at any moment
  • Same response: Final response object has same structure as non-streaming execution
  • Fluent interface: Combine wiretap(), onText(), onToolUse(), and configuration methods
  • Use cases: Progress bars, interactive UIs, debugging, long-running tasks