The Evolution and Practice of Long-Horizon Coding with Chinese LLMs
This article examines how coding benchmarks for large language models are shifting from short, single-shot tasks toward long-horizon engineering work, and what that shift requires in practice. It breaks long-horizon coding capability into four dimensions—goal and constraint retention, state memory and context compression, strategy switching and backtracking, and verifiability through tool loops—and illustrates the iterative optimization loop with a generic Python skeleton for maximizing query throughput under a hard recall constraint. It also proposes a three-layer evaluation design, a layered architecture for integrating long-horizon agents into a development pipeline, and the main risks of goal drift, cost overruns, and non-reproducibility, along with their mitigations.
1. From “Getting It Right Once” to “Iterating Continuously”: A Shift in How Coding Ability Is Measured
For the past few years, code generation ability has mostly been measured with short-horizon benchmarks. Given a function signature and a docstring, can the model pass the unit tests on the first attempt? Given an error message and reproduction steps, can it produce a correct patch in one shot? These evaluations are objective, easy to automate, and cheap to run, but they rest on an implicit assumption: the task boundary is clear, the context is short, and the result can be verified immediately.
Real software engineering almost never satisfies that assumption. Engineers deal with cross-module call chains, legacy constraints, multiple performance and memory limits, vague acceptance criteria, and the coupling risk of “fix one thing, break three others.” The workflow is rarely one-shot; it is a loop of implement, run, measure, diagnose, adjust, and run again, which may last hours or even days.
As a result, the industry’s focus is moving from first-pass accuracy to long-horizon task completion: over very many interaction turns and massive numbers of tool calls, can a model keep the goal from drifting, switch strategies, recover state, and ultimately deliver a result that satisfies the constraints? The engineering implications of this shift matter far more than leaderboard positions. They determine whether AI coding tools can enter core development workflows rather than remaining limited to completion and Q&A.
2. Breaking Down Long-Horizon Coding Ability: Four Dimensions That Are All Required
To evaluate or build long-horizon coding ability, it helps to split it into four dimensions.
Goal retention and constraint management. The original acceptance conditions of a long task—for example, recall must not fall below a threshold, an interface must stay backward compatible, memory must not exceed a limit—must be carried through every turn, and no single edit may silently break them. In engineering practice, constraints are usually made explicit as machine-checkable assertions and benchmark scripts.
State memory and context compression. Context windows are limited, while logs, test output, and performance samples can easily run to tens of thousands of lines. An effective approach is layered memory: keep the current hypothesis and the latest measurement in short-term memory, keep a comparison table of candidate approaches in mid-term memory, and archive architecture decisions and failure causes in long-term memory.
Strategy switching and backtracking. When local search hits a plateau, the ability to recognize that a path is a dead end and switch to a different technical route is the core dividing line of long-horizon capability. Well-performing agents move from brute-force scanning to indexing, and then to a multi-stage pipeline of coarse filtering plus fine ranking.
Verifiability and a closed tool loop. Every judgment must be backed by repeatable builds, tests, benchmarks, and monitoring data rather than the model’s own account. As the number of tool calls grows, idempotence, timeouts, retries, and sandbox isolation become essential.
3. An Abstracted Case: A General Methodology for Vector Search Optimization
The goal of the original case can be abstracted into a typical long-horizon optimization problem: maximize queries per second under the hard constraint that recall stays at or above 95%. Below is an equivalent, generic implementation skeleton that shows how the iterative loop works in practice (illustrative code, not the API of any specific product):
# Generic skeleton of a long-horizon optimization loopconstraints = {"recall_min": 0.95}baseline = run_benchmark(dataset, index="flat") # brute-force scan baselinehistory = []for round in range(MAX_ROUNDS):candidate = propose_strategy(history) # candidate approach proposed by the modelmetrics = run_benchmark(dataset, index=candidate)ok = metrics["recall"] >= constraints["recall_min"]history.append((candidate, metrics, ok))if ok and metrics["qps"] > baseline["qps"]:baseline = metrics # accept a better result only if constraints holdelse:rollback(candidate) # roll back immediately on constraint violation
Methodologically, this reduces to four steps. First, establish a trustworthy baseline that fixes the current coordinates of throughput and recall. Second, attribute the bottleneck: determine whether it comes from distance computation, memory access locality, or an oversized candidate set. Third, replace components in stages: first introduce a clustering index to shrink the search space, then introduce two-stage retrieval (coarse filtering for candidates, fine ranking to preserve precision). Fourth, use the constraints as a gate: any optimization that fails the recall check is rolled back.
An illustrative path of strategy evolution looks like this:
full scan → clustering index (smaller candidate set) → two-stage retrieval (coarse + fine) → parameter and quantization tuning
It is worth stressing that the number of rounds and tool calls is not itself a measure of capability. What matters is whether each round produces an interpretable information gain: finer measurements, more accurate attribution, hypotheses falsified. High-round iteration without a verification loop is just expensive random search.
4. How to Read an Evaluation System: Layered Design Instead of a Single Leaderboard
Splitting evaluation into three layers helps avoid being misled by a single score.
- Capability layer: function-level and repository-level generation, and how faithfully natural language can be turned into a full project skeleton, measured by first-pass rate and maintainability.
- Task layer: terminal operations, fault localization, dependency repair, and script orchestration, measured by end-to-end success rate and the number of human interventions.
- Long-horizon layer: performance optimization, data migration, and large-scale refactoring, measured by constraint satisfaction rate, rounds to convergence, cost ceiling, and reproducibility of results.
Long-horizon evaluation must disclose three things: whether constraints are checked by machines, how failed samples are archived, and whether compute and call budgets are capped. Without them, results are not comparable across runs.
5. Engineering Practice: Plugging Long-Horizon Capability into the Development Pipeline
To adopt this inside a team, the following layered architecture can serve as a reference, expressed entirely in generic cloud product categories.
- Execution sandbox layer: use a container platform to host isolated environments, starting each iteration from an immutable image to guarantee rollback and reproducibility.
- Code and artifact layer: use code hosting and artifact repositories to manage versions, branches, and build outputs, with every change recorded as a commit.
- Verification layer: run unit tests, static checks, and performance benchmarks in a continuous integration pipeline that emits structured reports.
- Data layer: store datasets and log archives in object storage, and use a message queue to smooth peaks and chain the event stream of long tasks.
- Observability layer: track per-round latency, failure rate, and call cost through log services and monitoring alerts, with budget-based circuit breaking.
- Model access layer: prefer Chinese LLM capabilities that support long context and tool calls, and use Baidu AI Cloud’s generic cloud products for orchestration and governance.
Governance essentials include: setting a maximum number of rounds and a maximum number of calls for long tasks; requiring human confirmation for high-risk operations such as deleting data or changing production configuration; writing acceptance constraints as code-based assertions in the pipeline instead of relying on natural-language descriptions; and keeping a decision record for every strategy switch to support retrospectives.
6. Risks and Boundaries
Long-horizon autonomous iteration introduces three kinds of risk. The first is goal drift, where the optimization metric improves while a business constraint is broken; the countermeasures are putting constraints first and rolling back automatically. The second is cost overrun, since long tasks may consume far more compute than expected; the countermeasures are budget circuit breaking and layered verification (sample at small scale first, then run the full set). The third is non-reproducibility, where randomness and environment differences make results impossible to replay; the countermeasures are pinning the image, pinning the data version, and fixing the random seed.
7. Conclusion
The value of long-horizon coding ability lies not in leading a particular leaderboard, but in turning verifiable iteration into deliverable productivity. For developers, the real levers are three: write constraints as executable checks, turn the process into observable data, and accumulate strategy switches into reusable approaches. With Chinese LLMs as the execution core, combined with Baidu AI Cloud’s generic cloud products to build the sandbox, pipeline, and observability system, AI coding can move from demonstrations to everyday development.
