Skip to main content
Automatically capture agent runs, tool executions, and handoff transitions within the OpenAI Agents SDK.

Setup

import traceroot
from traceroot import Integration

traceroot.initialize(integrations=[Integration.OPENAI_AGENTS])

Usage

Once initialized, all agent runs and tool calls are captured automatically:
import asyncio
import traceroot
from traceroot import Integration
from agents import Agent, Runner, function_tool

traceroot.initialize(integrations=[Integration.OPENAI_AGENTS])


@function_tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"The weather in {city} is 72°F and sunny."


agent = Agent(
    name="Weather Assistant",
    instructions="You are a helpful weather assistant.",
    model="gpt-4o-mini",
    tools=[get_weather],
)


async def main():
    # The entire agent run is automatically traced
    result = await Runner.run(agent, "What's the weather in Tokyo?")
    print(result.final_output)


if __name__ == "__main__":
    asyncio.run(main())
    traceroot.flush()

What Gets Captured

AttributeDescription
Agent runsEach Runner.run() or Runner.run_streamed() invocation
Agent stepsIndividual turns within the agent loop
Tool callsEach tool invocation with name, input, and output
HandoffsMulti-agent transitions and handoff decisions
LLM callsRaw completion requests to OpenAI
Tokens & CostAggregated token usage and pricing
LatencyDuration per agent run and per span