run function that drives them. Arize AX captures every Agents JS run — agent invocations, tool calls, handoffs, guardrails, and the underlying LLM calls — via the @arizeai/openinference-instrumentation-openai-agents package, which registers as a first-class TracingProcessor against the SDK.
Prerequisites
- Node.js 22+
- An Arize AX account (sign up)
- An
OPENAI_API_KEYfrom the OpenAI Platform
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
Setup tracing
The instrumentor implements the Agents SDK’s first-class
TracingProcessor interface rather than monkey-patching imports, so manuallyInstrument(agents) must receive the same @openai/agents namespace your application code imports. Pass exclusiveProcessor: false to the constructor to run alongside the SDK’s default OpenAI tracing exporter instead of replacing it.Run OpenAI Agents JS
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
openai-agents-js-tracing-example. - You should see a new trace within ~30 seconds with this shape: an
Agent workflowroot span (AGENT) wraps anAssistantagent span (AGENT) and aresponseLLM child span (modelgpt-5.5) with the prompt, response, and token usage attached. Tool, handoff, and guardrail spans appear when the agent invokes them. - If no traces appear, see Troubleshooting.
Check from the skill, CLI, or SDK
Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.- Arize skill (agent)
- AX CLI
- SDK
Install the Arize Skills plugin and let your coding agent check for you:Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.
Span filter
The basic setup above exports every span the tracer provider receives. That’s fine for a standalone Node script — nothing else is emitting through the provider. In Next.js / Vercel / NestJS / any runtime that ships its own OpenTelemetry auto-instrumentation, those instrumentations emitPOST / GET spans for every fetch, every page render, every API route, and the Agents SDK spans nest under those HTTP roots inside your AX project. A single chat turn can balloon into 30+ unrelated infra spans.
OpenInference-tagged spans all carry an openinference.span.kind attribute that the @arizeai/openinference-instrumentation-openai-agents processor sets — checking for it is enough to drop non-OpenInference spans. Swap SimpleSpanProcessor in instrumentation.ts for a filtering subclass:
@arizeai/openinference-vercel exports as isOpenInferenceSpan — inlined here so a non-Vercel app doesn’t have to depend on a Vercel-specific package.
The trade-off: filtering removes the HTTP root spans, which orphans the surviving Agents SDK spans on the Traces tab (no parent to anchor them) — they remain visible on the Spans tab. If you also need a clean trace tree on the Traces tab, swap the filter for a span processor that promotes the SDK’s top-level Agent workflow span to root by clearing its parent ID:
SimpleSpanProcessor (or OpenInferenceFilteringSpanProcessor) in instrumentation.ts:
npm install @arizeai/openinference-core lru-cache.
Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.ts. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. - Agents spans missing.
instrumentation.manuallyInstrument(agents)must run beforeAgentis constructed orrunis called. Make sureimport { provider } from "./instrumentation"is the first import in your entry point, and that the same@openai/agentsnamespace passed tomanuallyInstrument(...)is the one your application code imports. 401from OpenAI. VerifyOPENAI_API_KEYis set and has access to the default model. Swapmodel: "gpt-5.5"for a model your key can call.- Spans still going to the default OpenAI tracing exporter. The instrumentor registers exclusively by default. If you need to keep the SDK’s built-in exporter alongside Arize AX, pass
new OpenAIAgentsInstrumentation({ tracerProvider: provider, exclusiveProcessor: false }). - Process exits before spans flush. Spans are exported asynchronously (more so when you swap in the
RootAwareOpenInferenceProcessorbelow, which batches); alwaysawait provider.forceFlush()(orprovider.shutdown()) before the process exits to avoid losing trailing spans. - Tool / handoff / guardrail spans expected but not present. These spans only emit when the agent actually invokes the corresponding feature. The minimal example above has none — add
tools,handoffs, orinputGuardrailsto theAgentconstructor to see them. - AX project is full of
GET /,POST /api/chat, or other infra spans. Your runtime’s auto-OTel (Next.js, Vercel, NestJS, …) is piping HTTP / fetch / page-render spans through the global provider. See Span filter above for theOpenInferenceFilteringSpanProcessorrecipe (and theRootAwareOpenInferenceProcessorif you also need a clean trace tree on the Traces tab). In Next.js apps an additional defence is to skipprovider.register()entirely and pass the provider directly tonew OpenAIAgentsInstrumentation({ tracerProvider })— the instrumentor resolves its tracer off the provider you hand it, so global registration isn’t needed. - Agents SDK spans orphaned on the Traces tab. Expected when the
OpenInferenceFilteringSpanProcessoris the only processor — see Span filter for theRootAwareOpenInferenceProcessorrecipe that promotesAgent workflowto root.