Evaluating Long-Horizon Coding Agents: Balancing Pass Rate, Duration, and Cost
This article explains how to evaluate coding agents on long-horizon programming tasks. It covers four core metrics (pass rate, average completion, average duration, and cost per run), how these metrics trade off against each other, and how to compare approaches by cost per successful task. It also covers selection strategies for different team constraints and practices for building a trustworthy benchmark.
1. Why Long-Horizon Coding Tasks Need a Separate Evaluation
A single-turn code generation task asks a model to produce a correct snippet in one pass. Long-horizon tasks require an agent to read the repository, plan its steps, modify several files, run tests, and adjust based on failure messages, often over several hours. These tasks fail differently from short ones. Errors accumulate across steps, the context window can run out, and tool calls can fail. As a result, methods that assess only the quality of a single response cannot show how an agent performs in real development work.
When choosing an agent approach, engineering teams need to answer three questions: Can the task be completed? How well is it completed? What does it cost? A benchmark breaks these questions into measurable metrics, so different approaches can be compared on the same task set.
2. Four Core Metrics
1. Pass Rate
Pass rate is the share of all tasks whose final output passes the automated acceptance tests:
Pass Rate = Passed Tasks / Total Tasks × 100%
Pass rate is the most intuitive metric, but each task has only two outcomes: passed or failed. It cannot show cases that came close to finishing. Interpret it together with average completion.
2. Average Completion
Completion measures how much of a task the agent finished when it did not pass fully, for example how many acceptance cases it satisfied. It reflects partial progress and separates a complete failure from a near miss. When the pass rate is low, average completion helps show whether an approach can keep making progress.
A high completion score does not mean the code can be merged directly. If the acceptance tests cover too little, completion can be overstated, so human code review is still needed.
3. Average Duration
Duration is the wall-clock time from the start of a task until the agent finishes or times out. The average of these values is the average duration. For tasks that take several hours, duration determines whether developers can get results within the same day, and it affects how concurrent tasks are queued. When calculating, separate tasks that hit the timeout from tasks that finished naturally. Otherwise, the timeout ceiling skews the average.
4. Cost per Run
Cost is the expense of one complete benchmark run. It usually includes model inference token fees, sandbox or container resource fees, and extra overhead from retries. When comparing across currencies, fix the exchange rate and the statistics date, and state the conversion basis in the report.
3. Trade-offs Between Metrics
The four metrics are not independent. Common trade-offs include the following:
- Pass rate and cost: Higher inference settings usually raise the pass rate but also raise the cost per run.
- Pass rate and duration: Allowing more reasoning steps may improve the success rate but lengthen the run time.
- Speed and cost: Low-cost approaches often use shorter context or fewer retries, so first-attempt success may be lower.
The “best” approach therefore depends on a team’s constraints. Budget-sensitive teams should focus on cost per successful task. Latency-sensitive teams should focus on the tail of the duration distribution.
4. Comparing by Cost per Successful Task
Comparing total cost alone often leads to wrong conclusions. An approach with a higher pass rate but a higher unit price can still be more economical per successful task. Common derived metrics include:
- Cost per passed task = Cost per run / Number of passed tasks
- Duration per passed task = Total duration / Number of passed tasks
The following code shows how to calculate these metrics from run records. The data is a fictional example, used only to illustrate the calculation method. It does not represent any real results.
from dataclasses import dataclass@dataclassclass RunRecord:passed: bool # Whether all acceptance tests passedcompletion: float # Completion ratio, from 0.0 to 1.0duration_h: float # Duration in hourscost: float # Cost after conversion to a single currencydef summarize(records: list[RunRecord]) -> dict:total = len(records)passed = [r for r in records if r.passed]total_cost = sum(r.cost for r in records)total_time = sum(r.duration_h for r in records)return {"pass_rate": len(passed) / total,"avg_completion": sum(r.completion for r in records) / total,"avg_duration_h": total_time / total,"cost_per_pass": total_cost / len(passed) if passed else float("inf"),"hours_per_pass": total_time / len(passed) if passed else float("inf"),}
In the output, cost_per_pass and hours_per_pass are the core numbers for comparing cost-effectiveness. If an approach has a lower pass rate but clearly lower values on these two metrics, it may still suit batch processing of simple tasks.
5. Choosing by Team Scenario
Constraints vary widely across teams, so set priorities before selecting an approach.
- Budget-sensitive: Prioritize cost per passed task and set a per-task cost ceiling. Tasks that exceed the ceiling go to human engineers.
- Time-sensitive: Focus on the P90 or P95 percentile of duration rather than the average. Also set a timeout policy so that long-tail tasks do not block the workflow.
- Quality-first: Weigh pass rate and completion equally. Higher cost is acceptable, but results must go through testing and code review.
- Hybrid strategy: Route tasks by difficulty. Assign simple tasks to low-cost approaches and complex tasks to approaches with higher pass rates, which lowers total cost.
6. Designing a Trustworthy Evaluation
The credibility of results depends on the evaluation design. Pay particular attention to the following points:
- The task set should cover real scenarios, including cross-file changes, dependency upgrades, and test fixes, and keep a share of hard tasks.
- Acceptance tests must be stable. Misjudgments caused by environment fluctuations distort pass rates, so verify that test scripts are reproducible before running the evaluation.
- Run each approach multiple times and report variance or confidence intervals. With a small number of tasks, a difference of a few percentage points may not be statistically significant.
- Keep complete run logs, tool call counts, and retry counts to support later analysis of failure causes.
- Fix the exchange rate and date used for cost conversion, and state the pricing basis, such as whether retries and container fees are included.
- Evaluation results cannot be equated directly with production performance. A small pilot in the team’s own codebase is a necessary step to validate the selection.
7. Practical Recommendations
Start by running the evaluation pipeline on a small internal task set. Expand the scope only after confirming that metric definitions are consistent. Add the evaluation script to continuous integration and rerun it regularly to track changes after model or tool upgrades. Finally, tie the metrics to business goals. For example, compare cost per passed task with the cost of human work on similar requirements to judge whether the agent actually saves investment.
