https://x.com/i/article/2114758643082022912
3 building blocks (and 4 traps) for evaluating agents in production
When teams start building an agent, testing usually looks the same. You wire up a model, hand it a few tools, run three or four prompts in a terminal, and eyeball the output. If the answer looks reasonable, you ship it.
In practice, this breaks down fast. You tweak a system prompt to fix an edge case in one workflow, and suddenly the agent stops calling a required tool in another.
Worse, agents fail differently than standard software. An agent can get stuck in a retry loop, fire off multiple redundant tool calls, or hallucinate tool parameters, yet still return a polite, plausible-sounding final answer.
In production, that hidden failure is costly:
- It quietly spikes your cloud bill and token usage.
- It exhausts downstream API rate limits and quotas.
- It leaves users staring at a loading spinner.
- It can trigger duplicate side effects in external systems, all while looking "fine" on the surface.
- It erodes user trust, and first impressions are hard to win back.
You do not need an elaborate automated grading architecture on Day 0. Evaluation is a progressive journey. Any repeatable evaluation system is better than relying on ad-hoc terminal spot checks.
This is the engineering playbook behind our AI Agent Clinic episode, How to Actually Evaluate (Any) AI Agent: Beyond the Vibe Check, where we build an end-to-end evaluation pipeline for a LangGraph agent in 60 minutes using the open-source agent-eval toolkit.
By Hugo Selbie, Dani Zamora, Jesse Carah, and John DeMartino
Here is what we will cover:
- The 3 high-level building blocks: Anchoring tests in critical user journeys (CUJs), bootstrapping with simulated users (ADK user simulations), and measuring across four layers of the stack.
- The 4 common evaluation traps: Breaking your baseline by deleting failing tests, trusting fuzzy 1-to-5 LLM judge scales instead of boolean checks, ignoring the operational bill, and coupling your eval pipeline to a single agent framework.
- A practical Day 0 to Day 2 rollout: Moving from manual "red pen" trace reviews on Day 0 to automated agent-eval scorecards on Day 1 and CI/CD pull request merge gates on Day 2.
3 high-level building blocks for useful evaluations
Block 1: Define success with critical user journeys (CUJs)
Before writing test code, you need a shared vision of what a good outcome actually looks like. Anchor your tests in critical user journeys (CUJs) rather than abstract academic benchmarks.
A CUJ defines what a user expects the system to achieve, structured around their persona, goals, constraints, and verification conditions.
Every clause in that statement becomes a concrete evaluation point:
- Did the agent resolve the correct transaction ID?
- Did it check the internal ledger before drafting?
- Did it map internal IDs back to the external broker nomenclature?
Defining these expectations upfront forces product stakeholders, downstream users, and engineers to agree on how "success" is measured before anyone writes a grading rubric.
Block 2: Start with simulated users, graduate to real traffic
You do not need six months of production logs to build your initial golden dataset. Instead, break each CUJ down into concrete scenarios (both happy paths and edge cases) and feed them into a user simulator LLM such as ADK user simulations.
Primed with a persona and behavioral constraints (for example, an impatient analyst giving incomplete ticket numbers, or a developer asking a multi-part debugging question), the simulator mirrors the messy phrasing, typos, and multi-turn complexity of real users.
By testing your agent against a synthetic user and realistic scenarios, you can record comprehensive execution traces (including tool logs) prior to user interaction. This enables you to pinpoint and resolve performance gaps against your release standards. As live traffic begins to flow, you can progressively replace these synthetic setups with real production traces.
Block 3: Measure across the full stack
A single top-line score will never tell you why an agent failed. To isolate root causes, layer the following checks:
- Unit tests: Fast, deterministic code checks on individual tool functions, parsers, and prompt builders.
- Deterministic metrics: Exact assertions on tool selection, parameter schemas, latency budgets, and reference matches (computation metrics).
- LLM-as-a-judge rubrics: Strict boolean (Pass/Fail) grading on reasoning trajectories, policy compliance, and groundedness.
- End-to-end integration tests: Multi-turn scenario runs verifying state transitions and side effects across the full system.
Four common evaluation traps to avoid
Trap 1: Throwing tests out and breaking your baseline
Setting up evaluation metrics involves trial and error, and it is tempting to delete a noisy test or swap out sample queries between runs. Every time you add or remove a test, though, you invalidate your baseline and you cannot tell if a score changed because the agent got better or because the test suite moved.
How to fix it: Keep your golden dataset frozen while you tune a feature, change one variable at a time, and only retire a test when you are certain the underlying product requirement has changed.
Trap 2: Relying on fuzzy 1-to-5 judge scores instead of boolean checks
LLMs are notoriously inconsistent at grading qualitative 1-to-5 scales; the boundary between a "3" and a "4" is fuzzy and shifts from run to run.
How to fix it: Turn your judge rubrics into boolean (pass/fail) questions rather than open-ended rating scales. Rather than asking "How helpful was this answer from 1 to 5?", ask "Did the agent verify the account ID before calling the refund tool? (Yes/No)" using Adaptive Rubrics.
Trap 3: Evaluating the prose while ignoring the operational bill
A response that passes every quality check is still a production failure if it took 40 seconds, made twelve redundant tool calls, and cost sixty cents per query.
How to fix it: Always evaluate the whole system rather than just the final text. Track latency, token consumption (prompt, reasoning, and completion tokens), API cost, and tool-call counts right alongside answer quality.
Trap 4: Building a different eval pipeline for every agentic framework
Switching orchestration frameworks often forces teams to scrap and rewrite their entire testing suite. While most frameworks emit OpenTelemetry traces, they do not use the same semantic conventions for tool calls, steps, and tokens.
How to fix it: Standardize your traces around open specifications like OpenInference to decouple evaluation from your orchestration framework. The open-source agent-eval toolkit supports this natively with minimal setup across Google ADK, LangGraph, and custom runtimes.
Stand up your own evaluation pipeline: Day 0 to Day 2
You can stand up this pipeline in a couple of hours using the open-source agent-eval toolkit, which pairs OpenTelemetry trace capture with the Agent Evaluation service on the Gemini platform (formerly Vertex AI Evaluation).
Day 0: Scenarios, simulations, and the "red pen"
Start small and stay close to the raw data:
- Draft scenarios for your main CUJs and run simulations through your agent.
- Read ~20 execution traces end to end: prompts, reasoning steps, tool arguments, and final outputs.
- Grade each trace with a red pen, marking where the agent hesitated, hallucinated a parameter, picked the wrong tool, or rambled. Those notes define the exact deterministic assertions and boolean judge checks to automate next.
Day 1: Cadence, signal, and the testing framework
Next, use the agent-eval toolkit to standardize execution and establish a repeatable cadence:
- Automate trace capture and grading: Scaffold your golden dataset, run multi-turn scenarios over HTTP (--base-url) or offline, and route OpenInference traces to the Gemini Agent Evaluation service to execute deterministic checks and boolean judge rubrics.
- Run on every change: Execute the same test battery whenever you tweak a prompt, swap a model, or edit a tool docstring, comparing the delta against your baseline.
- Validate the judge against your traces: Compare automated judge scores against your Day 0 red-pen traces. If the judge passes a trace you marked in red, tighten the rubric until the automated signal matches your judgment.
The tuning loop: 50 to 60 iterations of turning knobs, not rewrites
Reaching production quality typically takes 50 to 60 small iterations of turning individual knobs—clarifying a tool parameter, adding a negative constraint, or adjusting a JSON schema—rather than rewriting the system prompt from scratch.
Once you complete each evaluation run, agent-eval generates an interactive, all-in-one HTML report pairing pass/fail boolean metrics with latency, token usage, API cost, cache utilization, and tool-call execution paths—plus automated Gemini root-cause analysis pinpointing the exact prompt directive or parameter behind failed turns. That data catches regressions when a prompt change feels smarter in spot-checking, but doubles latency or raises tool-call hallucinations by 15%. Small, measured changes beat big rewrites every time.
Day 2: Merge gates and shared dashboards
Once you trust your eval signal, turn it into a permanent regression safety net:
- CI/CD pull request gates with headless CLI: Run agent-eval headlessly in Cloud Build or GitHub Actions on every pull request to enforce two merge rules:
- A global pass threshold: The suite must meet a minimum pass bar (for example, 95% boolean success).
- Zero regressions on core evaluation metrics: The build fails if any previously passing metric regresses, preventing teams from trading a critical capability for an edge-case fix.
- Shared dashboards and centralized storage: Export run artifacts—raw trace JSONL, prompt hashes, model versions, latency profiles, and scorecards—to BigQuery or Cloud Storage to track accuracy, latency percentiles, and token budgets across releases.
When live users hit new edge cases, ambient quality agents like The Outer Loop help diagnose failing production traces and promote them back into your Day 0 golden dataset.
Try it yourself within minutes
- Watch the 60-minute live build: Check out the AI Agent Clinic episode, where we wire up this entire pipeline on a real LangGraph agent from scratch.
- Grab the open-source code: Clone the agent-eval toolkit on GitHub to scaffold datasets, collect OpenInference traces, and generate diagnostic HTML reports out of the box.
- Read another engineering guide: The Outer Loop, Insights First: An Ambient Quality Agent That Diagnoses Your Production Agent
