# 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](/answers/openai-agents-sdk-evals/how-do-i-trace-an-openai-agents-sdk-run). LangChain's LangGraph traces through LangSmith, which [can export over OTLP](/answers/langgraph-evals/how-do-i-trace-a-langgraph-agent) to any collector. Anthropic's Claude Agent SDK leaves it to the Claude Code CLI underneath, whose [trace spans are still beta](/answers/claude-agent-sdk-evals/how-do-i-trace-a-claude-agent-sdk-agent) 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](/answers/instrumentation/does-adding-instrumentation-require-code-changes) 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](/answers/instrumentation/are-genai-semantic-conventions-stable-enough-to-build-on).

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: 2026-10-18

Sources:
- OpenTelemetry semantic-conventions-genai: GenAI agent spans: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-agent-spans.md (fetched 2026-10-18)
- OpenTelemetry semantic-conventions-genai: GenAI spans: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-spans.md (fetched 2026-10-18)
- OpenTelemetry semantic-conventions-genai: Client inference: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/client-inference.md (fetched 2026-10-18)
- OpenAI Agents SDK docs: Tracing: https://openai.github.io/openai-agents-python/tracing/ (fetched 2026-10-18)
- LangChain docs: Trace with OpenTelemetry: https://docs.langchain.com/langsmith/trace-with-opentelemetry (fetched 2026-10-18)
- Claude Docs: Observability with OpenTelemetry: https://code.claude.com/docs/en/agent-sdk/observability (fetched 2026-10-18)

Source: https://tessary.ai/answers/instrumentation/how-do-i-trace-an-ai-agent
More on Instrumentation: https://tessary.ai/answers/instrumentation
From Tessary, agent reliability for AI agents in production: https://tessary.ai
