The Evolution of Long-Horizon Coding in Chinese LLMs: From One-Shot Answers to Sustained Optimization

    This article examines the shift in how coding agents are evaluated, moving from first-attempt correctness toward convergence on long-horizon engineering tasks. It defines long-horizon programming as a constrained optimization problem, explains why state management, strategy switching, and constraint guarding matter, and outlines a multi-dimensional evaluation matrix covering repository-level repair, natural-language-to-repository generation, terminal operations, tool-assisted reasoning, and benchmark optimization. A public vector database optimization case study shows how roughly 600 iterations raised throughput from about 3,547 to about 21,500 QPS while preserving 95% recall. The article closes with practical guidance for enterprise adoption, a layered human-agent collaboration model, and the main limitations and risks, including reward hacking, cost control, and long-context decay.

    1. From “Getting It Right Once” to “Iterating to the Finish”: A Shift in Evaluation

    For the past two years, most discussions of code generation have centered on a single metric: given a requirement or a bug description, can the model produce a runnable answer in its first response? Such benchmarks are valuable. They measure fundamental code comprehension, syntactic correctness, and common pattern matching. But when the lens shifts from an exam hall to a real engineering environment, it becomes clear that “getting it right on the first try” almost never happens in practice.

    Real engineering is a closed loop: write an implementation, run benchmarks or unit tests, inspect metrics and errors, locate the bottleneck, swap algorithms or data structures, and run again, repeating until the constraints are satisfied. This process can last hours or even days, filled with trial and error, rollbacks, and strategy changes. As a result, the key measure of a coding agent is shifting from first-attempt accuracy to convergence on long-horizon tasks: whether it can keep the goal from drifting across hundreds of interactions, extract useful signal from failures, and push metrics higher under a fixed budget.

    2. What Long-Horizon Coding Tasks Are, and Why They Are the Main Battleground

    A long-horizon task can be abstracted as a constrained optimization problem: the objective function is maximized within clear correctness boundaries, and every tool call is a costly sample. Take “optimize vector retrieval throughput” as an example. Its formal description looks roughly like this:

    1. maximize QPS
    2. subject to recall >= 0.95
    3. implementation must compile & pass tests
    4. budget: N iterations, M tool calls

    Compared with one-shot question answering, long-horizon tasks place three higher demands on an agent.

    The first is state management. Context expands quickly, with build logs, benchmark output, stack traces, and historical patches all tangled together. The model must learn to compress and summarize, keeping decision-relevant information and discarding noise.

    The second is strategy switching. When local optimization hits a plateau, further parameter tuning yields almost nothing, and it is time to change dimensions: move from index structure to quantization, or from single-threaded execution to batching and concurrent scheduling. Recognizing when it is time to change course is the core dividing line of long-horizon capability.

    The third is constraint guarding. Any aggressive optimization may cross a red line on recall, memory usage, or interface compatibility. The agent needs to run regression checks automatically after each change to avoid being “fast but wrong.”

    3. A Multi-Dimensional Evaluation View: Do Not Watch a Single Score

    A single leaderboard score can easily hide the structure of capability. A more reliable approach is to build a multi-dimensional observation matrix covering at least the following directions:

    • Repository-level software engineering repair: locating and fixing defects in real projects, testing cross-file understanding and dependency reasoning.
    • Natural language to a complete repository: generating a buildable, testable multi-module project skeleton from a requirement description.
    • Terminal and command-line operations: running builds, tests, and log investigations in a real shell environment.
    • Tool-assisted reasoning and retrieval: combining search and web browsing to aggregate information and close the task loop.
    • Long-horizon benchmark optimization: iterating continuously on a given skeleton, with performance and constraint satisfaction as the final measure.

    One public result worth noting: a Chinese LLM scored 58.4 on a repository-level software engineering benchmark, slightly above the 57.7 and 57.3 of two leading international models from the same period. It scored 42.7 on natural-language repository generation, 63.5 on a terminal operations benchmark, 52.3 on tool-assisted reasoning, and 79.3 on web task handling. The score gaps are small, but combined with long-horizon optimization cases, its capability structure leans more toward “engineering usability.”

    4. Case Breakdown: The Engineering Logic Behind 600 Iterations

    In a public vector database optimization task, the model faced an approximate nearest neighbor retrieval skeleton implemented in Rust, with the goal of maximizing queries per second while keeping recall at or above 95%. The final result raised throughput from about 3,547 to about 21,500, nearly a sixfold increase, beating the previous best result on this task held by a leading international model.

    Breaking down the process yields four reusable engineering actions.

    1. Establish trustworthy measurement. Get the benchmark and correctness checks running first, so the gains and regressions of every later change can be quantified, avoiding “optimizing by feel.”
    2. Locate bottlenecks in stages. Use sampling and flame-graph-style analysis to confirm whether the bottleneck lies in distance computation, memory access, or scheduling overhead before choosing the main direction.
    3. Combine optimizations. Common techniques include vector quantization and compression, replacing inverted or graph index structures, SIMD and memory layout adjustments, and batching with concurrent pipelines.
    4. Enforce constraint regression. After each round of changes, automatically verify recall and compile tests, and roll back immediately once a boundary is crossed, ensuring that “faster” does not come at the cost of “more wrong.”

    The illustrative iteration control logic can be expressed like this:

    1. best = baseline()
    2. for step in range(max_steps):
    3. patch = propose(best, history=summary(history))
    4. candidate = apply_and_build(patch)
    5. if not candidate.passes_tests():
    6. history.append(reject(candidate, reason="tests"))
    7. continue
    8. metrics = benchmark(candidate)
    9. if metrics.recall < 0.95:
    10. history.append(reject(candidate, reason="recall"))
    11. continue
    12. if metrics.qps > best.qps:
    13. best = candidate
    14. history = compress(history) # control context growth

    What is truly hard here is not writing the patch, but the decision quality behind summary, compress, and propose: distilling from history which paths have already been disproven, retaining key evidence within the context budget, and proposing new hypotheses that match the current bottleneck.

    5. Implications for Enterprise R&D Adoption

    As long-horizon capability matures, agents can evolve from “code completion tools” into “delegable engineering executors.” When borrowing from this, enterprises are advised to start in three areas.

    First, turn tasks into verifiable closed loops. Configure benchmarks, tests, and constraint thresholds for each optimization goal, letting the agent self-verify within the loop rather than relying on manual review every round.

    Second, build context and memory infrastructure. Use logging services to collect runtime data, object storage to keep versioned artifacts, message queues to decouple the stage pipelines of long tasks, and monitoring and alerting to track the resources and progress of long-running tasks.

    Third, adopt layered human-agent collaboration. Let the agent handle iterative work that is “enumerable, measurable, and reversible,” while humans own goal definition, risk boundaries, and final acceptance. In related engineering practice, Baidu AI Cloud also emphasizes that embedding model capability into an observable, rollback-capable pipeline is a prerequisite for reliably landing long-horizon tasks.

    6. Limitations and Risks

    It is important to recognize that long-horizon capability still faces three types of risk. The first is reward hacking: the model may specialize for the benchmark rather than truly generalize. The second is cost overrun: hundreds of tool calls bring compute and expenses that require budget guardrails. The third is long-context decay: when history grows too long, key information may be diluted, causing goal drift. Countermeasures include hidden test sets, hard budget caps, periodic goal restatement, and external memory retrieval.

    7. Conclusion

    From “getting it right on the first pass” to “iterating 600 times to the finish,” the change in the measuring stick reflects a shift in the industry’s focus: coding agents are moving from answerers to executors. For developers, understanding the constraints, measurement, and strategy-switching mechanisms of long-horizon tasks holds more long-term value than chasing a particular leaderboard position.