Long-Horizon Tasks: The New Battleground for Evaluating AI Coding Ability
This article examines the shift in AI coding evaluation from single-shot correctness to long-horizon tasks—work that requires sustained progress, self-correction, and convergence within constraints and budgets. It defines what long-horizon tasks are, explains why they reveal real engineering capability that short-horizon benchmarks miss, and outlines how to design reproducible evaluations with clear constraints, executable feedback, budget limits, and process tracking. It also covers engineering essentials such as isolated execution environments, persistent state and artifacts, low-latency feedback loops, and upfront guardrails, along with common pitfalls to avoid.
1. A Counterintuitive Observation: Sustaining Correctness Matters More Than Getting It Right Once
For the past two years, discussions about AI coding ability have largely rested on an implicit assumption: whether a model can produce the correct answer on the first attempt. Code generation benchmarks, single-function completion tests, and bug-fix evaluations are all essentially built on an “exam mindset”—present one problem, constrain the context, and check whether the output passes validation.
Real engineering, however, is never finished in one pass. A service that fails to meet performance targets often goes through a cycle: write a version, run it, find the bottleneck, swap the algorithm, run again, still miss the target, refactor the data structures, and keep load testing. This process can last hours or even days. The fact that some recent Chinese large models have focused on “long-horizon tasks” in public evaluations shows that the industry’s attention is shifting: from single-point accuracy to the ability to keep making progress over long time spans, self-correct, and ultimately converge to a usable state.
This article does not benchmark any specific model or product. Instead, it abstracts the phenomenon into a general technical question: how to define, evaluate, and engineer long-horizon tasks.
2. What Is a Long-Horizon Task
A long-horizon task is one that requires a model to keep making progress across multiple rounds of interaction, extensive tool calls, and accumulated state in order to reach a goal. It differs from traditional short-horizon tasks in three fundamental ways:
- Large state space: intermediate artifacts include code, logs, test reports, and performance metrics, and the context keeps expanding.
- Sparse and delayed feedback: whether a change works may only become clear after running the full benchmark suite.
- Dynamic strategy adjustment: when one path fails, the model must change approach rather than mechanically retry.
A typical long-horizon task can be described in the following form:
Goal: Maximize queries per second while keeping recall no lower than 95%Initial state: Given skeleton code for approximate nearest neighbor retrievalAvailable actions: Modify code, run benchmarks, read metrics, roll backTermination condition: Throughput target reached or budget exhausted
Note the three elements: constraint + goal + budget. Optimization without constraints has no engineering meaning, and a setup without a budget cannot be applied in reality.
3. Why Long-Horizon Tasks Are the Real Battleground
3.1 Coverage Gaps of Short-Horizon Benchmarks
High pass rates on single-function generation or single-bug-fix evaluations do not mean a model can work in a real repository. Real repositories contain dependencies, build scripts, implicit conventions, and historical baggage; a failure in any of these can make a “seemingly correct” patch fail.
3.2 Long-Horizon Capability Exposes Real Engineering Skills
In long-horizon tasks, a model must do three things that short-horizon tasks do not require: first, maintain task state, knowing “what has already been tried and why it failed”; second, make cost trade-offs, deciding whether to dig deeper or change direction; and third, converge under constraints rather than making endless changes.
3.3 Direct Value for Enterprises
What enterprises truly need is not an assistant that “can write functions,” but an executor that can take on a clear goal, make progress autonomously within a budget, and deliver verifiable results. The stronger the long-horizon capability, the larger the granularity of tasks that can be automated—expanding from “completing code” to “finishing an optimization,” “migrating a module,” or “fixing a class of problems.”
4. How to Design Long-Horizon Task Evaluations
To turn long-horizon capability into comparable, reproducible metrics, evaluation design needs to cover four areas:
- Define constraints and goals clearly: for example, a recall floor, a latency ceiling, or compatibility requirements.
- Provide executable feedback: there must be real, runnable benchmarks and metric outputs, not manual scoring.
- Set budget boundaries: limit the number of iterations, tool calls, or time to prevent gaming scores through “unlimited retries.”
- Record the process, not just the final value: iteration curves, strategy switch points, and rollback counts are all important signals.
A schematic evaluation loop looks like this:
for step in range(max_steps):action = agent.decide(state) # Modify code / run benchmark / roll backresult = env.execute(action) # Execute for real and collect metricsstate = state.update(result)if result.meets_goal and result.within_budget:return resultreturn best_state
In an evaluation report, beyond the final metrics, it should also state “the number of iterations needed to reach the current best value” and “whether there was a clear strategy switch.” These two items distinguish “getting lucky” from “actually knowing how to do engineering.”
5. Engineering Essentials for Long-Horizon Tasks
5.1 Execution Environments Must Be Isolated and Reproducible
Long-horizon tasks generate many intermediate artifacts and failed attempts. Isolated runtime environments (such as container platforms) ensure that each execution does not affect others, and固化 dependencies through images and configurations to ensure reproducible results.
5.2 State and Artifacts Must Be Persistable
Code versions, metric data, and logs should be stored separately in version control, object storage, and logging services, making it easy to trace “what change was made at which step and how the metrics changed.”
5.3 Feedback Loops Must Be Low-Latency
Tool calls and metric collection should be automated as much as possible to reduce manual intervention. Message queues can decouple task scheduling from result collection, and monitoring and alerting can track the health and timeouts of long-running tasks.
5.4 Budgets and Guardrails Must Be Set Upfront
Write iteration limits, cost limits, and a list of prohibited operations at the task initialization stage to prevent the executor from making irreversible changes during the long-horizon process.
6. Common Pitfalls
- Looking only at the final value and not the process: a single success may come from randomness; process data is what shows stability.
- Trading unlimited budget for scores: a high score detached from cost constraints has no production value.
- Ignoring constraint satisfaction: raising throughput while recall drops below the threshold is an invalid optimization.
- Equating long-horizon with “multi-turn dialogue”: the key is not the number of turns, but the ability to maintain state and adjust strategy.
7. Conclusion
The focus of AI coding evaluation is shifting from “whether it is correct on the first pass” to “whether it can keep making progress and converge within constraints and budgets.” For enterprises, this means that selection should focus on the isolation of the execution environment, the traceability of state and artifacts, the degree of automation of the feedback loop, and the completeness of budget guardrails. Baidu AI Cloud’s combination of general capabilities—container platforms, object storage, logging services, and monitoring and alerting—can serve as a reference foundation for carrying long-horizon tasks; but what truly determines effectiveness is still whether the task is clearly defined, whether feedback is real, and whether boundaries are clear.
