Understanding Score Gaps in Long-Horizon Coding Reinforcement Learning
When the same base model appears to double its score on long-horizon software engineering benchmarks, the leap rarely reflects raw capability gains alone. This article breaks down three factors behind such score differences—evaluation protocol design, coupling between training harness and execution environment, and reward constraints on trajectory length and cost—and explains how to judge whether a score is reproducible and transferable. It also covers practical techniques for stabilizing long-horizon RL training, including cost-penalized rewards, length-weighted baselines, and structured negative labels, offering actionable guidance for both training teams and benchmark readers.
Reinforcement learning on long-horizon software engineering tasks is not about completing code in a single shot. The goal is to train agents to make multi-step decisions across repositories, tests, review criteria, and toolchains. When public leaderboards show “the same base model, double the score,” readers tend to interpret it as an absolute leap in model capability. A more rigorous explanation usually comes down to three things: whether the evaluation prompt pins requirements down completely, whether the agent is scored in an execution environment consistent with its training, and whether the training reward constrains trajectory length and cost. Only by separating these three factors can we judge whether a score is transferable and reproducible.
The Evaluation Protocol Can Be “Harder” Than the Model
Some difficult coding benchmarks deliberately leave large gaps in the prompt: they describe only the path to fix or the surface symptom, without turning acceptance criteria into a mechanically checkable checklist. The review standard resembles how open-source maintainers judge a pull request: were similar defects fixed in other paths as well, does the change stay compatible with input types already present in the repo, and does it introduce style or interface breakage? A solution can pass all ordinary unit tests and still be vetoed outright for “not handling adjacent paths along the way,” scoring zero for the entire task.
This kind of protocol has two direct consequences. First, models not trained against this review style lose points systematically, because the training distribution rewards “tests green,” while the evaluation distribution rewards “reviewer satisfied.” Second, if a version upgrade replaces fully specified requirements with open-ended ones, scores across the board may drop—this does not mean every model got weaker simultaneously. When reading a leaderboard, ask first: is the prompt closed-ended, do veto conditions appear explicitly in the training labels, and does a zero score reflect functional failure or review failure?
Open-ended prompts also amplify long-horizon errors. If an agent fixes only path A while the same class of bug remains in path B, the trajectory looks locally successful but fails globally. If RL uses only the terminal test as a sparse reward, the gradient cannot distinguish “one step short of passing review” from “completely wrong,” and the policy drifts toward the shortest patch that passes tests rather than the complete fix maintainers expect.
Coupling Between the Execution Environment and the Training Harness
Agent performance depends heavily on the runtime: CLI tool wrappers, file-editing interfaces, test runners, timeout and retry policies. A model trained with RL on one toolchain bakes that environment’s interaction habits into its policy: when to read files, when to run tests, how to parse errors. Swap in a different general-purpose executor, and the same weights may lose several percentage points. This is distribution shift, not “the model suddenly got dumber.”
In practice, three kinds of scores should be distinguished: in-training-environment scores, official reproductions on the same vendor or protocol, and third-party cross-environment reproductions. Only the third kind demonstrates general capability. Fair comparisons must align on the same prompt version, the same timeouts, and the same rules on network access and dependency installation. Otherwise, a “doubling” may just mean one side rolls out its policy in a familiar closed loop while the other pays an interaction tax in an unfamiliar CLI.
From an engineering standpoint, the way to decouple this is to split the policy into “reasoning and patch generation” and an “environment adaptation layer.” The former is trained on neutral repository states and test summaries; the latter uses thin adapters to connect to concrete commands. Evaluation reports should disclose adaptation-layer differences, so adaptation capability is not counted as base-model capability.
The Core Difficulty of Long-Horizon RL: Length Oscillation
Trajectories on long-horizon tasks can span tens to hundreds of steps. If the reward arrives only at the end, the policy oscillates between “writing long trajectories to get lucky” and “submitting too early”: average return rises in one phase, then average length goes out of control in the next, and training becomes unstable. Sources of oscillation include: value-function bias on variable-length trajectories, advantage estimates not normalized by length, sampling temperature drifting with length, and cost (steps, tokens, tool calls) not being part of the reward.
Two families of techniques are commonly used for stabilization, and they should be used together.
First, rewards with cost penalties. On top of the task-success reward, add small negative terms for steps, invalid tool calls, and repeated edits, so the policy prefers “the shortest feasible trajectory that fully completes the task” rather than padding length. Set the penalty coefficient too high and the model becomes timid, submitting only minimal patches; too low and the oscillation persists. Penalties should be tiered by task difficulty, or introduced through a curriculum: short tasks first, long repositories later.
Second, length-weighted reward baselines. Estimate the baseline using samples whose trajectories are similar in length to the current one, rather than subtracting a global mean from a high-variance long trajectory. With length weighting, the advantage better reflects “whether it performed better at equal length,” and the gradient is not dominated by an occasional lucky super-long success. Baselines can also be computed per phase (localization, modification, verification) to reduce cross-phase incomparability.
On the data side, ensure diversity among failure trajectories: review rejections, red tests, and timeouts should all enter replay as negatives; otherwise the policy just reinforces the “shortcut that passes unit tests.” For open-ended review, use structured labels (adjacent paths not fixed, input types not compatible) rather than a single scalar, which makes reward shaping easier.
How to Interpret “Doubling” and Where to Invest
When a system built specifically for software engineering RL far outperforms general-purpose LLMs on a given protocol, check first: is it derived from the same protocol as the benchmark, was it trained on the same executor, and did it apply dedicated constraints on length and cost? If the answers are mostly yes, the score mostly reflects “within-protocol optimization” and does not directly imply general capability is twice as good.
Conversely, if a general-purpose model allocates most of its compute to non-software-engineering scenarios, relative stagnation in long-horizon coding is consistent with resource allocation and needs no conspiracy theory. The more valuable question is whether the policy remains stable under open-ended review, cross-environment reproduction, and cost constraints. When all three hold, the improvement is more likely to transfer to real-world repository maintenance.
For training and evaluation teams, we recommend documenting protocol changes, harness differences, and reward formulas (including cost terms and baselines) in technical reports, and providing at least one reproduction on a neutral executor. For users, compare using the same prompt version, the same timeouts, and the same tool permissions, and track “tests passed” and “review passed” separately. Only then do scores in long-horizon coding RL turn from marketing numbers back into discussable engineering quantities.
