Observability for LLM apps and AI agents
Traces show where an AI agent spends its time, spans show why a step went wrong, and evals show whether the answer was any good.
Observability for LLM applications and AI agents shouldn’t be a black box. There are many ways to improve AI agents, whether it is fine-tuning the model, improving the harness by chaining different tools or changing the model for the specific use case.
Observability allows you to peek inside an agent/workflow and improve 4 metrics: Latency, Uptime, Response Quality & Drift.
Without it, every one of those improvements is a guess.
Here’s a story that shows why. In August 2025, Claude started giving worse answers to some of its users. A routing bug sent some Claude Sonnet 4 requests to servers configured for the wrong context window. At the worst hour, on August 31, it hit 16% of Sonnet 4 requests (Anthropic, 2025). Two more bugs landed in the same weeks, one of which slipped Thai and Chinese characters into English answers.
Anthropic, the company that trains the model, didn’t catch it from the inside. In their own words: “The evaluations we ran simply didn’t capture the degradation users were reporting.” Their fix was more observability, with more sensitive evals that they now run “continuously on true production systems.”
If it can happen to the people who build the model, it can happen to your support agent.
Observability for an agent comes down to three tools. Traces tell you where the time went. Spans tell you why a step behaved the way it did. Evals tell you whether the answer was any good. Each one covers a gap the other two leave open.
Let’s get to it.
TL;DR
- A trace is the full record of one request: every LLM call, retrieval and tool call your agent made, nested as a tree. Use it to find the slow or failing step.
- A span is one step inside that trace, with its timing, status, model and token counts. Use it to find why a step went wrong, which is often a step upstream of it.
- An eval is a dataset, a task and a scorer. Score with code where you can, with an LLM judge where you must, and with humans to keep the judge honest.
- Together they cover four metrics. Latency and uptime show up in traces. Response quality shows up in evals. Drift shows up when you run those evals on production traffic over time.
- Start small. Trace every request, read real traces, and turn every failure you find into a dataset row.
Traces
Tracing helps you understand performance bottlenecks. Every request to the LLM, and every tool it uses, becomes a tree of nested spans: LLM calls, retrieval, tool calls and so on.
OpenTelemetry, the open standard most tracing tools build on, puts it simply: “Traces give us the big picture of what happens when a request is made to an application.” Each step records which step called it, so the whole request forms a tree. The step at the top, the root, spans the entire request.
Let’s make it concrete.
You run support at Snoozy, an online mattress company with a 100-night trial. You ship a support agent, and a customer asks: “Can I return my mattress after 120 nights?”
To answer, the agent does five things:
- Plans its approach with an LLM call.
- Retrieves the returns policy.
- Looks up the customer’s order through your order API.
- Writes the answer with a second LLM call.
- Runs a guardrail that checks the answer for personal data.
The customer waits 8.4 seconds. The support lead pings you: “the bot is slow.” Your instinct is to switch to a faster model or trim the prompt.
Then you open the trace.
The order lookup took 4.8 of the 8.4 seconds. Both LLM calls together took 2.9. A faster model might save you a second. Caching orders or fixing the slow API saves more than half the wait.
A trace stops you from optimizing the wrong step.
The span names in the drawing follow OpenTelemetry’s semantic conventions for generative AI, which name spans after the operation: chat for a model call, execute_tool plus the tool’s name, invoke_agent plus the agent’s name. The conventions are still marked “Development” as of October 2026, so names can change. Instrumenting against an open standard still means your traces aren’t locked into one vendor’s dashboard.
Traces catch uptime problems too. When a model provider goes down, its spans fail with an error status, and you know in seconds that it isn’t your code. On December 11, 2024, OpenAI’s API, ChatGPT and Sora were down for about four hours and 22 minutes (OpenAI, 2024). The cause, in OpenAI’s words, was “a new telemetry service configuration that unexpectedly generated massive Kubernetes API load across large clusters.”
The tool meant to watch the system took the system down. Classic.
Traces tell you where the problem is. They don’t tell you why.
Spans
A span is a detailed view of a specific call in the trace, allowing us to dive deeper and understand the metrics for each call and how it affects upstream and downstream spans or calls.
Every span carries the same core fields: a name, the span that called it (its parent), start and end times, a status, and attributes, which are key-value pairs describing the work. LLM spans add the model name and token counts. If you choose to, they can also hold the full prompt and completion.
Back to Snoozy. You fixed the order lookup, and the agent is fast now. Then a new complaint lands: the agent told the 120-night customer, “Yes, you can return it.” Snoozy’s trial is 100 nights.
The trace looks healthy. Every span says OK, and the timing is fine. So you open the span that wrote the answer.
Two things stand out. The status is OK, which only means the call didn’t crash. And the model read 31,412 input tokens to answer a one-line question.
That number sends you upstream. The retrieval span returned two versions of the returns policy: the current one with 100 nights, and an archived one from 2023 with 180. The model picked the old one. Downstream, the guardrail only checks for personal data, so the wrong answer sailed through.
The span where a bug shows up is rarely the span where it starts.
These are the fields I’d put on every span, because they’re the ones that answer “why”:
- Model and prompt version. Without these, you can’t tell whether a change in behavior came from a model swap or from a prompt edit.
- Input and output tokens. They tell you about cost, and they’re the fastest tell for stuffed or missing context.
- Duration, plus time to first token for streamed answers. OpenTelemetry defines a
gen_ai.server.time_to_first_tokenmetric for it. For a chat UI, that first token is the latency a user actually feels. - Tool names and arguments. A wrong argument looks the same as a wrong answer until you see it.
- IDs of retrieved documents. This is how you’d spot the 2023 policy in one glance.
Capturing full prompts and completions is a trade-off. It makes debugging much easier, and it also means storing customer data. Anthropic’s postmortem names this exact tension: its privacy controls limited how much its engineers could examine the problematic interactions they needed to reproduce the bugs. If you capture content, redact it and set a retention window.
Status OK means the call didn’t crash. It doesn’t mean the answer was right. For that, you need evals.
Evals
An eval contains three components: a dataset, task and a scorer. There are three approaches to scoring a response: deterministic, LLM-as-a-judge and human review.
Braintrust’s intro to evals has the clearest breakdown I’ve read:
- Dataset: the inputs you test against, ideally real questions from real users. You don’t need many to start: “Five to ten examples representing your main persona is enough to get started.”
- Task: the thing being tested. It can be a single prompt, a chain of prompts or the whole agent. The only requirement is that it “takes an input and produces an output.”
- Scorer: a function that grades the output on a scale from 0 to 1. Each scorer should measure one thing.
For Snoozy, the first dataset row writes itself: “Can I return my mattress after 120 nights?” The expected answer says no and points to the 100-night trial.
Each scoring approach has a different job. Anthropic’s guide to evals for AI agents lays out the trade-offs:
| Approach | Good at | Weak at | A Snoozy scorer |
|---|---|---|---|
| Deterministic (code) | Fast, cheap, objective, reproducible | Brittle with valid answers worded differently, no nuance | Does the answer say “100 nights”? Did the agent call lookup_order? |
| LLM-as-a-judge | Nuance and open-ended answers | Non-deterministic, costs more, needs checking against humans | Did the agent decline politely without promising an exception? |
| Human review | The gold standard for quality | Slow and expensive | Your support lead grades 50 conversations a week |
💡 Start with code. If a check can be a string match, a regex or a lookup against your own data, write it as code. It’s free to run on every commit and never disagrees with itself.
💡 Use an LLM judge for what code can’t see, then check the judge. Judges hold up better than you might expect. In the 2023 MT-Bench study, GPT-4 as a judge agreed with human preferences over 80% of the time, the same rate at which humans agreed with each other (Zheng et al., 2023). The same paper found judges favor answers by position, favor longer answers, and favor their own outputs. Hamel Husain and Shreya Shankar recommend validating each judge against human labels and tracking how often it catches real failures and how often it raises false alarms (LLM Evals FAQ, 2026). They also prefer pass or fail over 1 to 5 scales: “Binary evaluations force clearer thinking and more consistent labeling.”
💡 Keep humans in the loop. You often don’t know what “good” means until you’ve graded a pile of bad answers. Shankar and co-authors call this “criteria drift”: grading outputs changes the criteria you grade them by (Shankar et al., 2024). Anthropic’s version: “You won’t know if your graders are working well unless you read the transcripts and grades from many trials.”
Agents add one more twist. Run the same question three times and you can get three different paths. Anthropic separates two metrics here. pass@k is the chance an agent gets it right at least once in k tries. pass^k is the chance it gets it right every time. An agent that succeeds 75% of the time per try passes all three of three tries only about 42% of the time.
For a support agent, pass^k is the number that matters. Your customers don’t get a best-of-three.
Finally, set the bar high. As Braintrust puts it: “If you’re passing 100% of your evals, you’re not setting the bar high enough.”
An eval is only as good as its dataset, and the best dataset is the failures your users already found.
The Trifecta
Traces, spans and evals aren’t three separate tools. They’re one loop, and together they cover the four metrics from the top of this post:
| Metric | The question | Where it shows up |
|---|---|---|
| Latency | How long did the user wait, and which step made them wait? | Traces, plus time to first token for streamed answers |
| Uptime | Did the agent answer at all? | Traces, as error spans grouped by provider and tool |
| Response quality | Was the answer right? | Evals, offline on your dataset and online on sampled production traces |
| Drift | Is it getting worse while nobody changed anything? | The same evals, run on production traffic over time |
Drift is the sneaky one, because your code didn’t change. The model under it did. In a widely cited study, GPT-4 identified prime numbers correctly 84% of the time in March 2023 and 51% of the time in June 2023 (Chen, Zaharia and Zou, 2023). The authors’ conclusion: “the behavior of the ‘same’ LLM service can change substantially in a relatively short amount of time.”
Your users drift too. Snoozy launches a pillow, and the agent starts getting pillow questions it was never tested on. The only way to see either kind of drift is to keep scoring real traffic.
Here’s the loop, in order:
- Trace every request in production.
- Read the traces. Husain and Shankar suggest reviewing around 100 diverse traces and noting what went wrong in each, and stopping once new traces stop revealing new kinds of failure.
- Open the spans on the failures to find where each one started.
- Turn each failure into a dataset row with the behavior you expected.
- Fix it, and run your evals before you ship. Block the release if scores drop.
- Run the same evals on a sample of production traces to catch drift.
This is what Anthropic changed after its postmortem: quality evals running continuously on production systems, not only before release.
The fair objection is that this sounds like a lot of work for a chatbot. It is real work. Husain and Shankar write that “we’ve spent 60-80% of our development time on error analysis and evaluation.” But you don’t need it all on day one. Five real examples, one scorer and tracing on every request will catch more than any generic “helpfulness” score. On those, Husain and Shankar don’t hedge: “Generic evaluations waste time and create false confidence when you use them as quality measures.”
Traces tell you where. Spans tell you why. Evals tell you whether the fix worked.
An agent you can’t see into is a demo. An agent you can trace, inspect and grade is a product.
Frequently asked questions
What is the difference between a trace and a span in LLM observability?
A trace is the full record of one request to an LLM application, from the moment the user asks to the final answer. A span is one step inside that trace, such as a single model call, a retrieval or a tool call, with its own timing, status and metadata. Spans nest under each other, so a trace forms a tree with the agent run at the root.
What should you record on an LLM span?
At minimum, record the model name, input and output token counts, duration, status and, for tool calls, the tool name and arguments. Adding the prompt version and the IDs of any retrieved documents makes root causes much easier to find. Capturing full prompts and completions helps debugging but stores customer data, so pair it with redaction and a retention policy.
How many examples do you need to start running LLM evals?
Five to ten real examples and one scorer are enough to start, according to Braintrust. Grow the dataset by adding every failure you find in production as a new row with the expected behavior. A dataset built from real failures is worth more than a large generic benchmark.
Is LLM-as-a-judge reliable?
It can be. In the 2023 MT-Bench study, GPT-4 as a judge agreed with human preferences over 80% of the time, the same rate at which humans agreed with each other. Judges also show position, verbosity and self-enhancement biases, so check every judge against human labels before trusting it, and prefer pass or fail verdicts over 1 to 5 scales.
What is drift in an LLM application?
Drift is a change in an application’s behavior over time when nobody changed its code. The model provider can update or break the model, and users can start asking new kinds of questions. Catch it by running the same evals continuously on a sample of production traffic and watching the scores over time.
- LLM observability
- AI agents
- Evals
- OpenTelemetry