OpenAI Agents SDK Integration
SDKTraccia automatically instruments the OpenAI Agents SDK for full observability of agent runs.
Traccia automatically detects and instruments the OpenAI Agents SDK when it's installed. No extra code or configuration is required—just call init() and your agent runs, tool calls, handoffs, and LLM generations are traced automatically.
Zero configuration
init().1Install Traccia and OpenAI Agents SDK
Install both packages:
pip install traccia openai-agents2Initialize Traccia
Initialize Traccia at the start of your application. Agents SDK tracing is auto-enabled when openai-agents (Python) or @openai/agents (TypeScript) is installed:
from traccia import init
# That's it! Agents SDK tracing is auto-enabledinit()3Use Your Agent
Create and run your agent as usual. Traccia captures everything automatically:
from traccia import initfrom agents import Agent, Runner
init() # Automatically enables Agents SDK tracing
agent = Agent( name="Assistant", instructions="You are a helpful assistant.")
# Run your agent—all spans are traced automaticallyresult = Runner.run_sync(agent, "Write a haiku about recursion")print(result)Traccia implements the Agents SDK's TracingProcessor interface and registers itself via add_trace_processor() during init().
Configuration
The integration is enabled by default when openai-agents is installed. To disable it:
Option 1: Explicit parameter
init(openai_agents=False)Option 2: Environment variable
export TRACCIA_OPENAI_AGENTS=falsepython main.pyOption 3: Config file (traccia.toml)
[instrumentation]openai_agents = falseTrace Hierarchy
The integration produces a unified trace showing the relationship between your app code, the Agents SDK framework, and underlying LLM calls:
your_app_span
└─ agent.YourAgent (from Agents SDK)
└─ agent.response (from Agents SDK)
└─ llm.openai.responses (from Traccia OpenAI instrumentation)
• Prompt, completion, tokens, costSpan types captured by the integration:
agent.{name}High-level agent execution with metadata
agent.responseResponse operations with IDs
agent.tool.{name}Function tool calls with input/output
agent.handoffAgent-to-agent transfers
agent.guardrail.{name}Safety checks
llm.openai.responsesLLM calls with prompt, completion, tokens, cost
Compatibility
Installed but unused
If you have openai-agents installed but never use it (e.g., you use LangChain or pure OpenAI for your actual logic), the Traccia processor is registered but never invoked. No overhead.
Mixed frameworks
If your app uses both LangChain and Agents SDK for different flows, each integration handles its own code path independently. No conflicts.
Non-Agents apps
If openai-agents is not installed, Traccia works normally without any agent-specific features.
Complete Example
from traccia import init, span, stop_tracingfrom agents import Agent, Runner
init()
# Define your agent with toolsagent = Agent( name="MovieRecommenderAgent", instructions="You recommend movies based on user preferences.", model="gpt-4o-mini")
# Run with full tracingwith span("recommendation_session") as session_span: session_span.set_attribute("user.preference.genre", "sci-fi") result = Runner.run_sync( agent, "Recommend 5 sci-fi movies for someone who liked Blade Runner" ) session_span.set_attribute("recommendations.count", len(result))
# Flush traces before exitstop_tracing(flush_timeout=1.0)Next Steps
© 2026 Traccia.