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 withDocumentation Index
Fetch the complete documentation index at: https://refinehq.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
@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 anLLM_CALLevent. - Function spans (
FunctionSpanData) — records tool name, input arguments, result, and error status as aTOOL_CALLevent. - Handoff spans (
HandoffSpanData) — records aTOOL_CALLnamed"handoff"withfrom_agentandto_agentstored undermeta.openai_agents.handoff.
meta.openai_agents.* and do not pollute the main event payload.
Installation
Install AgentDbg with the OpenAI extra: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
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:Full example
This example emits deterministic fake spans without making any model or network calls, so it works with no API key: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’sexcept Exception handler, so no further model calls are made.
Checking for aborts after run
As a defensive fallback, the exception is also stored onPROCESSOR.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(...).