The Respan OpenAI Agents SDK integration enables tracing of multi-agent workflows, sending detailed telemetry data to the Respan platform for debugging and optimization.
The framework supports agents configured with instructions, tools, guardrails, and handoffs. Respan captures the full execution tree - every agent run, tool call, and handoff - as a hierarchical trace.
Use traces to debug agent failures, optimize handoff logic, and monitor guardrail performance across your multi-agent system.
Install the openai-agents and keywordsai-exporter-openai-agents packages. Set your KEYWORDSAI_API_KEY and tracing endpoint as environment variables.
Initialize the KeywordsAITraceProcessor before running any agents. The processor captures all agent events and sends them to the Respan platform asynchronously.
Run your agents as normal - basic agents, multi-agent handoffs, and tool-calling agents are all traced automatically. View the full execution tree in the Respan Traces dashboard.
python
from agents import Agent, Runner
from keywordsai_exporter_openai_agents import KeywordsAITraceProcessor
import os
# Initialize the trace processor
processor = KeywordsAITraceProcessor(
api_key=os.environ["KEYWORDSAI_API_KEY"],
endpoint=os.environ["KEYWORDSAI_OAIA_TRACING_ENDPOINT"],
)
# Create agents with handoffs
triage = Agent(name="Triage", instructions="Route to the right agent")
agent = Agent(name="Assistant", instructions="Help the user")
# Run - traces are captured automatically
result = Runner.run_sync(triage, "Hello!")
print(result.final_output)