AI Agent Observability and Tracing: Tokens, Paths, Regressions

AI agent observability means tracing tool calls, token spend, and release-to-release drift on OpenTelemetry spans, so a 200 status can't hide a wrong decision.

An isometric agent console wired to three tool devices, with only one cable and one tool glowing lime as the active call

Contents

Last updated on Nov 4, 2026.

An AI agent can return a 200 status, finish in normal time, and still have called the wrong tool, hallucinated an argument, or handed off bad context to the next step. Observing a single LLM call catches slow responses and token spend. It does not catch that.

Agent observability means tracing the actual chain of decisions, tool calls, and handoffs an agent made, not just whether the final response arrived and how much it cost.

Three questions come up once an agent is in production: where the tokens go, what path the agent took through its tools, and whether this release behaved differently from the last one. All three can be answered from ordinary OpenTelemetry traces and metrics, without a vendor SDK and without running an LLM judge on every request.

Public threads show teams hitting the same two costs. One Hacker News commenter comparing agent tracing tools reports a gap of a few minutes before agent traces are explorable in their tool, which rules it out if you want visibility in milliseconds.

A team behind a Show HN post for an agent release checker says the LLM judge they run is too expensive for more than a small slice of traffic, so some failures get through. Those are two practitioners’ reports, not benchmarks. They point at a delay before you can look, and a per-trace price for judging quality.

If the question is about a single model call, tokens, latency, cost, Last9’s LLM observability guide covers that layer directly. This piece is about the layer on top of it: what changes once that call is one step inside an autonomous, multi-step agent loop.

What makes agent observability different from LLM observability?

A single LLM call is a request and a response. An agent is a loop: the model decides what to do, calls a tool, reads the result, decides again, and repeats until it judges the task done. That loop is not predictable the way a normal function call is.

Unlike code with a fixed control flow, where you can trace an input through the same logic every time to find a bug, the same agent input can trigger a different sequence of tool calls, pull back different retrieved documents, and produce a different final response on separate runs. There is no single path to inspect, only the path a given run took.

That non-determinism is why status codes and latency graphs stop being reliable signals. An agent that worked correctly in a demo can start picking the wrong tool in production days later, and an AI agent monitoring setup built around uptime and response time will keep reporting a healthy 200 status the entire time.

The request succeeded. The agent still did the wrong thing. Catching that requires the reasoning and tool-call chain itself, because the outcome alone looks fine.

What should you trace in an agent run?

Four categories of spans cover most of what goes wrong in a production agent run:

Tool-call spans capture the tool name, the arguments passed to it, the return value, retry count, and duration. This is what surfaces a hallucinated argument or a silent retry loop that never shows up as an error.

Reasoning spans record the model’s plan, which action it picked, what it observed back, and what it decided next. This is what reveals plan drift, the agent abandoning its original approach mid-task, or a wrong branch taken at a decision point.

State and handoff spans capture the context before and after each step, and the payload passed at a sub-agent handoff. This matters most in multi-agent systems, where a second agent operates on the first agent’s output and has no way to know if that output was already wrong.

Memory and retrieval spans track what was queried, what came back, and how relevant or fresh it was. This is what catches a stale memory read or a retrieval that pulled the wrong entity into context.

Metrics worth tracking on top of these spans: tool selection accuracy, task completion rate, and how often a run required a retry or a human handoff. Latency and token cost still matter, but they answer “was it fast and cheap.” Tool selection accuracy and task completion answer “was it right.”

How does OpenTelemetry represent an agent trace?

OpenTelemetry’s GenAI agent span conventions, maintained in their own dedicated repository, define a specific span structure for this. The wider GenAI semantic conventions cover the model-call spans and metrics underneath.

A top-level invoke_agent span represents the full agent run. Under it, chat spans represent each individual model call, and execute_tool spans represent each tool invocation the model requests. A typical trace looks like invoke_agent → chat → execute_tool → chat → execute_tool → chat, repeating until the agent finishes.

If semantic conventions are new to you, this overview of OpenTelemetry semantic conventions explains how they work across signals.

The invoke_agent span itself carries agent-specific attributes the spec defines directly:

  • gen_ai.agent.id and gen_ai.agent.name identify which agent ran.
  • gen_ai.agent.version records which version of the agent ran. The spec marks it conditionally required when the application provides it, and it is the attribute that makes release comparisons possible.
  • gen_ai.agent.description gives, in the spec’s own words, “the free-form description of the invoked GenAI agent.”
  • gen_ai.conversation.id ties the run to a specific conversation thread, so multi-turn context can be correlated across it.

These attributes are what separate an agent trace from a plain chat trace: identity, version, and conversation continuity, on top of the model name and token count a chat span already has.

Where a model is calling tools over the Model Context Protocol, OpenTelemetry defines MCP semantic conventions that sit on top of execute_tool, carrying mcp.method.name, mcp.session.id, and a JSON-RPC request ID.

W3C Trace Context propagation links the MCP server’s spans as children of the client’s spans. That keeps a tool call traceable end to end even when the tool itself runs as a separate service. For the server side, including why a failed tool call can come back as a successful response, see our guide to MCP server monitoring.

The agent-span model is marked development status in the specification itself, meaning the overall shape is stabilizing but individual attribute names can still change. Check the current spec before you build dashboards or alerts on these exact field names.

A waterfall diagram of one agent run: a top-level invoke_agent span nesting five alternating child spans, three chat and two execute_tool, with the invoke_agent span's agent id, agent name, agent version, and conversation id attributes called out below it.
Durations are illustrative. The agent-span model is in development status, so attribute names can still change.

How do you track token usage for an AI agent?

Count tokens where the agent runs, and group them by the things you make decisions about: the model, the agent, and later the release. A single total per endpoint hides the interesting part. One agent that loops through five tool calls before answering spends several times the tokens of one that answers in two, on the same endpoint.

OpenTelemetry GenAI instrumentation gives you tokens in two places. Each model-call span can carry gen_ai.usage.input_tokens and gen_ai.usage.output_tokens, which the spec marks as recommended. The same counts also arrive as metrics, so you can chart spend without scanning traces.

In Last9, Agents Monitoring is backed by those GenAI metrics: gen_ai_client_token_usage_total for tokens, and the gen_ai_client_operation_duration_seconds histogram for request counts and latency, with gen_ai_request_model and error.type labels. The same series are queryable with PromQL in dashboards, alerts, and ad-hoc queries. Two starting points:

# Tokens consumed per model over the last day
sum by (gen_ai_request_model) (
increase(gen_ai_client_token_usage_total[1d])
)
# p95 model-call latency per model
histogram_quantile(0.95,
sum by (le, gen_ai_request_model) (
rate(gen_ai_client_operation_duration_seconds_bucket[5m])
)
)

Per-model is what the documented labels give you. Splitting by agent or by release needs a label or span attribute your instrumentation emits. Open the series in Metrics Explorer and read the label set before you write a query that depends on one. Last9’s docs do not describe a release filter in the Agents Monitoring view, so the release sections below use PromQL and span-derived metrics instead.

If you want cost rolled up per workflow rather than per call, the Python last9-genai SDK adds workflow tracking and cost tracking on top of standard OpenTelemetry. The launch post walks through the conversation model.

How do you read a decision path from a span tree?

The decision path is the order in which the agent called its tools, how many times it retried, and how many model calls it needed to finish. All of it is already in the span tree, because each execute_tool span is a child of the invoke_agent run that triggered it.

Three things are worth reading off a single trace:

  • Tool order. execute_tool search_orders then execute_tool refund_customer is a different decision from execute_tool check_order_status first, even when both end in a 200.
  • Retries. The same gen_ai.tool.name appearing three times in a row under one run is a retry loop. Nothing throws, so only the tree shows it.
  • Step count. The number of chat and execute_tool children is how much work the agent did. A run that doubles its step count after a prompt change did something different.

Tool arguments and results are the part that needs a decision. The spec marks gen_ai.tool.call.arguments and gen_ai.tool.call.result as opt-in and warns that both may contain sensitive information. Recording them is how you find a hallucinated argument, and it is also how customer data ends up in your telemetry. If you turn them on, redact sensitive data in the Collector before it is stored. For deciding what should never reach a transcript in the first place, see our guide to LLM security for coding agents.

Reading one trace answers “what did this run do.” It does not answer “is this release doing something new across thousands of runs.” That takes aggregation, which is the next section.

How do you catch release regressions without an LLM judge?

The idea is to split the work in two. Cheap, deterministic checks run on every trace and compare the new release with the previous one. Only the traces those checks flag go to an LLM judge or a person. The judge’s per-trace price then applies to a small slice that you chose on purpose, instead of a random sample that misses most failures.

A three-stage funnel: deterministic checks on every trace compared with the previous release, a narrower stage of flagged traces that drifted from baseline, and a final stage where an LLM judge or human reviews only the flagged traces.
Stage widths show the idea, not measured volumes. Deterministic checks cost a query per trace, so they can run on all traffic.

The signals that work are the ones a trace already carries:

  • Tool-call sequence. A new ordering of tools, or a tool that stopped being called at all.
  • Steps per run. The count of chat and execute_tool spans under one invoke_agent.
  • Retries. The same failing call repeated within one run.
  • Tokens per run. Input and output tokens summed across the run’s model calls.
  • Duration per run. The wall-clock length of the invoke_agent span.

The Show HN project mentioned above uses the same family of signals, including tool calls per turn, retries of the same failing call, loops, output length and cost per turn, and says that dropping the LLM judge makes the check cheap enough to run on all traffic. Its authors are also direct about the cost: it cannot tell that an answer is wrong if everything else about the turn looks the same. We come back to that limit below.

Tag every span with a release

A comparison needs to know which release produced each run. Set it once as a resource attribute, so it lands on every span the process emits:

export OTEL_RESOURCE_ATTRIBUTES="service.name=support-agent,service.version=2026.11.3,deployment.environment.name=production"

service.version is a resource attribute, so it sits on chat and execute_tool spans as well as on invoke_agent. That matters because gen_ai.agent.version is defined on the invoke_agent span only. Use gen_ai.agent.version too if your framework sets it, and rely on service.version for anything that has to be counted across child spans.

Mark the deploy

Last9’s change events API records a deployment as the last9_change_events metric, with the attributes you send as labels. Send one when a release goes out:

curl -XPUT https://app.last9.io/api/v4/organizations/{org_slug}/change_events \
--header 'Content-Type: application/json' \
--header 'X-LAST9-API-TOKEN: Bearer <LAST9_API_WRITE_TOKEN>' \
--data-raw '{
"event_name": "new_deployment",
"event_state": "start",
"attributes": {
"service_name": "support-agent",
"deployment_environment": "production",
"version": "2026.11.3"
}
}'

Set service_name to your APM service name exactly, or the event will not show as a marker on charts. It is still stored and queryable. The change events API takes deployment_environment as its attribute name, which is separate from the OpenTelemetry resource attribute above. Now the deploy is a point on the same timeline as the agent’s metrics, and you can see which side of it a drift sits on.

Turn spans into per-release metrics

The OpenTelemetry Collector’s spanmetrics connector generates call counts and duration histograms from spans. Its dimensions setting looks up a name in span attributes or resource attributes, so a release version can become a label. Our guide to converting traces to metrics with the spanmetrics connector covers the full setup. For agents, the part that matters is the dimensions:

connectors:
spanmetrics:
namespace: agent
dimensions:
- name: service.version
- name: gen_ai.operation.name
- name: gen_ai.tool.name

With that in place, the metric exposes a release label on every span type. A Prometheus-style export turns the call counter into something like agent_calls_total, with dots in label names rewritten as ”_”. Exact metric and label names depend on your exporter’s normalization, so confirm them in Metrics Explorer before you build alerts on them. Then compare steps per run across releases:

# Tool calls per agent run, by release
sum by (service_version) (
rate(agent_calls_total{gen_ai_operation_name="execute_tool"}[1h])
)
/
sum by (service_version) (
rate(agent_calls_total{gen_ai_operation_name="invoke_agent"}[1h])
)

Because gen_ai.tool.name is a dimension, you can group the same counter by tool and see which one a release started calling more. Keep dimensions to attributes with a small set of values. Tool names are fine. Conversation IDs and raw arguments would create a series per run.

Send only the flagged slice to a judge

Once a release shows drift, pull the traces behind it: the runs on the new version with more steps, a new tool order, or a token jump. That is the slice a judge or a human reads. The judge call is the same one you would run on everything, applied to far fewer traces.

Two caveats apply. First, the thresholds that mean “regression” are yours to set. A step count that is fine for a research agent is a loop for a lookup agent, and we have no universal number to give. Second, we have no ready-made per-release comparison dashboard or alert template to point you to, so the queries above are the starting point.

What does a two-release comparison look like?

Here is the shape of the output, with invented numbers so the pattern is visible. These are illustrative values, not measurements from a real system.

Signal (illustrative)Release 2026.11.2Release 2026.11.3What it suggests
Tool calls per run3.15.4The agent takes more steps to finish
Retries of one call, per 100 runs211A tool is failing and being retried
Input tokens per run4,2007,900More context carried through each step
refund_customer as first toolrarecommonThe agent changed which tool it reaches for

Read it as a set of questions, not a verdict. More tool calls and more tokens move together, which points at a loop or at extra context, and the retry row narrows it to a tool that started failing. The last row is the one a latency graph would never show. The tool-order change is a decision change, and you find it by grouping the call counter by gen_ai.tool.name and service_version.

None of these rows says the answers got worse. They say the behavior changed enough to look at. That is a smaller claim than “the release regressed,” and it is the one the data supports.

What are the real failure modes to watch for?

Beyond the wrong-tool and hallucinated-argument cases already covered, a few patterns show up repeatedly in production agent traces. Each one has a release-comparison signal you can watch without reading traces by hand.

Looping is an agent that keeps retrying a tool call or revisiting the same reasoning step without making progress toward the task. It is often invisible in aggregate metrics since each individual call still completes normally. The signal is steps per run and retries per run drifting up between releases.

Context loss across turns is an agent that correctly identifies what needs to happen early in a multi-turn interaction, then fails to apply it once the conversation moves on, because the relevant detail from turn one didn’t carry forward into the reasoning at turn four. A conversation ID on every span lets you pull the whole thread. Drift alone will not flag it, so this one needs sampled review.

Incomplete handoffs are specific to multi-agent systems: agent A finishes its part and passes a result to agent B, but the handoff payload is missing something agent B needed, and agent B has no signal that anything is wrong. It just proceeds on incomplete information.

None of these produce an error, so a check on whether the run completed without an exception misses all three. Only the reasoning and handoff spans show them.

A comparison of the same agent run viewed two ways: a dashboard showing a 200 status, normal latency, and zero errors, against the agent's own trace showing it selected the wrong tool and passed a hallucinated argument, so the run completed successfully while still producing a wrong outcome.
Illustrative example. A 200 status describes whether the request completed, not whether the agent was right.

Is this different for multi-agent systems?

Yes, in one way: a single agent’s mistakes are contained to its own reasoning chain, but a multi-agent system’s mistakes propagate.

If agent A retrieves stale data and hands it to agent B, agent B’s reasoning is now built on bad input it has no way to detect, and whatever agent B produces looks locally correct in its own trace even though the whole chain is wrong.

A conversation or workflow ID that persists across the handoff is what lets you walk back from a wrong final answer to the agent-to-agent transition where the bad data entered the chain, rather than re-checking every agent in the chain one at a time. For release comparisons, give each agent its own gen_ai.agent.name so a drift in one agent isn’t averaged away across the system.

How do you add observability to an AI agent?

The span model above turns into a short rollout:

  1. Pick one agent. Start with the agent that handles the most consequential task in production, not every agent at once.
  2. Wrap each run in an invoke_agent span. Set gen_ai.agent.name, gen_ai.agent.id, gen_ai.agent.version, and gen_ai.conversation.id so runs can be grouped by agent, version, and conversation.
  3. Record model and tool calls as child spans. Use chat spans for model calls and execute_tool spans for tool calls, with the tool name and retry count on each. Record arguments and results only after deciding how to redact them.
  4. Tag the release. Set service.version as a resource attribute and send a change event when each release ships.
  5. Capture handoffs and retrievals. At every sub-agent transition, record the payload that was passed. On every memory or retrieval read, record what came back.
  6. Compare releases on cheap signals. Chart steps per run, retries, and tokens per run by release, and route the traces that drifted to review.
  7. Track correctness next to latency and cost. Add tool selection accuracy, task completion rate, and retry or human-handoff rate to the same dashboard as latency and token spend.

If your agents run on LangChain or LangGraph, this guide to LangChain observability covers the framework-specific setup.

How does Last9 fit into this?

Agents Monitoring is built on the OpenTelemetry GenAI semantic conventions, so any instrumentation that emits GenAI-convention telemetry feeds it, with no Last9-specific SDK required. It shows conversations, token usage, latency percentiles, cost, success rate, and top models, and a slow or failing call links to its full request trace: the endpoint that triggered it, retries, and downstream work. That matters when the root cause is a slow database or a failing API rather than the model.

Agents can also query Last9 over MCP to investigate incidents; our guide to AI incident response with the Last9 MCP server covers the tool calls and the context they return.

The Python last9-genai SDK is optional. It builds on the same conventions and adds conversation grouping, workflow tracking, and agent identity, with gen_ai.agent.name and gen_ai.agent.id set on each agent’s spans. Cost tracking is automatic for 20+ models, and you bring your own pricing for the rest.

If you already use Langfuse, you do not have to choose. The Langfuse SDK v3 and later is OpenTelemetry-native, so you add Last9 as a second span processor in your own OpenTelemetry setup. The Langfuse integration guide has the Python and TypeScript steps. For a wider comparison of platforms, see best AI observability tools. For coding agents specifically, see coding agent observability.

What does this approach not catch?

Drift flags that behavior changed. It does not say the new behavior is wrong. A release can take fewer steps because it got better, or because it started skipping a check. A step count that holds steady can still hide a wrong answer, which is the limit the Show HN authors name for their own tool. Evals, sampled human review, or a judge on the flagged slice are still how you decide whether a change is good.

Three more limits are worth stating:

  • Thresholds are yours. We have no measured step-count or token-drift values that indicate a regression, and a number from another system would mislead you.
  • The conventions are still moving. The agent span conventions are in development status, so attribute names can change. Pin to the spec version you built against.
  • Deterministic checks need volume. A release with a handful of runs gives noisy averages. The comparison earns its keep on agents that run often enough to show a shift.

Instrument one agent with the span types above, tag its releases, and compare the first two. You will learn what normal drift looks like in your own traces before you decide what to alert on.

FAQ

What is AI agent observability?

AI agent observability is the practice of tracing an autonomous agent’s full decision chain, including its reasoning steps, tool calls, and any handoffs to other agents, rather than only monitoring the latency, cost, and success rate of the underlying model calls. It answers whether the agent did the right thing, where standard monitoring answers only whether the request succeeded.

How is agent observability different from LLM observability?

LLM observability tracks a single model call: tokens used, latency, and response quality for that one request. Agent observability tracks the full multi-step loop an autonomous agent runs, including which tools it called, what arguments it passed, how its plan evolved across steps, and what it handed off to other agents, since an agent can complete successfully at the API level while still having made a wrong decision partway through.

How do you track token usage for an AI agent?

Record token counts where the agent runs and group them by model and by agent. With OpenTelemetry GenAI instrumentation, token counts arrive as metrics and as gen_ai.usage.input_tokens and gen_ai.usage.output_tokens span attributes. In Last9, the gen_ai_client_token_usage_total series is queryable with PromQL, for example summed by gen_ai_request_model. Per-agent and per-release splits need a label or attribute your instrumentation emits, so confirm it in Metrics Explorer first.

How can you detect agent regressions between releases without an LLM judge?

Compare each release with the previous one on signals that cost a query instead of a model call: the tool-call sequence, steps per run, retries of the same call, and tokens and duration per run. Tag spans with the release version and mark each deploy with a change event so the comparison window is clear. Then send only the traces that drifted to an LLM judge or a human. This flags that behavior changed, not that an answer is wrong.

How do you add observability to an AI agent?

Start with one production agent. Wrap each run in an OpenTelemetry invoke_agent span with the agent name, agent ID, agent version, and conversation ID. Record each model call as a child chat span and each tool call as a child execute_tool span with its name, and its arguments and result if you have decided they are safe to record. Capture the payload at every handoff and the results of every retrieval, then track tool selection accuracy and task completion rate alongside latency and cost.

What does OpenTelemetry’s invoke_agent span track?

OpenTelemetry’s invoke_agent span represents a complete agent execution and carries agent-specific attributes including gen_ai.agent.id, gen_ai.agent.name, gen_ai.agent.description, gen_ai.agent.version, and gen_ai.conversation.id. Child chat spans represent individual model calls within that run, and child execute_tool spans represent each tool the agent invokes, giving a full parent-child trace of one agent run from start to finish.

Can an AI agent fail without throwing an error?

Yes, and this is the main reason agent-specific tracing matters. An agent that selects the wrong tool, hallucinates a tool argument, loses context across conversation turns, or passes an incomplete handoff to another agent typically completes its run normally at the infrastructure level, a 200 status, normal latency, no exception. The failure only shows up in the reasoning and tool-call content itself, which standard uptime or latency monitoring never inspects.

Do I need different tracing for multi-agent systems versus a single agent?

The same span types apply, but multi-agent systems add a specific new risk: one agent’s error becomes another agent’s bad input. State and handoff spans that capture what was passed at each agent-to-agent transition, tied together with a persistent conversation or workflow ID, are what let you trace a wrong final answer back to the specific handoff where bad data entered the chain, rather than needing to inspect every agent in the pipeline individually.

Do I need a vendor SDK to send agent telemetry to Last9?

No. Last9’s Agents Monitoring view is built on the OpenTelemetry GenAI semantic conventions, and any instrumentation that emits GenAI-convention telemetry feeds it. The Python last9-genai SDK is optional. It adds conversation grouping, workflow tracking, agent identity, and cost tracking on top of standard OpenTelemetry.

Can I keep Langfuse and also send traces to Last9?

Yes. The Langfuse SDK v3 and later is OpenTelemetry-native, so you add Last9 as a second span processor in your application’s own OpenTelemetry setup. Langfuse has no dashboard toggle that forwards traces to another OTLP backend, and the setup is the same for Langfuse Cloud and self-hosted Langfuse. The Last9 Langfuse integration guide has the Python and TypeScript steps.

What are some examples of agent observability platforms?

Datadog, Splunk, and Google Cloud offer agent observability inside their broader monitoring products. Langfuse, LangSmith from LangChain, and Arize focus on LLM and agent tracing and evaluation.

Last9 fits when you want agent traces in the same place as the rest of your telemetry. Its Agents Monitoring view reads standard OpenTelemetry GenAI telemetry with no Last9-specific SDK required, and a slow or failing agent call links straight to the full request trace, including the endpoint that triggered it, retries, and downstream work. That matters when the root cause is a slow database or a failing API rather than the model.

Whichever platform you pick, check that it accepts standard OTel GenAI spans, since that decides whether you can change backends later without re-instrumenting your agents.

About the authors
Sejal Pandey

Sejal Pandey

Sejal Pandey works on content and growth at Last9, writing about observability, reliability, and SRE practices.

Last9 logo and enter key

Start observing for free. No lock-in.

OpenTelemetry · Prometheus

Just update your config. Start seeing data on Last9 in seconds.

Datadog · New Relic · Others

We've got you covered. Bring over your dashboards & alerts in one click.

Built on Open Standards

100+ integrations. OTel native, works with your existing stack.