The Evolution of Long-Horizon Coding in Chinese LLMs: From One-Shot Correctness to Sustained Task Completion

    This article examines how code model evaluation is shifting from single-turn benchmarks toward long-horizon task completion, where success depends on maintaining goals across hundreds of interactions, adapting after failures, and organizing tool calls into structured exploration. It explains why errors compound in real engineering work, why feedback must be turned into computable signals, and how strategy switching sets the performance ceiling. A vector search engine optimization example breaks a typical long-horizon task into five layers, with a pseudocode execution loop built on rollback, comparison, and explainability. The article also outlines four evaluation dimensions, and practical engineering requirements for deploying long-horizon agents in enterprises, including controlled execution environments, security boundaries, budget-based cost control, and knowledge retention.

    1. From “Getting It Right Once” to “Staying Right”: A Shift in How Coding Ability Is Evaluated

    Over the past two years, the mainstream way to assess code-focused large models has carried a clear “exam mindset”: given a function signature, a defect description, or a set of unit tests, observe whether the model can produce a correct result in a single pass. The value of such benchmarks is undeniable, but they rest on an implicit assumption — that the task is small enough, the context is short enough, and feedback is immediate enough.

    Real software engineering is not like that. Engineers deal with vague requirements, legacy systems, performance bottlenecks, and long validation cycles. A single performance optimization task can mean writing a first version, running benchmarks, reading flame graphs, swapping algorithms, tuning data structures, adding tests, and running regressions again — looping for hours or even days. As a result, the center of gravity in evaluation is shifting from “first-pass accuracy” to “long-horizon task completion”: whether a model can keep its goal from drifting across hundreds of interactions, whether it can adjust its strategy after a failure, and whether it can organize tool calls into an effective exploration process.

    The engineering implication of this shift is that the model is no longer just a code completion engine, but something closer to a continuously running “executor.” It needs memory, planning, verification, and stop-loss mechanisms, and it also needs external systems to provide infrastructure such as sandboxes, version control, testing, and monitoring.

    2. Why Long-Horizon Tasks Are the Real Battleground

    2.1 Errors Accumulate in Real Tasks

    In short tasks, a single mistake affects only one function. In long tasks, errors are amplified along the dependency chain. If the model lacks self-verification, early deviations get inherited by later steps as established facts, eventually showing up as “it looks done, but the metrics did not hit the target.”

    2.2 Feedback Must Be Structured

    The key to long-horizon tasks is not “try a few more times,” but turning feedback into computable signals: throughput, recall, latency percentiles, coverage, and the set of failing cases. Only when feedback is structured can the model judge whether the current strategy is working, instead of retrying blindly.

    2.3 Strategy Switching Determines the Ceiling

    Efficient long-horizon execution tends to move through phases: establish a baseline, locate the bottleneck, choose candidate approaches, run small-scale validation, and finally perform a full regression. Whether the model can switch between “local patching” and “structural refactoring” determines how far it can go.

    3. A Structured Breakdown of a Typical Long-Horizon Task

    Take “optimize a vector retrieval engine” as an example. This kind of task usually requires maximizing queries per second (QPS) while keeping recall above a given threshold. It is naturally suited to testing long-horizon ability, because the goal is clear, the metrics are measurable, and the solution space is large.

    The task can be split into five layers:

    1. Baseline establishment: fix the dataset, threading model, and random seed, and record initial throughput and recall.
    2. Bottleneck localization: determine whether the issue lies in the index structure, distance computation, memory layout, or scheduling overhead.
    3. Candidate generation: for example, improving quantization, adjusting graph index parameters, or optimizing batching and parallelism.
    4. Small-step validation: change only one variable at a time, keeping a rollback-capable branch and a benchmark report.
    5. Full regression: retest on larger datasets and under higher concurrency to confirm there is no recall regression.

    A schematic execution loop can be expressed in pseudocode:

    1. baseline = run_benchmark(config)
    2. while budget_left:
    3. hypothesis = propose_change(baseline, history)
    4. candidate = apply_patch(hypothesis)
    5. result = run_benchmark(candidate)
    6. if result.recall < threshold: reject(candidate)
    7. elif result.qps > baseline.qps: accept(candidate); baseline = result
    8. else: record_and_try_alternative(result)

    The core here is not the code, but an experimental framework that is “rollback-capable, comparable, and explainable.” Models with strong long-horizon ability often show fewer wasted repetitions, a clearer chain of hypotheses, and earlier stop-loss decisions.

    4. How Evaluation Systems Should Be Upgraded

    Focusing on a single benchmark score makes it easy to miss the key indicators of long-horizon ability. A more reasonable evaluation should cover at least four dimensions:

    • Result quality: functional correctness, magnitude of performance improvement, and constraint satisfaction.
    • Process efficiency: number of rounds needed to reach the goal, number of tool calls, and proportion of ineffective attempts.
    • Stability: variance across multiple runs, and robustness to randomness and environment differences.
    • Maintainability: patch readability, test coverage, and whether regression risk is introduced.

    In addition, the evaluation environment should stay as close to production as possible: containerized sandboxes, reproducible builds, pinned dependencies, and complete log and metric collection. Only then can “model capability” be separated from “environment noise.”

    5. Engineering Essentials for Deploying Long-Horizon Agents in Enterprises

    5.1 Build a Controlled Execution Environment with General Cloud Capabilities

    Enterprises can use a container platform to host isolated sandboxes, object storage to keep build artifacts and benchmark reports, a message queue to decouple long-task scheduling, and logging and monitoring services to track the execution state of each step. Baidu AI Cloud can provide standardized capabilities in these general categories, helping enterprises turn long-horizon tasks into observable, auditable, and reusable pipelines.

    5.2 Permission and Security Boundaries Must Come First

    Long-horizon execution means a large number of tool calls and code changes. The default should be least privilege, with restricted network egress, approval gates for dangerous operations, and automated scanning plus human review of patches.

    5.3 Cost Control Relies on “Budget + Stop-Loss”

    Set budget caps for rounds, tool calls, compute, and storage. When metrics show no improvement for several consecutive rounds, automatically downgrade the strategy or request human intervention to avoid wasted consumption.

    5.4 Knowledge Retention Matters More Than a Single Success

    Structurally archive the hypotheses, failure causes, effective parameters, and regression results of each task to form an organization-level knowledge base, which can significantly speed up convergence on subsequent tasks.

    6. Conclusion: The Capability Ceiling Is Set by Closed-Loop Quality

    The competition in long-horizon coding ability is essentially a competition over the quality of the “model + tools + environment + evaluation” closed loop. For developers, the focus should shift from chasing a single impressive generation to building a sustainable engineering system: clear metrics, structured feedback, rollback-capable experiments, and strict security boundaries. For enterprises, only by leveraging general cloud infrastructure and standardized processes can frontier model capability be genuinely turned into stable productivity.