Why Reinforcement Learning–Trained Code Models Show Volatile Benchmark Scores
This article explains why the same base code model can score very differently across programming benchmarks and execution frameworks. It breaks the variance down into three sources: stricter, veto-based grading rules; differences in the agent scaffolding around the model; and distribution mismatch between the reinforcement learning environment and the evaluation environment. It also outlines reusable practices for reporting scores, building internal benchmarks, and aligning reward design with real merge standards.
1. The Symptom: Same Base Model, Scores Several Times Apart
In day-to-day work with code large models, a common and easily misread pattern shows up: the same base model can end up more than twice as far apart in final score when run on different programming benchmarks under different execution frameworks. A team that looks at a single leaderboard number can easily conclude that the model has doubled in capability, or that it has regressed.
Breaking this variance apart, it usually comes from three layers:
- Grading criteria: whether the rubric introduces hard, veto-style constraints;
- Execution framework: whether the scaffolding, tool-calling protocol, and context organization the model relies on are the same;
- Training distribution: whether the execution environment used during reinforcement learning comes from the same source as the evaluation environment.
Each layer is expanded below.
2. Tighter Rubrics: From “It Runs” to “It Can Be Merged”
Early programming benchmarks used relatively loose judging logic: given a problem description, the model produced a patch, the repository’s own unit tests were run, and passing meant a score. The new generation of benchmarks moves noticeably closer to the standard of an open-source maintainer reviewing a PR, with three main differences.
First, requirements are no longer spelled out. The prompt gives only a defect description for one main path, but implicitly expects the model to proactively identify the same class of problem recurring on other paths and other branches, and fix those as well.
Second, compatibility becomes a hard constraint. A patch must not break the repository’s existing input types, configuration options, or backward-compatible behavior; otherwise it is judged a failure even if the target case passes.
Third, judging is veto-based. Touching any single hard red line zeroes out that case outright, rather than deducting points proportionally.
The judging logic expressed in pseudocode:
def judge(patch, repo):if not run_target_case(patch, repo):return 0.0for rule in veto_rules: # compatibility, style, out-of-scope changes, etc.if rule.violated(patch, repo):return 0.0 # veto: single violation zeroes the casereturn 1.0
The direct consequence of this design: the score distribution shifts from continuous to roughly binary, marginal improvements in model capability are hard to reflect in the score, and any out-of-scope change is amplified into a zero. If the benchmark authors and the problem setters come from the same source, they have a natural advantage in understanding the rubric; an external model that has not been aligned against this class of constraint will see an overall score drop as a structural result, not a capability regression.
3. Execution Framework Differences: The Scaffolding Is Also a Variable
The second underestimated variable is the execution framework, the “scaffolding” around the model. It determines what the model can see, what it can call, and in what format it submits changes. Swapping frameworks for the same model commonly moves the score by 2–5 percentage points, for reasons including:
- Context organization: how repository retrieval results are trimmed and how code snippets are ordered, which directly affects the success rate of locating the defect;
- Tool protocol: the interface shape for file read/write, command execution, and test runs, plus the error-propagation format;
- Retry and budget: the maximum number of turns allowed, timeout, and recovery strategy after failures;
- How patches are applied: full-file rewrite versus minimal-diff editing, which affects the hit rate of veto rules.
Comparing scores across frameworks is therefore equivalent to comparing two different experimental conditions, and the conclusions are not comparable. The sound practice is to fix the framework, fix the budget, fix the random seed, and then compare side by side.
4. The RL Training Environment Determines Distribution Match
The third layer of causes comes from the training side. A typical pipeline for improving code ability with reinforcement learning has four stages:
- Collect execution trajectories: let the policy model trial-and-error over multiple turns in a runnable sandbox, recording “observation–action–reward”;
- Construct the reward signal: combine test-case pass rate, static checks, and patch-size penalties into a reward;
- Policy optimization: use methods such as group-relative advantage estimation to reduce reward variance and stabilize convergence;
- Evaluation alignment: validate in a framework from the same distribution as training, then move to a general environment to test generalization.
Two key conclusions. First, if the reinforcement learning stage is completed inside one particular scaffolding, the policy implicitly learns that framework’s prompt style and tool habits, and will inevitably lose points when transferred to a heterogeneous framework. Second, if the reward only rewards “target case passes,” the model will tend toward minimal changes, which is exactly the opposite of the evaluation expectation of proactively fixing the same class of problem. The improvement is to fold compatibility checks and same-class problem coverage into the reward, and to randomize across multiple frameworks during training to improve distribution robustness.
Illustrative reward construction:
reward = (1.0 * target_case_pass+ 0.5 * sibling_case_coverage- 0.3 * veto_rule_hit- 0.1 * normalized_patch_size)
5. A Reusable Checklist for Evaluation and Training
- When reporting scores, also state the benchmark version, execution framework, turn count, and timeout budget; without all of them, do not compare;
- Build an internal fixed benchmark set covering same-class defects across paths and backward-compatibility cases, so you are not pulled along by a single leaderboard;
- Cross-validate training and evaluation frameworks: same-source measures the upper bound, heterogeneous measures generalization, and the gap between them is the framework sensitivity;
- Add explicit penalties for veto items in the reward function to reduce zero scores caused by out-of-scope changes;
- Apply minimal-diff constraints and run static checks up front on patches, shifting veto risk to the left;
- Keep investing in general engineering capabilities such as repository retrieval, dependency analysis, and test generation; these transfer across frameworks.
6. Conclusion
Sharp swings in programming benchmark scores are, in most cases, not sudden changes in model capability but a combined effect of mismatched rubrics, execution frameworks, and training distributions. For engineering teams, the more reliable approach is to establish a reproducible evaluation standard, quantify framework sensitivity, and keep the reinforcement learning reward design aligned with real merge criteria. If you need to support large-scale sandbox execution, trajectory storage, and training job scheduling, you can build the pipeline on general cloud capabilities such as container platforms, object storage, message queues, and monitoring and alerting; Baidu AI Cloud offers corresponding support in these general infrastructure categories, though the actual selection should still be based on your own evaluation standard and compliance requirements.
