OpenAI Agents SDK
cetra traces OpenAI Agents SDK runs as a tree of agent, turn, model call and tool spans.
Install
Section titled “Install”pip install "cetra-sdk[openai-agents]" openai-agentsSet up
Section titled “Set up”import cetrafrom agents import Agent, Runner, function_tool
cetra.init(instrument=["openai-agents"])
@function_tooldef get_weather(city: str) -> str: return f"It is 18 degrees and sunny in {city}."
agent = Agent( name="weather", instructions="You are a weather assistant.", tools=[get_weather],)Runner.run_sync(agent, "What is the weather in Paris?")
cetra.flush()What you get
Section titled “What you get”With the OpenInference instrumentation, one run with a function tool produces:
- an
agentspan for the workflow and one for the agent; - one
chainspan per turn; - an
llmspan for each model call, with the provider, token counts and cost; - a
toolspan for the function tool.
Limits
Section titled “Limits”- The fixtures were captured with
openai-agents0.24.0, OpenInference 2.7.0 and OpenLLMetry 0.62.4. - The SDK’s own tracing to OpenAI is a separate feature. This page covers the OpenTelemetry instrumentation.
- Traces: read the trace as a tree and a timeline.
- Cost and tokens: how cost is computed from the token counts.
- Online rules: score these traces automatically.