Evaluating AI Agents: From Metrics to an Engineering System
This article outlines a systematic approach to evaluating AI agents, covering the core evaluation model, three types of scorers, scenario-specific evaluation design, a roadmap for building an evaluation system from scratch, stability metrics like pass@k and pass^k, and a multi-layered quality assurance framework for production-ready agent development.
Evaluating AI Agents: From Metrics to an Engineering System
The key difference between AI agents and early large language model applications lies in their continuous decision-making: agents call tools, read and write environment states, adjust strategies based on intermediate results, and complete goals through multi-turn interactions. This autonomy improves task completion capabilities but also elevates quality assessment from “checking a single output” to “verifying an entire execution trajectory and the final environment state.” Without systematic evaluation, teams often discover problems only in production, and fixing one bug can introduce new regressions, creating a reactive cycle. The value of evaluation is to expose issues before they affect users and to make every change—whether to models, prompts, tools, or strategies—measurable, comparable, and auditable.
The Basic Evaluation Model: Input, Trajectory, State, and Scorer
The core of automated evaluation can be abstracted into four components: task input, agent execution, environment outcome, and scoring logic. Task input includes not only the user prompt but also the tool list, initial environment, constraints, and success criteria. Agent execution may be a single round or multiple rounds of tool calls and reasoning. Environment outcomes include the final answer as well as file changes, database states, UI states, and tool invocation logs. Scoring logic selects code assertions, model-based grading, or human review depending on the task type.
Single-turn evaluation is simpler: given a prompt, produce an output, and let the scorer judge whether it meets expectations. Multi-turn evaluation is closer to real agent usage: it requires providing the agent with a reproducible environment, tool interfaces, and task instructions, recording the full trajectory, and checking the environment’s final state. For coding tasks, for example, one can check code diffs, unit tests, and static analysis; for operation-style tasks, one can check the final UI state and key action sequences. The first principle of evaluation design is that success criteria must be observable, reproducible, and interpretable—not just “looks good.”
Three Types of Scorers: Code-Based, Model-Based, and Human-Based
Code-based scorers suit tasks with deterministic outcomes, including unit tests, assertions, pattern matching, state snapshot comparisons, and tool call count limits. They are low-cost, fast, and repeatable, making them the mainstay of regression testing. However, they have limited coverage for open-ended tasks and may reward “passing tests” rather than truly solving problems, so they need to be combined with other scorers.
Model-based scorers typically use scoring rubrics or rating scales to judge factual accuracy, completeness, relevance, tone, safety, and other aspects of a response. They fit open-ended conversations, research reports, and complex explanation tasks. But model scorers can exhibit preference bias, position bias, and scale drift. They must be calibrated against human-annotated samples and periodically audited for consistency. Scoring rubrics should be specific enough to be decided on individual dimensions, avoiding vague criteria like “overall quality is good.”
Human-based scorers are used for high-risk, subjective, or tasks that are difficult for models to judge, such as domain-specific correctness, user experience, compliance, and policy adherence. Human review is expensive and not suitable for full-scale execution, but it can serve as the golden standard to calibrate automated scorers, as well as for sampling audits and re-evaluation of difficult cases.
In practice, a combined scoring approach is recommended: code-based scorers handle hard constraints and verifiable results, model-based scorers cover open-ended quality dimensions, and human-based scorers calibrate and provide fallback for high-risk cases. The weights of the three scorer types should be adjusted dynamically according to task risk.
Designing Evaluation Scenarios by Use Case
Coding agents should be evaluated on whether the final code is correct, passes tests, introduces no regressions, and follows engineering standards. Task sets can include bug fixes, feature implementation, refactoring, and test generation. Scorers can be composed of unit tests, static checks, diff scope inspections, and model reviews. The environment must be reproducible and not depend on unstable external services.
Conversational agents need evaluation of multi-turn task completion rates, factual consistency, context retention, correct tool invocation, safety compliance, and user experience. Scoring should look at both the final answer and intermediate behavior—whether key information was missed, or whether tools were called when they shouldn’t have been. For customer service or transaction-like scenarios, policy constraints and permission checks should also be included.
Research agents should be evaluated on information coverage, evidence chain completeness, verifiability of citations, consistency between conclusions and evidence, and the absence of fabricated information. Scorers can check whether key facts appear, whether sources are traceable, and whether the reasoning chain is self-consistent. For open-ended research tasks, a combination of model scoring and human sampling is more reliable.
Computer-operation agents (e.g., GUI automation) should be evaluated on whether the action sequence is safe, whether the final state achieves the goal, and how well the agent recovers from anomalies. The evaluation environment should provide state snapshots and re-playable logs. Scorers check key UI states, file states, operation steps, and error handling. These tasks are prone to environment instability, so it is essential to distinguish “agent failure” from “environment failure.”
A Roadmap for Building an Evaluation System from Scratch
The first step is to clarify task boundaries and success criteria. Break down business goals into decidable dimensions, separating hard constraints from soft quality aspects. The second step is to build a representative task set covering common paths, edge cases, difficult examples, and adversarial samples, with versioned management of the task set. The third step is to set up a reproducible environment, fixing initial states, tool behaviors, and dependency versions. The fourth step is to compose scorers: start with code-based scorers to establish a baseline, then introduce model-based scorers for open-ended dimensions, and finally use human calibration. The fifth step is to integrate evaluation into continuous integration (CI) to act as a change gate. The sixth step is to establish metric dashboards, failure attribution, and regression governance processes.
The evaluation set is not a one-time asset but an evolving engineering artifact. Every production incident, user feedback, and human review finding should be converted into new evaluation tasks. At the same time, the size and runtime cost of the evaluation set must be controlled. A layered strategy works well: a fast smoke set for every commit, a full set for pre-release, and a hard-case set for targeted improvement.
Measuring Stability with pass@k and pass^k
pass@k measures the probability that at least one of k independent attempts on the same task succeeds. It reflects the agent’s upper-bound capability in the exploration space. pass^k is stricter: it requires all k attempts to succeed, making it suitable for measuring stability and consistency. For production systems, a high pass@k but low pass^k means the agent “occasionally works” but cannot be relied upon. The following is illustrative code:
from math import combdef pass_at_k(success_count, trial_count, k):# Empirical estimate: probability of at least one success in k trialsif trial_count - success_count < k:return 1.0# Approximate using combinations; adjust based on sample sizereturn 1.0 - comb(trial_count - success_count, k) / comb(trial_count, k)def pass_pow_k(results, k):# Count a task as stable success only if all k attempts succeedstable = 0for task_results in results:if len(task_results) >= k and all(task_results[:k]):stable += 1return stable / len(results)
Metrics must match task risk. For creative or exploratory tasks, pass@k can be the focus; for transactional or code-fix tasks, pass^k should also be tracked. Additionally, record the distribution of failure types, average number of turns, tool call error rates, and human review pass rates to avoid a single metric masking systemic issues.
A Multi-Layered Quality Assurance System
Offline evaluation is the foundation for rapid iteration during development. CI gates prevent obvious regressions. Production monitoring detects distribution drift, tool anomalies, and rising failure rates. A/B testing compares policy changes on real-user metrics. Human review provides fallback for high-risk scenarios and calibrates automated scorers. The key to a multi-layered system is the closed loop: production problems are added to the evaluation set, evaluation failures trigger attribution, fixes are verified through regression, and then changes are gradually rolled out.
Evaluation-driven agent development is not about chasing a high score. It is about building an interpretable, reproducible, and sustainable quality feedback mechanism. Only by treating evaluation as engineering infrastructure can a team confidently release agents and maintain reliability as models and tools continue to evolve.
