How to Build a Trustworthy Agent Evaluation System from Scratch
Building an evaluation system for AI agents is about far more than designing a scoring sheet. This article explains why trustworthy evaluation depends on two often-overlooked foundations—a reliable observability data pipeline and a well-designed metrics framework—walks through a real-world data duplication incident (90MB of trace files shrinking to 11MB after deduplication), and outlines a step-by-step path from reliable data capture and layered trace modeling to test case construction, scoring, and regression replay. You will also learn why safety must be treated as a veto criterion rather than an averaged dimension, and why execution traces matter more than overall scores.
When most teams set out to build an agent evaluation system, their first instinct is to design a nice-looking scorecard: accuracy, task completion rate, cost. But once you’ve actually done it, you realize that whether the results are trustworthy depends on two frequently overlooked prerequisites—a reliable data pipeline and a sound metrics design. Drawing on real lessons from production, this article walks through the complete path to building an agent evaluation system from scratch.
1. Start with Two Core Principles
Principle 1: Safety must be an independent veto criterion, not something diluted by an average score.
Agents can take real actions. A single unintended deletion, write, or data exfiltration can have serious consequences. If safety is mixed into a weighted overall score, an agent that “performs well overall” may hide high-risk behavior in critical scenarios—and the average masks that risk. The right approach is to treat safety as a pass/fail gate: any test case that crosses a safety boundary fails the evaluation outright, no matter how high the other dimensions score. Functional scores can involve trade-offs; safety red lines cannot.
Principle 2: Traces matter more than total scores.
A total score answers only one question—which version is better. When you need to know “why did this version regress?” or “which step caused this failure?”, a total score is useless. Only a complete, replayable execution trace lets you pinpoint whether the problem was a wrong tool-call parameter, a reasoning error, or context pollution. So the output of an evaluation system should not be a single number, but “score + drillable execution trace.” The trace is the basis for improvement; the score is just a ranking result.
2. The Foundation: A Reliable Observability Data Pipeline
This is the most underestimated part. The raw data evaluation depends on—what the agent did at each step, which tools it called, what the model returned—passes through multiple stages: collection, reporting, persistence, and aggregation. Skipping this step and jumping straight to scoring criteria leads to two hidden problems:
- Incomplete data: some test cases have missing execution records or incomplete fields, while coverage looks artificially high;
- Duplicate counting: the same execution is written repeatedly, distorting statistics at the source.
Neither problem throws errors or crashes. They quietly corrupt your storage and metrics, and are usually discovered only by accident—after the evaluation conclusions have already been published.
A Real-World Incident
Our own data pipeline hit a classic problem: during troubleshooting, we found that a day’s trace files on the server totaled about 90MB, but only about 11MB of valid data remained after deduplication—an 8x inflation. The postmortem revealed two compounding causes:
- Redundant conversation history storage: different downstream consumers each needed the full conversation history, so the reporting side stored the same history in two separate fields—the same data written twice;
- Incremental reporting turned into full reporting: after each completed step, the client repackaged and re-reported every completed step in the session so far. The server simply appended writes without idempotent deduplication by session and step, so early steps were written dozens of times.
The fix was fairly straightforward:
- Build a unique key from “session ID + step ID” and perform idempotency checks before writing on the server side;
- Switch to single-step incremental reporting; let the server aggregate the full history;
- Add a daily data quality inspection job that uses sampling comparisons and volume anomaly detection to catch inflation.
# A simple data quality check outline1. Count the steps per session; if the same (session_id, step_id) appearsmultiple times, trigger a deduplication alert2. Compare reported volume with deduplicated volume; flag an anomaly if theinflation ratio exceeds a threshold (e.g., 2x)3. Randomly sample N traces daily and verify the completeness of key fields
3. The Build Order: From 0 to 1
Step 1: Land the data reliably. Use a simple persistence queue to store execution data stably. The point of this step is robustness, not elegance: no data loss or duplication across process restarts, network jitter, or brief server unavailability. Get the local buffering solid first, then worry about upload and aggregation. Define the dimensions you need to collect at the same time to avoid rework later.
Step 2: Model traces in layers. A three-layer structure works well here—similar models have been proposed in industry research:
- Operation layer: who called whom, inputs and outputs, latency, error codes—answers “what happened”;
- Reasoning layer: the reasoning process and confidence at the time—answers “why it did this”;
- Context layer: external interactions such as HTTP requests, SQL executions, and vector database retrievals—answers “what it depended on”.
The reasoning layer is nested inside the operation layer, forming parent-child span relationships. The benefit is immediate: suppose an alert fires at 3 a.m. that an agent performed an unintended write. You open the trace, expand level by level down to the reasoning layer, and see the judgment directly—e.g., “the user said ‘tidy things up,’ which I interpreted as archiving to the main database”—without digging through scattered debug logs and guessing.
Step 3: Build the test case set and scoring layer. Cover four scenario categories: functional, boundary, adversarial, and safety. Split scoring into two families: rule-based scores that can be automatically judged (format, constraints, safety red lines) and quality scores that require an LLM or human judgment (reasoning soundness, result usability). Run safety cases in a separate batch—any failure is a veto.
Step 4: Replay and regression. The real value of an evaluation system lies in continuous iteration. Use the collected traces as regression inputs: before shipping a new version, replay it against historical traffic and compare behavioral differences. This dramatically reduces the risk of “fixing one thing and breaking another.”
4. Summary
The correct order for building an agent evaluation system is: first make the data pipeline complete and idempotent, then model traces in layers, and only then build the scoring system and regression mechanism. Remember two things: safety is a one-strike veto, not an ordinary item in a weighted average; the total score is for ranking, but the trace tells you what to fix next. With the right foundation in place, the scores you produce are actually trustworthy.
