Skip to main content

Overview

This example demonstrates real-time streaming output from the OpenCode 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
  • AgentCtrlConsoleLogger: Shows execution lifecycle alongside streaming
  • OpenCode exposes cost and session information

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
  • Console logger: Execution lifecycle events interleaved with streaming output
  • Cost visibility: OpenCode provides cost tracking in the response