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
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:
tracingTracingConfigTraceCtxManagerTraceProviderTracingProcessoradd_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
| Hook | AITracer role |
|---|---|
on_llm_start | Create pending execution record |
on_llm_end | Capture tokens, latency, response, cost |
on_tool_start / on_tool_end | Tool execution boundaries |
on_trace_start / on_trace_end | Finalize trace for storage |
force_flush / shutdown | Flush buffered records |
Recommended defaults
- Keep the default OpenAI exporter enabled
- Add a mirror processor with
add_trace_processor(...) - Use stable
workflow_nameandgroup_idvalues - Set
trace_include_sensitive_data=Falsein shared environments - 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="..."):
passExact 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.