Evaluating AI Agents on Long-Horizon Tasks: Metrics and Best Practices

    Single-turn Q&A benchmarks cannot capture how agents actually work. This article explains why agent evaluation should cover complete long-horizon task sessions, how to build reliable evaluation samples, and which metrics matter—including command execution reliability, steerability, net improvement rate, task completion rate, and step efficiency. It also covers how to implement blind comparisons with position-bias correction, common pitfalls in interpreting results, and practical recommendations for building regression sets and reproducible evaluation reports.

    1. Why Evaluate Agents on Long-Horizon Tasks

    Single-turn Q&A evaluation only tells you whether a model can answer one question correctly. Agents work differently. They plan steps across multiple interactions, call tools, read returned results, adjust their path when errors occur, and ultimately accomplish a well-defined goal. A single task may involve dozens of steps or more. Measuring only per-step answer accuracy cannot reveal where failures actually happen in real workflows.

    The evaluation target should therefore be the complete session from task start to finish, including intermediate tool calls, error recovery, and mid-task user interventions. The evaluation should answer three questions: Was the task ultimately completed? Was the process stable? When problems occurred, could the agent correct itself?

    2. Building Evaluation Samples

    The source of your samples directly determines how credible your conclusions are. There are three common sources:

    • Manually authored standard task sets. Inputs, outputs, and acceptance criteria are all explicit, making results easy to reproduce and compare.
    • Anonymized real user sessions. The task distribution better reflects actual needs, but privacy protection and data authorization must be handled carefully.
    • Failure cases extracted from production logs. These are well suited as regression tests to prevent fixed issues from recurring.

    Samples should also be stratified by work type, such as document processing, code development, data analysis, and everyday Q&A. Different task types demand clearly different capabilities, and aggregating them together can mask weaknesses. Each stratum also needs a sufficient number of samples. If a category has only a dozen or so samples, random variance in a single run can change the ranking, making any “improvement” conclusion unreliable.

    3. Core Metrics

    1. Command Execution Reliability

    This measures whether operations the agent initiates in a command-line environment complete as expected. A common formula is the number of successful commands divided by the total number of commands, where “success” requires an exit code of zero, no timeout, and output that meets the task’s acceptance criteria.

    1. def command_success_rate(commands):
    2. """commands: each record contains exit_code(int), timed_out(bool), and output_ok(bool)."""
    3. if not commands:
    4. return 0.0
    5. ok = sum(
    6. 1 for c in commands
    7. if c["exit_code"] == 0 and not c["timed_out"] and c["output_ok"]
    8. )
    9. return ok / len(commands)

    2. Steerability

    This measures whether the agent can accurately understand the user’s intent, revise its plan, and preserve valid progress already made when the user redirects it mid-task. During evaluation, you can inject corrective instructions at predefined checkpoints and record whether the agent returns to the correct path, along with how many extra steps the correction requires.

    3. Net Improvement Rate

    On the same batch of tasks, compare the new version against a baseline version task by task. The net improvement rate is the proportion of improved tasks minus the proportion of regressed tasks. It reflects the net gain of the new version and is more informative than simply comparing average scores. Averages can be inflated by a few high-scoring tasks, while the net improvement rate directly shows how many tasks got better and how many got worse.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class TaskResult:
    4. task_id: str
    5. baseline_score: float
    6. candidate_score: float
    7. def net_improvement_rate(results, eps=1e-6):
    8. """Returns (improved task ratio - regressed task ratio), in the range [-1, 1]."""
    9. if not results:
    10. raise ValueError("results list is empty")
    11. improved = sum(1 for r in results if r.candidate_score - r.baseline_score > eps)
    12. regressed = sum(1 for r in results if r.baseline_score - r.candidate_score > eps)
    13. return (improved - regressed) / len(results)

    Different teams may define the denominator, threshold, and tie handling differently. Before comparing reports from different sources, confirm that these definitions are consistent.

    4. Task Completion Rate and Step Efficiency

    Completion rate answers whether the goal was achieved; step efficiency answers how many tool calls and how much time it took. The two must be examined together. One agent might complete every task but require three times as many steps as another—a difference that translates into noticeable cost and latency in real usage.

    4. Implementing Blind Comparisons

    Human review is easily influenced by position, response length and phrasing, and reviewer preference. The purpose of blind testing is to minimize these confounders. A practical procedure:

    • Generate two candidate results for the same task.
    • Randomly assign left/right positions so reviewers don’t know which version produced each result.
    • Record preferences and discard reviews that are clearly invalid or incomplete.
    • Correct for position bias—for example, swap the left/right positions and evaluate again, keeping only results where both judgments agree.
    1. import random
    2. def make_blind_pair(task_id, answer_a, answer_b, rng=random):
    3. swapped = rng.random() < 0.5
    4. left, right = (answer_b, answer_a) if swapped else (answer_a, answer_b)
    5. return {"task_id": task_id, "left": left, "right": right, "swapped": swapped}
    6. def decode_preference(pair, choice):
    7. """choice is 'left', 'right', or 'tie'; returns 'A', 'B', or 'tie'."""
    8. if choice == "tie":
    9. return "tie"
    10. picked_original_a = (choice == "left") != pair["swapped"]
    11. return "A" if picked_original_a else "B"

    Blind test results also require statistical validation. When the win-rate gap is small, compute a confidence interval or use methods such as the sign test to determine whether the difference exceeds random variation.

    5. Common Pitfalls in Interpreting Results

    • Looking only at the overall score. An aggregate score can hide significant regressions in a specific task category. Report results by stratum and list the task types with the largest regressions.
    • Too few samples. Ranking changes on small samples are mostly random noise. Reports should state the sample size and confidence intervals.
    • Evaluation environment differs from production. Differences in tool permissions, network conditions, timeout settings, and context length directly change outcomes. The evaluation environment should mirror production configuration as closely as possible.
    • Data leakage. If evaluation tasks have appeared in training data or prompt examples, scores will be inflated. Deduplicate the evaluation set and audit its provenance.
    • Ranking on a single metric. Leading on one metric does not mean being better overall. Cost, latency, failure types, and safety-related behavior should all be recorded alongside.

    6. Practical Recommendations

    1. Maintain a fixed regression set and run it after every change to the model version, prompts, or tool configuration. Keep historical results for trend comparison.
    2. Put cost, latency, and failure types in the same report as quality metrics to support trade-off decisions.
    3. Add human confirmation checkpoints for tasks involving high-risk operations such as deletion, sending, or deployment, and make sure the evaluation specifically covers these scenarios.
    4. Evaluation reports should state the sample sources, sample size, model and configuration versions, evaluation date, and the precise definition of each metric. Conclusions lacking this information are hard to reproduce and hard to compare across teams.
    5. Models and tools iterate quickly, so evaluation conclusions have a shelf life. Re-run evaluations on a fixed cadence rather than relying on one-off results indefinitely.