Trace OpenCode terminal coding sessions, model calls, and tool usage in Arize AX using the Arize Coding Harness Tracing.
Trace OpenCode terminal coding sessions, model calls, and tool usage with Arize AX for full observability.
OpenCode is an open-source AI coding agent built for the terminal. The Arize Coding Harness Tracing instruments OpenCode sessions with an in-process plugin and exports OpenInference spans to Arize AX. Each turn is captured as a trace, with nested spans for the model call and every tool invocation.
The installer prompts for your Arize AX credentials and project name, writes them to ~/.arize/harness/config.yaml, and copies the tracing plugin to ~/.config/opencode/plugin/arize-tracing.ts. OpenCode auto-discovers plugins from both the plugin/ and plugins/ directories under ~/.config/opencode/, so no opencode.json edit is required.
Credentials live in ~/.arize/harness/config.yaml. Environment variables override values in config.yaml and can be set in your shell profile so they apply to every OpenCode session.
If ARIZE_TRACE_ENABLED=false is set in your shell environment — for example, inherited from another harness’s configuration — tracing is silently disabled. Set ARIZE_TRACE_ENABLED=true before launching OpenCode, or unset the variable to fall back to the default of true.
Root span for the turn. Input is the user prompt; output is the assistant’s final text.
LLM: {model}
LLM
Model call with llm.model_name, llm.provider, prompt/completion/reasoning token counts, cache read/write tokens, and llm.cost. One per assistant message.
{tool}
TOOL
One per completed tool call, with tool.name, redacted input/output, and tool-specific attributes such as tool.command, tool.file_path, tool.query, and tool.url.
Timestamps come from OpenCode’s own millisecond clocks rather than wall-clock time on the tracing process. The default project name is opencode unless you set ARIZE_PROJECT_NAME.
OpenCode is architecturally different from the other coding agents in this repo. Extensions load as plugins inside OpenCode’s Bun runtime — there is no per-event subprocess. The integration has two pieces:
A TypeScript plugin shim at ~/.config/opencode/plugin/arize-tracing.ts that listens for message.updated and session.idle events, pulls the authoritative session snapshot via the OpenCode SDK, and pipes it to the reconciler.
A Python reconciler (arize-hook-opencode) that walks the snapshot and emits any new Turn, LLM, and TOOL spans, deduplicated by message ID and tool call ID. Spans are sent directly to Arize AX — no separate buffer or collector service is required.
Sub-agent and task sessions trace independently. OpenCode’s built-in task tool spawns sub-agents that each get their own sessionID. In v1, each sub-agent session produces its own independent trace; they are not linked back to the parent session’s trace.