Skip to main content

Overview

This example demonstrates real-time streaming output from the Pi CLI. Text and tool calls are displayed as they arrive, with AgentCtrlConsoleLogger providing execution lifecycle visibility alongside the streaming output. Key concepts:
  • executeStreaming(): Execute with real-time output
  • onText() / onToolUse(): Callbacks for streaming events
  • withTools(): Control which tools the agent can use
  • AgentCtrlConsoleLogger: Shows execution lifecycle alongside streaming

Example

Expected Output

Key Points

  • Real-time output: Text appears as the agent generates it
  • Tool visibility: See each tool call with arguments as it executes
  • Read-only mode: Use withTools() to restrict to safe, read-only tools
  • Console logger: Execution lifecycle events interleaved with streaming output
  • Cost visibility: Pi provides cost tracking in the response