Why Reinforcement Learning Post-Training Fails on Coding Benchmarks

    This article explains why a reinforcement learning post-trained model can score several times higher than its base model on some coding leaderboards, and why such gaps are usually not a "post-training magic" effect. It breaks down four main causes—reward design with cost penalties and length-weighted baselines, rollout length oscillation, harness coupling, and leaderboard version drift with stricter scoring—and outlines a reproducible debugging workflow plus engineering practices for keeping training and evaluation aligned.

    1. The Phenomenon: Score Inversions Are a Measurement Problem, Not Magic

    A familiar scene plays out on coding benchmarks: a base model without extra post-training is compared with a version of the same base model that has undergone reinforcement learning post-training, and the latter ends up leading by several times on some leaderboards. Results like this are often read as “post-training magic,” but the more common real cause is that the evaluation setup, the training objective, and the execution environment are not aligned.

    To judge how credible such a conclusion is, start by separating three things: model capability, the task harness, and the leaderboard version. A change in any one of them can move scores dramatically, yet they are frequently treated as the same thing.

    2. Four Main Causes

    1. Reward Function Design: Cost Penalties and Length-Weighted Baselines

    The core of reinforcement learning post-training is not “making the model smarter” but “making the model fit a particular reward definition.” Two approaches are common in the industry: introducing a reward with a cost penalty, which adds negative terms for the number of calls, execution time, and token consumption on top of correctness; and using a length-weighted reward baseline to reduce the impact of long samples on the variance of the gradient estimate.

    The pseudocode below is illustrative only and does not represent any specific implementation:

    1. # reward = task correctness - cost coefficient * resource consumption
    2. def reward(task_ok: bool, steps: int, tokens: int,
    3. cost_alpha: float = 0.01) -> float:
    4. return float(task_ok) - cost_alpha * (steps + tokens / 1000)
    5. # Length-weighted baseline: estimate the mean per sample-length group to reduce variance
    6. def advantage(r, baseline_by_len_bucket, bucket):
    7. return r - baseline_by_len_bucket[bucket]

    The problem is that this kind of reward systematically favors “short, fast, minimal-change” solutions. When a leaderboard’s scoring criteria happen to reward fixing related issues along the way and staying compatible with the repository’s existing input types, the training objective and the evaluation objective point in opposite directions, so the score is naturally pushed down. This is not model degradation but a mismatch of optimization objectives.

    2. Rollout Length Oscillation: A Typical Symptom of Post-Training Instability

    Sampling trajectory lengths vary enormously on long-horizon software engineering tasks. During training, the average length can swing back and forth, the reward curve can jitter, and the policy can oscillate between “change a bit more” and “change a bit less.” Common mitigations include estimating baselines per length bucket, truncating overly long trajectories and assigning partial credit, reducing the per-step update magnitude, and normalizing and clipping advantage values. If these are not handled properly, training may converge to a “conservative but short” policy that loses points on tasks requiring cross-file reasoning.

    3. Harness Coupling: The Same Model Is Not Comparable Across Execution Frameworks

    Post-training is often deeply bound to a particular harness: the system prompt, the tool set, the way context is organized, and the failure-retry strategy all become part of the training distribution. Evaluating that model in a different framework amounts to running it out of distribution, and a score drop is the expected result. A difference of several percentage points for the same model across frameworks is common, so cross-framework score comparisons are essentially inconclusive.

    4. Leaderboard Version Drift and Tighter Scoring Rules

    When a new benchmark version deliberately leaves requirements open in the prompt instead of spelling them out, and introduces “instant fail” items based on open-source maintainer review standards, most models see their scores drop across the board. Fixing only the specified path without handling related issues or staying compatible with existing input types can be scored zero outright, even if the unit tests pass. If the leaderboard and the post-training come from the same ecosystem, the scoring preferences are more likely to be internalized, and such high scores need to be interpreted more cautiously.

    3. A Reproducible Debugging Path

    1. Fix the base model and decoding parameters, switch only the post-trained version, and run a controlled comparison.
    2. Evaluate the same model in at least three harnesses: the training harness, your own command-line harness, and a general third-party evaluation harness, and observe the size of the score gaps.
    3. Report confidence intervals and sample sizes; do not draw conclusions from a single run, and manually review every zero-scored sample one by one.
    4. Break down the metrics: pass rate, average change size, average number of steps, cost per task, and timeout rate, instead of looking only at the total score.
    5. Check the trajectory length distribution and reward variance in the training logs to confirm whether oscillation or collapse has occurred.

    4. Engineering Practice Recommendations

    • Reward design should state the tradeoff explicitly: when correctness takes priority, the cost penalty coefficient should be small enough not to overpower the main objective.
    • Build an internal regression set covering three scenarios—cross-file fixes, input compatibility, and regression risk—to prevent leaderboard-chasing overfitting.
    • Decouple the training and evaluation harnesses, and keep at least one evaluation channel that is independent of training.
    • If you use cloud resources, you can use a container platform for environment isolation and reproducibility, object storage to save trajectories and artifacts, and logging and monitoring services with alerting to track reward curves and length distributions, keeping experiments traceable.

    5. Conclusion

    A “doubled score for the post-trained version” is more likely the combined result of the reward definition, the execution harness, and the leaderboard version than a pure improvement in model capability. Separating the variables, making the measurement criteria explicit, and folding cost into the metrics is the right way to judge whether a benchmark score is credible.