Evaluating Long-Horizon Code Agents Scientifically: A Terminal Task Perspective
This article examines how to assess long-horizon code agents that break down complex goals, use command-line and file tools, and iterate in real environments. It explains the design logic and limits of terminal benchmarks, how to interpret pass rates and benchmark versions responsibly, and which technical factors—task decomposition, state tracking, self-correction, and training with verifiable rewards—shape long-horizon performance. It also offers practical guidance on building internal evaluation sets, measuring end-to-end pipeline metrics, sandboxing execution, and using general cloud infrastructure.
1. From Code Completion to Engineering Completion
Early programming assistance tools mainly handled local problems, such as generating a function from a comment, completing a line of code, or explaining a piece of logic. These tasks have short context, clear goals, and easily verifiable results. In the past year or two, industry discussion has shifted toward long-horizon agents. A long-horizon agent here refers to a system that receives a complex goal, decomposes the steps on its own, calls command-line and file tools, continues executing in a real environment, and adjusts its approach based on feedback. It is suited to engineering tasks with clear acceptance criteria that can be run repeatedly in an environment. If the need is only one-off text generation, its advantage is not obvious.
The difficulty of real engineering tasks mainly comes from the composite nature of the goals. A task usually includes locating performance bottlenecks, modifying the implementation, passing tests, and ensuring that other modules are not affected. Completing such a task often requires dozens or even hundreds of interactions. During execution, the agent may also encounter missing dependencies, inconsistent environment versions, and flaky tests. Each step’s output changes the environment state, and small early errors may be amplified in later steps.
Therefore, measuring long-horizon execution capability requires a method that can be run repeatedly and whose results can be judged objectively. Looking only at model performance in question answering cannot answer whether it can independently complete an engineering task.
2. Terminal Benchmarks: Design Logic and Boundaries
2.1 How the Tests Are Designed
Terminal benchmarks usually provide the agent with an isolated container environment, generally containing only a command-line interface and limited compute resources. There are two common task formats: fixing a defect in an open-source repository and making all tests pass, or building a service from scratch according to a set of functional requirements. The agent cannot see hints beyond the task and can interact with the environment only by executing commands, reading files, and running tests. Each task comes with verification scripts, and only a final state that meets all acceptance conditions is counted as a pass.
This design reduces the possibility of a model scoring high by memorizing answers. Some benchmarks randomize environment parameters and place acceptance scripts outside the agent’s visible scope. These measures can only reduce the risk of answer memorization; they cannot fully exclude overlap between training data and public code repositories. Evaluators should state which leakage-prevention measures they have adopted, and readers should use that information to judge the credibility of the results.
2.2 How to Read the Scores
Public leaderboards often give only a single percentage. Before citing that number, readers need to confirm several points: which benchmark version it corresponds to, how many tasks there are, whether it is a first-attempt pass rate or a pass rate after multiple retries, when the test was run, and whether the result comes from an official report or a third-party reproduction. Without this information, the number is difficult to verify.
Different benchmark versions cannot be compared directly. If the same model has different scores on two versions, it usually means the task set or acceptance scripts have changed. When comparing successive model generations, the same task set and the same evaluation protocol should be used. The size of the improvement should also be specified as absolute percentage points or as a relative change; otherwise, readers cannot judge its practical significance.
When top models’ scores are clustered, a single benchmark often cannot distinguish similar models. In this case, teams should pay more attention to the differences between the two models in their own task scenarios. The following table lists the fields recommended for recording a benchmark result so that it can be verified later.
| Field | What to record |
|---|---|
| Model | Specific model name and version number |
| Benchmark | Name, version, and number of tasks |
| Metric | First-attempt pass rate, or pass rate after multiple retries |
| Protocol | Number of retries, timeout settings, and resource configuration |
| Date | When the test was executed |
| Source | Official report, leaderboard page, or internal reproduction record |
2.3 Common Questions
How should I choose a terminal benchmark?
Consider three points. First, whether the tasks are close to your technology stack and project type. Second, whether the acceptance criteria can be determined automatically. Third, whether the evaluation protocol is public. If a benchmark publishes only scores and not the protocol, its reference value drops significantly.
How should I read pass rates?
First confirm what the numerator and denominator represent. Then look at stability, such as whether the same task produces consistent results across multiple runs. A single pass does not mean long-term usability; variance across multiple runs should also be part of the judgment.
What are common misreadings?
There are three main ones. First, directly ranking scores from different benchmarks. Second, treating a single pass as stable availability. Third, equating a benchmark score with engineering outcomes. Actual engineering performance also depends on context management, toolchain integration, permission configuration, and how the team splits tasks.
3. Technical Elements Behind Long-Horizon Code Capabilities
3.1 Task Decomposition and State Tracking
The main difficulty for long-horizon agents is goal drift. After dozens of tool calls, the model may forget the initial goal or omit steps that have already been completed. Common industry responses fall into three categories. The first is maintaining an explicit task checklist. The second is rolling summaries of historical operations in context. The third is self-verification at key nodes. Structured management of execution trajectories has a major impact on success rates for long tasks.
3.2 Self-Correction and Use of Feedback
The terminal environment provides feedback signals, including exit codes, error messages, and test output. Stronger models turn this information into subsequent actions, forming an execution-observation-correction loop. The ability to recover from failure often says more about whether a model is reliable in real projects than a single success does.
3.3 Directions for Improvement at the Training Level
Public materials mention roughly four directions for improvement: introducing more real software engineering data for training, applying reinforcement learning on verifiable tasks, using test passes as a reward signal, and optimizing tool-call formats and multi-turn strategy training. Using test results as a verifiable reward is one of the more common technical routes at present. When evaluating vendor claims, readers should rely on public papers, technical reports, or reproducible experiments.
4. Practical Recommendations
Build your own evaluation set. Extract typical tasks from your own codebase, such as defect fixes, feature migrations, and environment configuration. You can start with a few dozen representative tasks and expand gradually. Each task needs automated acceptance scripts and regular sample-based manual review. The review ratio can start small and then be adjusted based on the misjudgment rate found.
Measure the pipeline with end-to-end metrics. For an automated development pipeline, more meaningful metrics include end-to-end task completion rate, number of manual interventions, and rework rate. These metrics are directly related to the team’s actual benefits; a single benchmark score cannot reflect these changes.
Design an execution sandbox and control risk. When integrating into actual workflows, use container isolation, least privilege, and operation auditing. Long-horizon execution may lead to data deletion, cost amplification, and permission sprawl. Therefore, set up rollback mechanisms and usage caps, and require human confirmation for high-risk operations such as deletion, deployment, and permission changes.
Make good use of general cloud capabilities. Model services, container runtime environments, logs, monitoring, and alerting can be combined into runtime infrastructure for agents. Before building, verify the billing method, data retention policy, and access control configuration, and complete validation in a test account first.
5. Conclusion
The key to evaluating long-horizon code agents is reproducible tasks, clear protocols, and acceptance criteria that are close to real scenarios. Teams should focus on building their own validation system and use it to determine whether a model can reliably complete work in their own projects.
