Zespan
Start free
OpenAI Agents SDK

OpenAI Agents SDK Integration

Add the Zespan tracing processor to the OpenAI Agents SDK. Agent runs, hand-offs, guardrails and tool calls arrive as one trace per run, with every span carrying the name of the agent it ran under.

The OpenAI Agents SDK is OpenAI's framework for building agents that call tools, hand off to other agents and run guardrail checks, with its own built-in tracing model.

zespan.com — openai agents sdk trace
Zespan trace of an agent run with agent, hand-off and tool call spans

Getting Started

1

Install the SDK

In Python, install zespan with the openai-agents extra. In TypeScript, use @zespan/sdk.

bash
pip install zespan[openai-agents]
2

Add the tracing processor

Initialise Zespan and call instrument_openai_agents(). Each finished Agents SDK span becomes a Zespan event.

python
import zespan
from zespan.integrations.openai_agents import instrument_openai_agents

zespan.init(api_key="zsp_...")
instrument_openai_agents()
3

TypeScript: pass addTraceProcessor

In TypeScript, pass the Agents SDK's addTraceProcessor to instrumentOpenAIAgents.

typescript
import { addTraceProcessor } from "@openai/agents";
import { initZespan, instrumentOpenAIAgents } from "@zespan/sdk";

initZespan({ apiKey: "zsp_..." });
await instrumentOpenAIAgents({ addTraceProcessor });
4

Read the run in Zespan

Each run is one trace. A triage-to-billing run shows the tool calls and the final reply under billing_agent, and the hand-off span shows triage_agent as the agent it was delegated from.

What's captured automatically

  • Agent spans named agent.<name>, and every span carries the agent it ran under
  • Tool calls with name, arguments, result or error, which the tool-level checks of the domain packs read
  • Hand-offs as handoff spans, never tool calls, with the delegating agent recorded
  • Guardrail spans, marked .triggered when the guardrail fired
  • Model spans with model, tokens, the tools the model asked for, and answer text when prompt storage is on
  • A kill switch: set ZESPAN_OPENAI_AGENTS=off to stop the processor without a code change

FAQ

Do I also need wrapOpenAI or patch_openai?

No. With auto-patching on, the model call a provider wrapper records joins the run's trace under the model span, and you still get one event per model call.

Why do tool checks say "needs data"?

The Agents SDK's sensitive data switch (trace_include_sensitive_data in Python, traceIncludeSensitiveData in TypeScript) controls whether function spans carry input and output. When it is off, only the tool name and status are sent. storeToolIO: false has the same effect.

Can I use OpenTelemetry instead?

Yes, in Python. The openinference-instrumentation-openai-agents package maps the Agents SDK's tracing onto OpenTelemetry spans, which you export to Zespan's /v1/traces endpoint.

Start free — 50K traces a month, no card needed

OpenAI Agents SDK integration works on all plans including the free tier.

← All integrations