Why Reinforcement Learning Scores for Coding Models Fluctuate: Benchmarks, Harnesses, and Reward Design
This article explains why post-trained coding agents often appear to double baseline scores on coding benchmarks, and why most of that gap comes from benchmark version drift, harness mismatch, scoring criteria overlapping with training data, reward design, and data allocation rather than a real generational jump in capability. It breaks evaluation into three layers (benchmark, harness, model), details how newer benchmark versions add vague prompts, veto checks, and engineering-compliance tests, shows how the same weights perform differently across scaffolds, and offers pseudocode for cost-penalized rewards and length-bucketed baselines. It closes with a practical checklist for running a credible comparison and a layered plan for reproducing and optimizing these capabilities in your own environment.
1. The Phenomenon: Post-Trained Models Beat the Baseline — But Are the Numbers Trustworthy?
In the coding agent space, one discussion comes up repeatedly: a team takes a general-purpose LLM, applies reinforcement learning post-training, and reports a coding agent that massively outperforms the original baseline on some coding benchmarks — sometimes more than 2x on individual leaderboards. At first glance this looks counterintuitive. Post-training is usually understood as alignment and enhancement of existing capability, not a generational leap in ability.
To judge whether such numbers are credible, you cannot look at a single leaderboard percentage. You need to split the evaluation stack into three layers: tasks and scoring criteria (the benchmark layer), the execution environment and toolchain (the harness layer), and the model’s own training and inference configuration (the model layer). Most “score doubled” disputes originate in the first two layers, not the third.
One premise has to be stated up front: a coding agent’s final score is not determined by model weights alone. It is a composite result of “model + prompt + tool-calling protocol + sandbox environment + grading script.” Any cross-model comparison that does not lock down the last four is essentially not comparable.
2. Cause One: Score Drift from Benchmark Version Iteration
Benchmarks themselves keep evolving. When a benchmark series moves from 1.x to 2.0, typical changes include:
- More blanks left in the prompt: instead of spelling out every requirement, the task gives a vague description close to what a real open-source maintainer would write, and the model must infer the implicit constraints.
- Veto items are introduced: hard checks are added following open-source pull request review standards. For example, the task only asks for a fix on path A, but a similar problem exists on path B in the repo; or the change is not compatible with other input types already supported by the repository; or the change introduces style and dependency-convention violations. Ordinary unit tests may pass, but the综合 review assigns a zero.
- Test coverage shifts from “functionally correct” to “engineering compliant”: regression tests, boundary conditions, backward compatibility, and consistency of docs and comments are all included.
The direct consequence is that all models score lower across the board, and the size of the drop correlates strongly with whether a model was specifically optimized for that benchmark. A structural phenomenon follows: when a new benchmark and a post-training approach come from the same ecosystem, that approach naturally understands the grading criteria better and its advantage is amplified, while a general baseline with no targeted adaptation gets compressed. This does not necessarily indicate a capability gap — it reflects a difference in overlap between the evaluation distribution and the training distribution.
So when you see “model X scores 2x the baseline on a new benchmark,” the first thing to verify is whether both numbers come from the same benchmark version, the same prompt template, and the same grading script.
3. Cause Two: Systematic Bias from Harness Mismatch
The second frequent cause is an inconsistent execution environment. Official results are often measured in a self-built command-line agent environment, and post-training was also done inside that environment, so tool-calling formats, context organization, and failure-retry strategies all match the training distribution. Run the same model under a different general-purpose harness and the score usually drops noticeably.
Take public third-party evaluations as an example: the same model can show a monotonic difference in pass rate across execution environments — roughly one level in the self-built command-line environment, a gain of several percentage points after switching to another coding command-line tool, and a further gain in a general agent framework built by the evaluator. This shows that performance differences for the same weights across harnesses can be on the same order of magnitude as the gains from a small-scale post-training run.
There are four main mechanisms by which the harness affects scores:
- Tool descriptions and calling protocol: if function signatures, parameter names, or error return formats differ from training time, the model produces a large number of invalid calls.
- Context management strategy: differences in file retrieval, code snippet truncation length, and history compression significantly affect success rates on long tasks.
- Execution and verification loop: whether tests are run automatically, whether multiple repair rounds are allowed, and timeout and retry settings directly determine whether you are measuring a “single-attempt pass rate” or a “multi-round pass rate.”
- Sandbox and pre-installed dependencies: missing dependencies turn tasks that were solvable into environment errors.
Practical advice: when comparing across environments, at minimum fix four variables — “benchmark version + prompt template + max rounds + whether running tests is allowed.” Otherwise the numbers mean nothing.
4. Cause Three: Reward Function Design and Length Bias
Back on the training side, the two most typical sources of instability in reinforcement learning for long-horizon software engineering tasks are cost blowup and response-length oscillation.
The former means the model tends to generate verbose patches and probe repeatedly; short-term reward looks fine but overall cost is high. The latter means rollout length oscillates back and forth during training, which increases the variance of advantage estimates and makes the training curve hard to converge.
Two common general approaches in the industry can be expressed with illustrative pseudocode:
# 1) Reward with cost penalty: account for token and tool-call costreward = task_score - alpha * token_cost - beta * tool_call_cost# 2) Length-weighted baseline: estimate the baseline per length bucket to reduce length-induced variancebaseline = length_bucket_mean(reward, bucket=reply_length)advantage = reward - baseline
The key point: the cost penalty term suppresses the degenerate strategy of “trading length for a pass,” while the length-weighted baseline separates length — a confounding variable — from the advantage estimate, so the training signal focuses more on the task itself. Combined, the two usually reduce rollout-length oscillation noticeably and improve stability on long-horizon tasks.
But it must be emphasized: these changes are training-stability and cost-efficiency optimizations. Their benefits show up mainly as faster convergence, lower variance, and a higher pass rate per unit cost. They cannot directly support a conclusion of “2x general capability.” Interpreting the gains from stability optimization as a generational capability gap is the most common logical leap in these discussions.
5. Cause Four: Mismatch Between Training Data and Capability Structure
Another easily overlooked angle is how the baseline model allocates training resources. When a general model puts a large share of compute into multimodal, 3D generation, game scenarios, and similar directions, its relative advantage on pure code and repository-level tasks may be compressed. In that case, a smaller post-trained model with a higher proportion of code data overtaking it on a specific coding benchmark is a result of resource allocation, not evidence that the benchmark is untrustworthy.
Judging this kind of issue requires looking at the capability profile rather than a single score: whether the same model performs evenly across sub-items such as repository-level repair, single-file completion, algorithm problems, front-end reconstruction, and test-case generation. Leading on one point while lagging on others usually points to data mix rather than overall capability.
6. How to Run a Credible Comparison
Here is a practical alignment checklist:
- Lock the benchmark and version: state the version number, the grading script, and whether veto items are included.
- Unify the harness: same harness, same tool protocol, same max rounds and timeout.
- Unify the prompt: including the system prompt, repository retrieval strategy, and output format constraints.
- Separate pass-rate definitions: single-attempt pass, best-of-three sampling, and pass after multi-round repair cannot be mixed.
- Report cost metrics: average tokens, average number of tool calls, end-to-end latency.
- Repeat runs and report confidence intervals: small-sample leaderboards fluctuate a lot, and a single result is not enough to support a conclusion.
- Publish failure cases: attributing zero-score cases is more informative than the total score.
7. Engineering Implementation Advice
To reproduce and optimize this kind of capability in your own environment, a layered approach works:
- Data layer: build a repository-level task set covering bug fixes, dependency upgrades, and compatibility patches, and keep tests that can be graded automatically.
- Training layer: use a reward with cost penalty and a length-bucketed baseline, and monitor the rollout-length distribution and advantage-variance curves.
- Inference layer: pin the harness version and track runtime metrics such as tool-call success rate, invalid-call rate, and average number of repair rounds.
- Infrastructure layer: use a container platform for environment isolation and dependency pre-installation, object storage to keep task snapshots and artifacts, and logging plus monitoring with alerting to track failure clusters for long-running tasks.
In related practice at Baidu AI Cloud, this combination of “containerized sandbox + logging and monitoring + elastic compute” is the key foundation for keeping the evaluation and training loop running stably.
8. Conclusion
Conclusions like “the post-trained model scores 2x the baseline” should, in most cases, be attributed first to benchmark version differences, harness mismatch, and overlap between scoring criteria and the training distribution, and only second to real gains from the reward function and training stability. The rational approach is to align evaluation variables first, then look at the capability profile, and only then discuss model capability itself. For engineering teams, rather than chasing single-leaderboard numbers, it is better to make cost, stability, and failure attribution into routine metrics — that is the sustainable optimization path.
