OpenAI Agents SDK
Overview
respan-instrumentation-openai-agents is an instrumentation plugin that captures traces from the OpenAI Agents SDK and sends them to Respan via the unified OTEL pipeline.
It registers a TracingProcessor with the OpenAI Agents SDK that converts native SDK trace/span events into OTEL ReadableSpan objects with proper traceloop.* and gen_ai.* attributes.
Version: 1.0.0 | Python: >=3.11, <3.14
Dependencies
Quick start
Public API
OpenAIAgentsInstrumentor
The main instrumentor class. Implements the Instrumentation protocol.
activate()
When called, activate():
- Creates an internal
_RespanTracingProcessorinstance. - Calls
agents.tracing.set_trace_processors([processor])to replace the default OpenAI tracing backend. - All subsequent traces and spans from the OpenAI Agents SDK are routed through Respan instead of OpenAI’s tracing endpoint.
set_trace_processors() replaces all existing processors. If you need OpenAI’s native tracing alongside Respan, you will need a custom setup.
deactivate()
Clears the internal processor reference. Does not restore the original OpenAI processors.
Captured span types
The plugin captures all span types from the OpenAI Agents SDK:
Span attributes
All spans include these common attributes:
LLM spans (ResponseSpanData, GenerationSpanData) additionally include:
With propagated attributes
Use propagate_attributes() to attach per-request metadata to all spans:
With decorators
Combine plugin instrumentation with decorators for additional context:
Architecture
Internal modules
These are implementation details, not part of the public API: