Automatically trace openai-agents workflows with the SGP processor.
openai-agents
library via the OpenAITracingSGPProcessor
. This processor automatically captures detailed traces from your AI agent runs, translating events from the agent’s lifecycle into SGP traces and spans.
This provides deep visibility into your agent’s execution, including tool calls and model invocations, without requiring manual instrumentation.
openai-agents
package. The processor will raise an ImportError
if the package is not installed.OpenAITracingSGPProcessor
hooks into the openai-agents
tracing system. You register it once, and it listens for lifecycle events, handling the translation to SGP tracing objects automatically.
on_trace_start
creates a corresponding SGP trace with the type AGENT_WORKFLOW
. The root span of this trace is stored internally.on_trace_end
finds the stored root span and marks it as complete.on_span_start
fires for each new operation. It creates a new SGP span, linking it to the correct parent (either another span or the root trace).openai_span_type_map
helper to convert the agent’s span type (e.g., “function”, “generation”) into an SGP SpanType
(e.g., “CODE_EXECUTION”, “COMPLETION”).on_span_end
populates the span’s input
, output
, and metadata
using helper functions that parse the data from the agent. If the agent reports an error, it’s recorded on the span.OpenAITracingSGPProcessor
with the openai-agents
library.