Skip to main content
Looking for Python? See the Python guide.
NPM Version This module provides OpenInference instrumentation for the OpenAI Agents SDK for TypeScript (@openai/agents), capturing agent runs, model calls, tool calls, handoffs, and guardrails as OpenInference spans.

Install

Setup

Use the register function from @arizeai/phoenix-otel to connect to Phoenix, then register the Agents SDK instrumentation. Create the instrumentation.ts file:
The Agents SDK exposes a first-class tracing API, so this instrumentation registers a trace processor with the SDK rather than monkey-patching the module. By default it replaces the SDK’s built-in processors; pass manuallyInstrument(agents, { exclusiveProcessor: false }) to keep OpenAI’s native tracing exporter running alongside Phoenix.

Usage

Spans are exported in batches. The Usage example calls await provider.forceFlush() before exiting so all spans are delivered to Phoenix.

Observe

With instrumentation enabled, you will see the following in Phoenix:
  • AGENT spans for each agent in the run, with graph metadata that lets Phoenix visualize multi-agent handoffs as a graph
  • LLM spans for model calls, including messages, invocation parameters, and token counts
  • TOOL spans for function tool calls, handoffs, and MCP tool listings
  • GUARDRAIL spans for input/output guardrails, including whether the guardrail was triggered
Both the chat completions and responses transports are supported. See the package README for the full span-coverage table and configuration options (including traceConfig for masking sensitive inputs/outputs).

Resources