OpenAI Agents SDK Integration

Full observability for OpenAI Agents SDK workflows. Capture multi-agent handoffs, tool calls, guardrail validations, and LLM usage with automatic child-span extraction.

openai-agents >= 0.0.7Multi-AgentTool CallsHandoffsGuardrails

Installation

Terminal
pip install turingpulse-sdk turingpulse-sdk-openai-agents openai-agents

Quick Start

main.py
from agents import Agent, Runner
from turingpulse_sdk import init, TuringPulseConfig
from turingpulse_sdk_openai_agents import instrument_openai_agents

# Initialize TuringPulse
init(TuringPulseConfig(
    api_key="sk_live_...",
    workflow_name="my-project"
))

# Define your agent
agent = Agent(
    name="research-assistant",
    instructions="You are a helpful research assistant.",
    tools=[web_search, file_reader],
)

# Wrap for observability — returns a callable
run = instrument_openai_agents(agent, name="research-workflow")

# Sync execution
result = run("What are the latest AI trends?")
print(result.final_output)

# Async execution
result = await run.async_run("Summarize this paper")

What Gets Captured

TelemetryDescription
Workflow spanTop-level span covering the full agent run
LLM callsEach model invocation with token counts and model info
Tool callsFunction calls with arguments and results
HandoffsAgent-to-agent delegation with target agent name
GuardrailsValidation results with pass/fail status
Token usageAggregated input/output tokens across all LLM calls

Multi-Agent Handoffs

When agents delegate to other agents via handoffs, TuringPulse captures the full delegation chain as child spans, making it easy to trace which agent handled each part of a conversation.

multi_agent.py
from agents import Agent

triage_agent = Agent(
    name="triage",
    instructions="Route to the appropriate specialist.",
    handoffs=[billing_agent, technical_agent],
)

billing_agent = Agent(
    name="billing",
    instructions="Handle billing inquiries.",
)

technical_agent = Agent(
    name="technical",
    instructions="Handle technical support.",
)

run = instrument_openai_agents(triage_agent, name="support-workflow")
result = run("I need help with my invoice")

With Governance

governance.py
from turingpulse_sdk import GovernanceDirective

run = instrument_openai_agents(
    agent,
    name="regulated-workflow",
    labels={"compliance": "soc2"},
)

result = run("Process this financial transaction")
💡
Trace Visualization
Multi-agent handoffs appear as a tree in the trace view, showing exactly which agent handled each part of the conversation and what tools were used.

Next Steps