How do I trace an AI agent?

Use the tracing your agent framework already ships and route it to a backend you control, or, if the agent is hand-built, wrap its loop with the OpenTelemetry SDK using the GenAI semantic conventions and export over OTLP. Either way, aim for one trace per user turn, with a span for every model call and tool call inside it.

OpenAI’s Agents SDK records a trace for each run out of the box but ships it to OpenAI’s own dashboard and doesn’t speak OpenTelemetry itself, so reaching another backend takes a trace processor. LangChain’s LangGraph traces through LangSmith, which can export over OTLP to any collector. Anthropic’s Claude Agent SDK leaves it to the Claude Code CLI underneath, whose trace spans are still beta as of October 2026.

For a hand-built loop, the spec names the spans: invoke_agent {gen_ai.agent.name} around the run, {gen_ai.operation.name} {gen_ai.request.model} per inference call, and execute_tool {gen_ai.tool.name} per tool call. Zero-code instrumentation can cover a supported model client; your own loop and tools need manual spans. Prompts, outputs, and tool arguments and results are all opt-in, and as of October 2026 every name here still carries OpenTelemetry’s Development stability marker.

Framework spans don’t always use those names: Claude Code emits claude_code.* spans and OpenAI’s SDK has its own span types, so a backend keyed on gen_ai.operation.name has to map them before it can compare the two.

published

sources

keep reading

More on this.

Try Tessary on Cloud.

free · 10,000 traces a month · 1 GB · 30-day retention · $10 one-time credit for triage and RCA · no credit card