Code Agent Evaluation: High-Difficulty Terminal Benchmarks and Long-Horizon Coding Tasks
This article explains how code agent evaluation has shifted from generating functions to completing tasks inside real, resource-constrained terminal environments, and how to read the results correctly. It covers why terminal benchmarks raise the difficulty, why single-run pass rates are noisy while low pass rates mark a capability boundary, and why the same score can hide very different capabilities. It then breaks down long-horizon coding capability across planning, state management, tool use, error recovery, and process consistency, and shows how to build a tiered evaluation system with confidence intervals, cost data, anti-contamination practices, and regression baselines. It closes with common evaluation pitfalls and engineering recommendations for making assessment measurable, reproducible, and regression-testable.
1. The Evaluation Target Has Shifted: From “Generating Functions” to “Completing Tasks”
In the past, evaluating a model’s coding ability usually meant giving it a function signature and a natural-language description, then using a fixed set of test cases to decide whether the output passed. These tasks had short steps and small contexts, and they measured how well the model grasped syntax and common patterns.
The shape of agent tasks has now changed fundamentally. An agent must autonomously read a codebase, locate defects, modify multiple files, run builds and tests, and keep adjusting based on error feedback until the task is genuinely complete. Once completing a task requires dozens or even hundreds of consecutive steps, it falls into the category of “long-horizon tasks.”
When the evaluation target changes, the focus of assessment shifts with it. Beyond the quality of single-step code generation, it now includes task planning, environment operation, error recovery, and the ability to stay aligned with the goal over long contexts. The evaluation methodology, therefore, must be upgraded accordingly.
2. Terminal Environments: The Natural Vehicle for High-Difficulty Code Benchmarks
A new generation of coding benchmarks—exemplified by open-source terminal benchmark projects—builds the evaluation environment as a real, interactive, and resource-constrained terminal. Tasks require the agent to complete the full flow, from viewing files, installing dependencies, and running scripts to fixing defects, within an isolated runtime environment, with results judged by hidden tests during the evaluation phase.
There are three reasons for choosing a terminal environment:
- Closeness to real work scenarios. Real software engineering is inseparable from the terminal: compile errors, dependency conflicts, and test failures all have to be diagnosed from the command line. Only by actually going through these steps can an agent demonstrate that it is ready for real-world use.
- Resource constraints raise the difficulty. Memory, disk, CPU, network, and execution time are all strictly bounded, which rules out the possibility of “stumbling” onto an answer through unlimited trial-and-error or brute-force enumeration.
- Richer process feedback. Real output mixes in compile errors, dependency warnings, and failed test assertions. The agent has to identify which signals are the key information and adjust its actions accordingly. These abilities are hard to measure with static metrics.
Note: The specific versions and scores of the various public benchmarks mentioned here represent public results at the time of evaluation. Different benchmarks differ in task design, timeout settings, and evaluation mechanisms. These numbers are provided only to illustrate the current state of capabilities and should not be the sole basis for selection decisions.
3. How to Read the Metrics: A Score Is Not the Same as Capability
The purpose of evaluation is to infer overall capability from a limited set of tasks, so every conclusion should carry a confidence boundary. The field typically measures model performance by the average pass rate over a certain number of samples, while also tracking whether a task can be completed at least once across multiple attempts (for example, at least one success under k samples). Similarly, some cloud vendors have evaluated new models using the same approach of multiple sampling and averaging the results, which has become a fairly mainstream practice in the industry.
1. Single-run pass rates are noisy
A task might have only about a 50% success probability for a model to begin with, in which case scores across repeated evaluations will fluctuate randomly between 40% and 60%. Claiming that a model “surpasses” or “approaches” a certain level based on just two or three runs is not robust. When two models differ by less than one percentage point, that gap most likely comes from sampling noise or differences in the evaluation environment rather than a real difference in capability.
2. A low pass rate reflects a capability boundary
On high-difficulty terminal benchmarks, even the best-performing models achieve pass rates of only sixty to seventy percent, which shows that long-horizon complex tasks remain a clear weakness. This score describes a “capability boundary” rather than “average performance,” which means human fallback and secondary verification are still required in actual integration.
3. The same score does not mean the same capability
Passing 60% of the tasks might mean that one agent happens to pass the high-value core scenarios, while another passes a large number of simple ones. For this reason, an evaluation report should disclose the task difficulty distribution, the failure-type distribution, and cost data, rather than offering nothing more than a single “pass rate” figure.
4. Long-Horizon Coding Capability: From “Succeeding Once” to “Stable Multi-Step Execution”
Long-horizon coding capability is the key measure of whether an agent can take on real engineering tasks. As an example, in a certain multi-step code task benchmark, a new generation of models improved by roughly five percentage points over the previous generation, indicating continued progress on long chains of tasks. Long-horizon capability can be broken down along the following dimensions:
| Capability Dimension | Concrete Behavior | Primary Assessment Focus |
|---|---|---|
| Task planning | Breaking a complex requirement into executable subtasks | Whether the plan is reasonable and adjustable |
| State management | Retaining key information over a long context | Whether constraints are forgotten, whether work is duplicated |
| Tool use | Correctly selecting and invoking tools such as the terminal, files, and search | Whether calls are accurate and parameters correct |
| Error recovery | Adjusting the approach based on error feedback | Whether it can locate the root cause and avoid ineffective retries |
| Process consistency | Staying aligned with the goal while progressing step by step | Whether it drifts from requirements or over-modifies |
1. Planning and state management
Long-horizon tasks typically face the following difficulties:
- Context grows linearly over time;
- Key information from early on gets buried under large volumes of tool output;
- The agent “forgets” the original task constraints.
A mature agent actively manages state—for example, by maintaining a task checklist, summarizing tool output, and retrieving key information within a long context—so that it does not have to re-“understand” the entire problem at every step.
2. Error recovery and retry strategies
In a terminal environment, build failures, missing dependencies, and failing tests are the norm. What really separates agents is often not the quality of the first attempt at code, but whether the agent can effectively diagnose and fix problems when faced with failure:
Initial plan A: modify the target module↓ test still failsAnalyze the error output -> locate an uncovered boundary condition↓Plan B: add boundary handling + new regression tests↓All tests pass
Effective recovery mechanisms usually involve three practices:
- Distinguishing “environment problems” from “code problems,” to avoid repeatedly editing business code when a dependency is missing;
- Narrowing the search space using keywords from the error stack;
- Setting a maximum retry count and timeout to prevent infinite loops.
3. Reliability at the engineering layer
Improving the model’s capability alone is not enough; the engineering layer needs supporting measures as well:
- Sandboxing and access control: Runtime environments are isolated from one another, with least-privilege permissions to avoid affecting the host system;
- Deterministic execution: Pinning dependency versions and base images to reduce noise caused by environment differences;
- Result persistence: Archiving task logs, execution traces, and final artifacts in a unified way to facilitate review;
- Process observability: Using logging services and monitoring alerts to track task status, elapsed time, and failure rates in real time, so that intervention can happen promptly.
5. From Single-Run Evaluation to a Tiered Evaluation System
No single benchmark can fully characterize an agent’s engineering capability. In practice, it is advisable to build a tiered evaluation system in which different levels of tests answer different questions.
1. A three-tier evaluation structure
- Unit level: function-level defect fixing, code completion, explanation, and refactoring, which examine basic coding ability;
- Task level: completing a well-defined engineering goal in a real terminal environment—such as fixing a specified defect, implementing a feature, or making all tests pass—which examine tool use and environment operation;
- Long-horizon level: cross-module refactoring, dependency migration, and multi-stage tasks lasting several hours, which examine planning, memory, and stability.
2. Execution and scoring
# Illustrative configuration for tiered evaluationlevels:unit: # Unit level: fast regressionpass_threshold: 0.95weight: 0.2task: # Task level: real terminal environmentpass_threshold: 0.75weight: 0.4long_horizon: # Long-horizon level: sustained multi-step executionpass_threshold: 0.55weight: 0.4report:report_accuracy: true # Disclose the 95% confidence interval in the reportreport_cost: true # Also report the average cost per task
def evaluate(cases, agent, sample_n=3):"""Compute the mean pass rate after multiple sampling runs and return a 95% confidence interval."""results = []for case in cases:outcomes = [run_once(case, agent) for _ in range(sample_n)]# Take the success ratio across multiple runs for each taskresults.append(sum(outcomes) / sample_n)mean = sum(results) / len(results)stderr = statistics.stdev(results) / math.sqrt(len(results))ci95 = (mean - 1.96 * stderr, mean + 1.96 * stderr)return {"mean": mean, "ci95": ci95, "n": len(cases)}
The example above is only meant to illustrate the evaluation logic. In actual implementations, the sample size needs to be balanced against cost constraints and statistical precision, and an appropriate interval estimation method should be used for the confidence interval.
3. Anti-contamination and continuous updates
Once a benchmark is made public, it may be absorbed into training data, leading to inflated scores. Common practices include:
- Periodically introducing new tasks or variants;
- Creating equivalent rewrites of tasks to prevent answers from being “memorized”;
- Separating a public set from a private held-out set, and using the private set to verify true generalization ability.
4. Regression baselines
After every model or agent-framework upgrade, the baseline task set should be run again to promptly detect capability regression or cost increases.
6. Common Evaluation Pitfalls
- Looking only at scores, not cost. The same agent scores higher under a larger budget, while the per-call cost of different models can differ by several times. An evaluation should provide a quality–cost curve and inform model selection based on the specific scenario (for example, instant completion versus background batch jobs).
- Equating long-horizon capability with long context. A long context window is only a necessary condition; what is decisive is whether the agent can stay aligned with the goal over a long context and effectively compress information.
- Overlooking the human-feedback loop. Only by introducing human feedback into the generate–execute–review loop can real development preferences be continuously injected into the system, gradually improving usability on complex tasks.
7. Conclusion and Engineering Recommendations
Evaluating high-difficulty terminal benchmarks and long-horizon coding tasks is essentially about answering an engineering question: can an agent complete complex tasks reliably in a real environment the way a developer would? This can be distilled into three practical principles:
- Assess across multiple dimensions. A single score should be treated only as a reference and must be combined with multiple sampling runs, confidence intervals, and cost data for a comprehensive judgment;
- Focus on long-horizon stability. Continuously iterate on planning, state management, and error recovery so that the agent still “remembers the goal” after dozens of steps;
- Close the loop between engineering and evaluation. Through sandbox isolation, deterministic execution, observability, and a tiered evaluation system, turn capability assessment into engineering capabilities that are measurable, reproducible, and regression-testable.
Going further, once code agents are gradually embedded into the development workflow, they can move from single-point assistance to full-process collaboration: taking on defect localization and automatic fixing in code hosting and continuous integration, generating and running regression tests during the testing stage, and assisting with problem localization during release by combining log and monitoring data. For teams with needs for evaluation at scale and batch task execution, infrastructure provided by platforms such as Baidu AI Cloud can be used to build elastically scalable evaluation and task-execution environments, reducing self-built costs and improving iteration efficiency.
