Skip to main content
AgentDbg’s OpenAI Agents SDK integration registers a tracing processor that listens to the SDK’s native span events and converts them into AgentDbg trace records. Import the module once, wrap your entrypoint with @trace, and every LLM call, tool call, and agent handoff appears in your local timeline—no API key required for the example.

What gets captured

The adapter translates three OpenAI Agents SDK span types:
  • Generation spans (GenerationSpanData) — records model name, prompt input, response output, token usage, and model config as an LLM_CALL event.
  • Function spans (FunctionSpanData) — records tool name, input arguments, result, and error status as a TOOL_CALL event.
  • Handoff spans (HandoffSpanData) — records a TOOL_CALL named "handoff" with from_agent and to_agent stored under meta.openai_agents.handoff.
Framework-specific span details (trace ID, span ID, parent ID, timestamps, model config) are stored in meta.openai_agents.* and do not pollute the main event payload.

Installation

Install AgentDbg with the OpenAI extra:
This installs openai-agents alongside AgentDbg. If you import the integration without openai-agents present, you get a clear ImportError with install instructions.

Setting up the adapter

1

Install the package

2

Import the integration module

Importing agentdbg.integrations.openai_agents registers the tracing processor automatically. You only need to import it once, anywhere before your agent runs:
3

Wrap your entrypoint with @trace

The adapter only records events while an active AgentDbg run is open. Wrap your entrypoint:

Full example

This example emits deterministic fake spans without making any model or network calls, so it works with no API key:
Run it and open the timeline:

Guardrails with the OpenAI Agents SDK

All AgentDbg guardrails work with the tracing processor. When a guardrail fires, the processor immediately stops the run by bypassing the SDK’s except Exception handler, so no further model calls are made.

Checking for aborts after run

As a defensive fallback, the exception is also stored on PROCESSOR.abort_exception. Use PROCESSOR.raise_if_aborted() to re-raise it if you need to check after a run completes:
The adapter records events only while an explicit AgentDbg run is active. Wrap your entrypoint with @trace or traced_run(...).
The minimal example uses low-level SDK tracing spans with deterministic fake data—no API key needed and no model calls made. It’s a safe way to verify your setup before connecting to a real model.