Long-Horizon Coding Agent Evaluation: Metrics and Selection Practices
This article explains why long-horizon evaluation is needed for AI coding agents and how to design task sets that reflect real development work. It defines four core metrics—pass rate, average completion, average duration, and single-run cost—and shows how to aggregate them from run records with a sample Python function. It also describes how to interpret results for quality-first, efficiency-first, and budget-first selection, and how to improve credibility through repeated runs, fixed configurations, failure categorization, consistent pricing, and periodic re-evaluation.
Why Long-Horizon Task Evaluation Is Needed
Early evaluations of coding assistants often relied on single-turn question answering. A typical test gave a function description and checked whether the generated code passed a few cases. Such tests are fast, but they differ substantially from real development work. Real requirements usually involve multiple files, dependencies, environment configuration, test repair, and multiple debugging cycles. Completing one task can take hours or longer.
Long-horizon evaluation is designed for this gap. The evaluated agent must autonomously plan, execute, verify, and correct its work over an extended period, then deliver a runnable result. The focus shifts from “can it write a correct code snippet” to “can it complete a whole piece of work under constraints.”
Principles for Constructing Evaluation Tasks
The quality of the task set determines the value of the evaluation conclusions. A task set suitable for selection usually meets the following conditions.
- Cover real scenarios: Tasks should include requirement understanding, module development, defect repair, interface integration, performance optimization, and other types, rather than concentrating on only one kind of problem.
- Allow automatic result verification: Each task should have a clear acceptance script or test cases, and the judgment should not depend on subjective manual scoring.
- Provide environment isolation: Each run should use a clean container or snapshot environment so that historical files, caches, or network state do not affect the result.
- Use a reasonable difficulty distribution: Simple tasks calibrate the lower bound, while complex tasks distinguish the upper bound. Both should be retained.
For example, a set of mobile application development tasks could include implementing a list page and pagination loading according to API documentation, fixing a layout bug that appears on a specific device model, adding unit tests to an existing module, and making the build script pass static checks. Each task should specify a fixed input repository, requirement description, and acceptance command.
Four Core Metrics
Pass Rate
Pass rate measures the proportion of successful tasks and is the most intuitive metric:
Pass rate = number of tasks passing acceptance / total number of tasks
Pass rate only answers “how many succeeded” and does not show how far failed tasks were from the goal. It therefore needs to be interpreted together with completion.
Average Completion
Completion characterizes the progress of tasks that did not pass. A common approach is to score by acceptance sub-items. For example, if a task contains five checkpoints and three are satisfied, the completion is 0.6. Average completion is the arithmetic mean of completion across all tasks.
This metric distinguishes “almost correct” from “completely off track.” If two tools have the same pass rate but differ significantly in average completion, the tool with higher completion usually has lower manual remediation cost when a person takes over.
Average Duration
Duration refers to the wall-clock time from task start to final output, usually measured in hours or minutes. The calculation should include the tool’s thinking, execution, waiting for external services, and retries.
Duration should be compared together with task difficulty. If a tool only completes simple tasks, its duration will naturally be lower and cannot be used directly as evidence of a speed advantage. It is better to report duration by task group or compare tools on the same task set.
Single-Run Cost
Single-run cost refers to all billable items consumed to complete the full task set, such as model invocation fees, compute resource fees, and storage fees. Reports should state the pricing currency, exchange rate, and measurement date, because exchange-rate changes directly alter local-currency values.
Cost and duration often trade off against each other. A longer reasoning chain may improve pass rate, but it also raises cost and waiting time. During selection, cost should be treated as a constraint rather than an isolated ranking basis.
Example Metric Calculation
The following code shows how to aggregate the metrics above from raw run records. The data structure is kept general so it can be connected to different evaluation pipelines.
from dataclasses import dataclassfrom statistics import mean@dataclassclass TaskRun:task_id: strpassed: boolcompletion: float # Completion score, ranging from 0.0 to 1.0duration_hours: float # Wall-clock duration in hourscost_usd: float # Billed amount for this task in USDdef summarize(runs: list[TaskRun]) -> dict:if not runs:raise ValueError("Run records are empty")total = len(runs)return {"pass_rate": sum(r.passed for r in runs) / total,"avg_completion": mean(r.completion for r in runs),"avg_duration_h": mean(r.duration_hours for r in runs),"total_cost_usd": sum(r.cost_usd for r in runs),}
In real projects, you should also record the seed, model version, agent configuration, and environment image hash for each run so that others can reproduce the same result.
Interpreting Results and Making Selection Decisions
A single metric is rarely enough to support a decision. Priorities can be ordered according to business needs:
- Quality first: Focus on pass rate and completion, and accept higher duration and cost. This applies to core modules or security-sensitive code.
- Efficiency first: Focus on duration and manual remediation cost. This applies to feature development with clear requirements and frequent iteration.
- Budget first: Set a cost cap per run or per task, and compare costs only after meeting a quality floor.
A practical approach is to set hard constraints first—for example, cost must not exceed the budget and pass rate must not fall below the team’s acceptable lower bound—and then compare the remaining metrics among feasible options. This makes the decision basis clear and easier to trace afterward.
Ensuring Credible Evaluation Conclusions
- Average multiple runs: The same task may produce different results due to randomness. Run each task multiple times and report the range of variation.
- Fix versions and configurations: Record tool versions, prompt templates, timeout settings, and retry policies to avoid invalidating conclusions after version updates.
- Report success and failure causes separately: Classify and count timeouts, environment errors, and logic errors to help determine whether the problem lies in capability or infrastructure.
- Use a consistent pricing basis: Cost statistics should use the same currency, exchange-rate date, and billing scope.
- Re-evaluate periodically: Tools and services iterate quickly, so conclusions should have a validity period and be re-evaluated at key milestones.
The value of long-horizon task evaluation is that it turns “it feels usable” into verifiable data. As long as task design is reasonable, metric definitions are clear, and the process is reproducible, teams can use it to choose a coding assistance solution that fits their needs and track changes over time.
