Learn › AI Agents: Building & Production › Evaluation and Observability

Evaluation and Observability

Intermediate 🕐 13 min Lesson 4 of 7
What you'll learn
  • Explain why agents require different evaluation approaches than traditional software
  • Describe what a trace is and what information it captures
  • Name the five key metrics for production agent monitoring

Why Agents Are Hard to Evaluate

Traditional software is deterministic — the same input produces the same output, and you can write unit tests to verify it. Agents are non-deterministic: the same goal can produce different tool call sequences, different intermediate steps, and sometimes different final outputs. Standard testing approaches don't transfer directly.

Evaluation for agents has to operate at two levels: tracing (what did the agent do?) and scoring (did it do the right thing?).

Tracing: The Foundation

Tracing records every operation in the agent loop as a structured span: the input, the output, the tool called, the arguments, the result, the latency, and the token count. A complete trace is a tree of spans — one root span for the full run, with child spans for each step.

Tracing is the minimum observability requirement for any agent in production. Without it, when something goes wrong you have no way to know which step failed, what the agent was trying to do, or whether the problem was in the model's reasoning or in a tool's output.

The OpenTelemetry (OTEL) standard is increasingly used for agent tracing, which means you can route traces to different backends without rewriting instrumentation.

Key Metrics

Beyond raw traces, teams track a core set of metrics in production:

  • Task completion rate — what fraction of runs successfully complete the goal
  • Steps per task — how many loop iterations the agent needs on average; rising step counts can signal reasoning degradation
  • Tool error rate — how often tool calls return errors; a spike here often means a downstream service changed
  • Latency and cost per run — total wall-clock time and total token spend per completed task
  • Human escalation rate — in supervised deployments, how often the agent defers to a human

Evaluation: Offline and Online

Evaluation happens in two modes:

  • Offline evaluation — before deployment, running the agent against a test suite of scenarios with known correct outputs. This catches regressions when you change the prompt, the tools, or the model.
  • Online evaluation — in production, continuously sampling runs and scoring them (automatically or with human review). This catches issues that only appear with real user inputs and real data.

A LangChain survey of 1,340 teams in late 2025 found that 89% were running some form of agent observability in production, and quality was named the top barrier to shipping agents. The gap between experimentation and production is real, and observability is a large part of closing it.

Tools in Common Use

  • LangSmith — built for LangChain and LangGraph teams; tight integration with the framework's execution trace
  • Arize / Phoenix — OTEL-powered tracing with ML monitoring; well-suited to teams using multiple frameworks
  • Langfuse — open-source, self-hostable tracing and evaluation; popular with teams that need data residency
  • Braintrust — focused on evaluation and scoring; strong dataset management for regression testing
Key takeaways
  • Agents are non-deterministic — the same goal can produce different tool sequences; evaluation must operate at both the trace level and the scoring level
  • A trace is a tree of spans recording every step in the loop: input, output, tool called, arguments, result, latency, and token count
  • Five key production metrics: task completion rate, steps per task, tool error rate, latency/cost per run, and human escalation rate
  • Offline evaluation catches regressions before deploy; online evaluation catches issues that only appear with real users — teams need both
Learn more every week Get 5 hand-picked prompts + new AI tools every Monday. Free.