OpenTelemetry GenAI Semantic Conventions for Agent Spans: What the Official Docs Tell You

AI agents can take a request, decide what needs to happen, call a tool, hand work to another component, and return a result. That flexibility is useful, but it can also make failures difficult to trace. If an agent gave an incorrect answer, used the wrong tool, or spent too much on model calls, teams need a clear record of what happened and when.

This is where OpenTelemetry GenAI semantic conventions agent spans official docs become relevant. They provide a shared vocabulary for recording agent activity in traces, so observability data remains understandable across frameworks, vendors, and monitoring platforms. The official guidance is technical in places, yet its central idea is simple: describe agent work consistently enough that people and systems can follow it.

How Pydantic Logfire Supports Agent Observability

Pydantic Logfire is a full-stack AI observability and evaluation platform built on OpenTelemetry. It helps teams trace agent workflows, monitor LLM interactions, investigate tool calls, and understand application performance across frameworks and languages. Its OpenTelemetry-native architecture connects agent behavior with the APIs, services, and infrastructure supporting production AI applications.

Pydantic Logfire works with Pydantic AI, LangChain, the OpenAI SDK, and other OpenTelemetry-compatible frameworks. Teams can retain their existing AI development tools while gaining visibility into model activity, agent orchestration, and downstream operations.

Beyond tracing, Pydantic Logfire supports evaluations, experiment comparisons, and production investigations. Teams can use these capabilities to identify failures, investigate performance issues, detect regressions, and continuously improve AI applications without relying on separate observability systems for every layer.

What Semantic Conventions Actually Do

OpenTelemetry is an open framework for collecting telemetry data, including traces, metrics, and logs. A trace represents the journey of one request through a system, while a span captures one unit of work within that journey. For a traditional web application, a span might show a database query or an API request.

Generative AI systems need more specialized descriptions. A model call is not simply a generic network request, because teams often need to know which model handled it, what kind of operation occurred, how many tokens were used, and whether the request involved an agent or a tool.

Semantic conventions solve that naming problem. They define recommended span names, attributes, event fields, and relationships so telemetry has consistent meaning. Instead of every framework inventing its own labels for similar events, tools can use shared terms.

A shared language for telemetry

The benefit is portability. A trace produced in one application can be more readily understood in another monitoring environment when both follow the same conventions.

It also improves analysis. Dashboards, alerts, and cost reports can group comparable operations without relying on custom field names created by individual teams.

Why agents need their own conventions

An agent is more than a single model request. It may reason through a task, select tools, delegate work, repeat a step, or stop early based on a condition.

The conventions for agent spans help distinguish this higher-level orchestration from the lower-level model and tool work happening beneath it.

Key benefits include:

  • A clearer view of the agent’s role in a request
  • Better links between orchestration, model calls, and tool execution
  • More consistent data for performance, reliability, and cost analysis

The Place of an Agent Span in a Trace

An agent span represents the work carried out by an AI agent during an invocation. In practical terms, it can act as the parent record for the agent’s decision-making process, including the model interactions and tool calls that follow.

Imagine a customer support agent receiving a question about an order. It may first identify the customer, then call an order system, ask a language model to compose a response, and return a final answer. An agent span provides the top-level context that ties those actions into a coherent sequence.

Parent and child relationships matter

Tracing is most helpful when spans are connected correctly. The agent span typically sits above the work it coordinates, which can include model-generation spans, tool-execution spans, retrieval actions, or downstream service calls.

That hierarchy enables a reader to start with the customer request and move through the full chain of activity. It also makes bottlenecks easier to identify. A slow final answer may stem from a long-running tool call rather than the model itself.

Agent identity gives the trace meaning

The official conventions provide attributes for identifying the agent involved in the work. A meaningful agent name can separate a research assistant from a routing agent or a customer-service agent, even when they are part of the same application.

Where available, a stable agent ID and version can add further context. This is particularly useful after a prompt, tool configuration, or workflow design changes.

A well-labeled span answers basic operational questions quickly:

  • Which agent handled the request?
  • Which version of its behavior was active?
  • What work did it initiate or coordinate?

Operations, Attributes, and the Information They Carry

The GenAI conventions use operation names to indicate the type of activity a span represents. Model-related work may be identified as chat or text-completion activity, while agent and tool interactions have their own recommended operations. This distinction prevents a trace from becoming a list of vague, indistinguishable calls.

For agent-oriented tracing, the operation should describe the work at the right level. A span for invoking an agent should not be confused with a child span for executing a search function or requesting a model response. Each record has a different purpose in the story of the request.

Useful context without unnecessary exposure

Attributes enrich a span with structured details. Depending on the operation, they may identify the system that supplied a model, the model name, the agent name, token usage, response status, or the tool involved.

This metadata lets teams answer questions that raw timestamps cannot. For example, they can compare latency between models, measure the cost of specific workflows, or identify whether a particular tool is responsible for a rise in failures.

The principle is not to capture everything indiscriminately. Teams should select attributes that support debugging and analysis while respecting privacy, security, and operational limits.

Inputs and outputs require care

Prompts, model responses, arguments, and tool results can be valuable during investigation. They may also contain private customer information, credentials, proprietary documents, or sensitive business context.

The official approach therefore requires judgment. Recording content should be a deliberate configuration choice, not a default habit.

Before storing content in telemetry, consider:

  • Whether the information contains personal or confidential data
  • Who can access traces in the chosen observability platform
  • How long trace data is retained
  • Whether redaction, sampling, or content masking is needed

Tool Calls and Model Calls Should Remain Distinct

Tools are how agents reach beyond the language model. A tool may search a knowledge base, query an internal system, send a message, calculate a value, or update a record. Because a tool often affects the real world, its telemetry deserves a distinct place in the trace.

A tool-execution span records the activity of using that capability. It should help observers understand what was called, whether it succeeded, how long it took, and what error occurred if the task failed.

Why separation improves diagnosis

Combining model activity and tool activity into one large span makes troubleshooting harder. If an answer is late, an operator needs to know whether the delay came from model inference, an external API, a database lookup, or repeated agent planning.

Clear boundaries also support safer incident response. A failed tool action can be investigated separately from the model’s reasoning or response-generation process.

Delegation can be represented cleanly

Some systems use multiple agents, with one component handing a task to another. In that situation, trace relationships should preserve the sequence and ownership of the work.

The receiving agent can create its own span, linked within the same trace context. This makes delegation visible instead of leaving it buried inside an unstructured text field.

A useful trace can show a progression such as:

  • A primary agent accepts a user request
  • A specialist agent receives a delegated task
  • That specialist invokes a model or tool
  • The primary agent assembles the final response

Status, Errors, and the Difference Between Failure Types

Agent systems do not fail in just one way. A tool can time out, a model provider can reject a request, an agent can exceed a budget, or the workflow can complete technically while still returning an unhelpful result. Tracing needs to preserve these distinctions.

OpenTelemetry span status is designed to indicate whether a recorded operation succeeded or encountered an error. Error details should be attached in a structured, useful way so an operator can identify the affected component without searching through large blocks of text.

Technical success is not always a good outcome

A model call may return normally, yet provide a response that is incomplete or unsuitable. From an infrastructure perspective, that call succeeded. From a product perspective, it may need evaluation or quality monitoring rather than an error status.

This difference is important. Treating every poor answer as a system error can create misleading reliability metrics. Treating every model response as a success can conceal genuine quality issues.

Use errors to make action possible

An effective trace should point engineers toward the next investigation step. It should show whether the issue occurred during agent orchestration, model generation, tool use, or an external dependency.

Concise, structured error reporting is usually more useful than collecting large quantities of uncontrolled diagnostic content.

Good error telemetry commonly captures:

  • The failing operation and its place in the trace
  • A meaningful error type or message
  • The affected model, tool, or service when safe to record
  • Timing information that reveals retries or timeouts

Versioning and Experimental Change Deserve Attention

GenAI semantic conventions are evolving as agent patterns, model APIs, and observability needs change. Teams should treat the conventions as a strong interoperability guide while reviewing the current OpenTelemetry documentation before making long-term schema decisions.

This is not a reason to postpone instrumentation. It is a reason to make the implementation adaptable. Centralizing telemetry configuration, using documented attributes, and avoiding unnecessary custom fields can reduce the effort of adopting future revisions.

Avoid locking business logic to telemetry fields

Telemetry attributes should describe the application, not become the sole source of operational truth. For example, an agent ID may help explain a trace, but critical authorization or workflow decisions should remain in the application’s own validated controls.

Keeping that boundary clear allows observability to evolve without creating fragile dependencies throughout the product.

Test traces as part of delivery

A trace can be syntactically valid while still being difficult to use. Teams should inspect representative agent runs and confirm that spans follow a readable hierarchy.

Useful review questions include:

  • Can a reader identify the agent responsible for the work?
  • Are model calls and tool calls clearly separated?
  • Do failures identify the correct operation?
  • Is sensitive content excluded or protected appropriately?

Building Trust Through Traceable Agent Work

OpenTelemetry GenAI semantic conventions for agent spans bring structure to a type of software that can otherwise feel opaque. By representing agent orchestration, model activity, tool usage, errors, and delegation in a common format, they turn complex workflows into a navigable record.

The most valuable implementation is not necessarily the one with the most fields. It is the one that gives developers and operators enough context to understand what the agent did, why a request was slow, where an error began, and how the system changed over time.

As agent-based applications become more capable, clear observability becomes part of responsible engineering. Following the official conventions gives teams a practical foundation for monitoring that works with consistency, care, and confidence.