Skip to main content
Available in both SDKs. Python (pip install 'sentrial[openai-agents]') and TypeScript (@sentrial/sdk with @openai/agents as an optional peer). Both register a trace processor with the Agents SDK’s tracing pipeline — registration is additive, so the default OpenAI-dashboard exporter keeps running alongside.

What Gets Tracked Automatically

Sessions

One session per agent run (trace) — agent name from the root agent span, aggregated tokens and cost, final output.

LLM Calls

Every generation/response span as a per-call event — model, prompt/completion tokens, auto-calculated cost, duration.

Tool Calls

Each function span with the tool name, parsed arguments, result, and errors.

Handoffs

Agent-to-agent handoffs recorded as decisions (“Handoff from X to Y”).

Guardrails

A triggered guardrail is recorded as an error (and fails the session); a passed guardrail is recorded as a decision.

Errors

A failed run’s root agent span error becomes the session’s failure reason.

Installation

Quick Start

One function call. Then run your agents exactly like before.
TypeScript: @sentrial/sdk never imports @openai/agents itself — you hand it the SDK’s addTraceProcessor (or the whole module namespace: import * as agents from '@openai/agents'; instrumentOpenAIAgents(agents, options)). Python: instrument_openai_agents() is the only entry point that imports the openai-agents package.

Configuration Options

Idempotent registration — Calling instrument_openai_agents() / instrumentOpenAIAgents() again for the same client returns the first registered processor instead of registering a duplicate (which would mirror every run into two sessions). The first duplicate call logs a warning. Keep the returned processor if you plan to call shutdown() or force_flush() / forceFlush() yourself.

How Runs Map to Sessions

Additional mapping notes:
  • Session metadata carries integration: "openai-agents" plus the OpenAI trace_id, so you can cross-reference the run in the OpenAI traces dashboard.
  • The session’s own input is not populated — the Agents SDK does not expose the run input on the trace object; the first user message rides in each generation span’s LLM event instead.
  • finish() records llm_calls, tool_calls, and handoffs as custom metrics.
  • Speech, transcription, MCP-list, and custom spans are ignored — they carry no fields Sentrial models.

Don’t Combine with wrap_openai / wrapOpenAI

wrap_openai() / wrapOpenAI() wrap a raw OpenAI client so each LLM call is tracked inside a session you manage with begin(). This integration instead observes the OpenAI Agents SDK runtime from the outside — each agent run becomes a full Sentrial session automatically. If you use the Agents SDK, prefer this integration; do not combine both on the same run, or LLM calls will be double-counted.

Batching, Explicit Clients & Short-Lived Processes

The Agents SDK invokes processor callbacks inline on the run’s path, so an explicit client with batching enabled is recommended — each track call then enqueues and returns immediately instead of waiting on a network round-trip per span:
At application stop, the Agents SDK calls the processor’s shutdown(), which finishes any still-open sessions as interrupted (failure reason “Trace not ended before processor shutdown”) and flushes the client’s event queue. In short-lived processes (scripts, serverless functions), don’t exit before queued events are sent — call force_flush() / forceFlush() on the processor (or flush() on the client) after your last run when batching is enabled. Tracking is fail-safe by design: every processor callback is containment-wrapped, so a Sentrial error is logged and swallowed — it never crashes your agent run.

Next Steps

Python SDK Reference

Full SDK documentation with all methods and options.

TypeScript SDK Reference

Full SDK documentation with all methods and options.

Google ADK

The same Plugin-style integration for Google’s Agent Development Kit.