Docs
OpenAI Agents Integration

OpenAI Agents Integration

Map OpenAI Agents SDK traces, spans, processors, hooks, and function schemas into AITracer.

Agent Lab: Run local Ollama agents in the dashboard — no SDK required (Quick Start). This guide is for ingesting traces from this provider via the SDK or API.

AITracer can mirror OpenAI Agents SDK spans into the same Traces store you use for Agent Lab.

The goal is not to replace provider-native tracing. It adds:

  • durable trace persistence in your AITracer workspace
  • shared history with local runs and coach sessions
  • optional governance and verification on ingest (advanced)

Integration workflow

Rendering diagram...

Keep the default OpenAI exporter enabled; add AITracer as an additional processor.


Core tracing surface

AITracer integrates with the OpenAI Agents SDK tracing layer through:

  • tracing
  • TracingConfig
  • TraceCtxManager
  • TraceProvider
  • TracingProcessor
  • add_trace_processor(...)
  • set_trace_processors(...)
  • set_tracing_disabled(...)
  • set_tracing_export_api_key(...)

These hooks let you mirror spans without changing OpenAI’s native pipeline.


Trace and span mapping

Trace metadata

  • workflow name
  • trace ID
  • group ID
  • metadata
  • start / finish timestamps
  • export metadata

Span metadata

  • span ID and parent span ID
  • span data, errors, timestamps
  • trace relationships

Supported span types

agent, custom, function, generation, guardrail, handoff, MCP tool, response, speech, transcription


Lifecycle hooks

HookAITracer role
on_llm_startCreate pending execution record
on_llm_endCapture tokens, latency, response, cost
on_tool_start / on_tool_endTool execution boundaries
on_trace_start / on_trace_endFinalize trace for storage
force_flush / shutdownFlush buffered records

  1. Keep the default OpenAI exporter enabled
  2. Add a mirror processor with add_trace_processor(...)
  3. Use stable workflow_name and group_id values
  4. Set trace_include_sensitive_data=False in shared environments
  5. Mark curated examples in the dashboard for Training export

Minimal integration example

from agents import trace, custom_span, function_span
from agents import add_trace_processor
from agents.tracing import TracingProcessor
 
class LocalProcessor(TracingProcessor):
    def on_trace_start(self, trace): ...
    def on_trace_end(self, trace): ...
    def on_span_start(self, span): ...
    def on_span_end(self, span): ...
    def shutdown(self): ...
    def force_flush(self): ...
 
add_trace_processor(LocalProcessor())
 
with trace("my_workflow", metadata={"component": "aitracer"}):
    with custom_span("preflight", {"risk": "low"}):
        pass
    with function_span(name="summarize", input="...", output="..."):
        pass

Exact import paths and helper signatures may vary depending on the installed openai-agents SDK version.


Optional advanced

Integrity verification and audit retention: Verification Layer, Audit Vault.


OpenAI Agents Integration – AITracer — AITracer