How Reinforcement Learning Doubles Coding Agent Scores: A Practical Framework

    This article explains why coding agents built on the same base model can show a 1.5x score gap after different post-training strategies, and how reinforcement learning drives that difference. It covers aligning evaluation metrics, building verifiable task sets, designing layered rewards, training tool-use and multi-turn repair loops, and tuning model combinations for team versus solo formats. You will find a reproducible experiment matrix, common pitfalls, and implementation guidance for stable score gains.

    1. Background: Why the Same Base Model Plus RL Produces a 1.5x Gap

    A common pattern in coding agent projects is that two systems built on the same base model end up with very different pass rates on coding benchmarks after different post-training strategies. The original comparison is representative: the base version scores about 38.9%, while the reinforcement-learning-enhanced version reaches 58.2%, nearly 1.5x higher. In the solo format, the enhanced version ranks near the top with a 66.0% pass rate, while a general-purpose flagship model leads in the team format but shows a different ranking in the solo format.

    This suggests the score gap does not come simply from a larger model. It is more likely the combined effect of three factors:

    1. How well the training objective aligns with the evaluation objective;
    2. How trainable tool calling and multi-turn repair are;
    3. Whether the format (team or solo) amplifies or cancels out collaboration gains.

    Setting aside specific product attributes, this article abstracts the phenomenon into a general technical question: how a post-trained agent can reliably improve on coding benchmarks, and provides an actionable implementation framework.

    2. Align the Evaluation First: Turn “Score” into an Explainable Metric

    Many teams skip this first step when reproducing experiments, which makes results incomparable. Fix the following definitions before training starts:

    • Pass rate definition: passed cases / total cases, with ties and failures counted separately;
    • Goal difference (for/against): account for “newly passed” and “introduced regressions” separately to avoid fixing one thing and breaking two;
    • Format segmentation: report team format (main model plus auxiliary models/sub-agents) and solo format (single model) separately;
    • Controlled variables: keep the base model, post-training method, decoding parameters, toolset, and context length identical, changing only one variable at a time.

    The scoring logic can be written schematically as:

    1. def score(result):
    2. passed = len(result.passed_cases)
    3. total = len(result.total_cases)
    4. regressed = len(result.regression_cases)
    5. rate = passed / total
    6. # Net gain: benefit after subtracting regressions
    7. net = passed - regressed
    8. return {"rate": rate, "net_gain": net, "goal_diff": (passed, regressed)}

    Only by tracking net gain can you explain why some combinations have a decent pass rate but rank lower: their regression counts are usually higher.

    3. Data Construction: The Task Pool Sets the Ceiling for RL

    The fuel for reinforcement learning in coding is a set of verifiable tasks. Construction should cover four categories:

    1. Bug fixing: given failing cases and repository context, pass tests with minimal changes;
    2. Feature implementation: given an interface contract and tests, complete the implementation;
    3. Refactoring and migration: adjust structure while preserving behavior;
    4. Multi-file coordination: cross-module changes that test dependency reasoning.

    The key principle is verifiability: every task needs an automated judging script so the reward is not fooled by text that merely “looks correct”. On the data side, deduplicate and stratify by difficulty to avoid policy degradation caused by many near-duplicate samples.

    4. Reward Design: From Sparse Outcomes to Learnable Process

    Coding task rewards are naturally sparse (pass/fail), and training directly on them is often unstable. A layered reward works better:

    • Outcome reward: test pass rate, net gain;
    • Process reward: whether the problem is reproduced first, whether tests are run, whether changes are minimal;
    • Constraint penalties: introduced regressions, broken public interfaces, overly long irrelevant changes.

    A simplified reward function:

    1. def reward(traj):
    2. r = 2.0 * traj.pass_rate # Outcome
    3. r += 0.5 * traj.reproduced_bug # Process: reproduce first
    4. r += 0.3 * traj.ran_tests # Process: run verification
    5. r -= 1.5 * traj.regression_rate # Penalize regressions
    6. r -= 0.2 * traj.diff_size_ratio # Penalize large, unnecessary diffs
    7. return r

    This design teaches the policy to verify before modifying, significantly lowering the regression rate and improving the “against” side of the goal difference.

    5. Tool Calling and Multi-Turn Repair: Train “Can Modify” into “Can Verify”

    The common trait of high-scoring agents is not getting it right in one shot, but having a closed loop:

    1. Read the repository structure and relevant files;
    2. Run tests or static checks to reproduce the failure;
    3. Generate a minimal patch;
    4. Run tests again; on failure, read the errors and continue fixing;
    5. Once converged, output a change summary.

    During training, include tool-call trajectories in context management and control irrelevant information growth. For long-context scenarios, use segmented retrieval and summary compression so key error messages are not buried.

    6. Team Format: The Auxiliary Model Is a Cost-Capability Tradeoff, Not Dead Weight

    The original material shows that the same main model paired with different auxiliary models yields clearly different pass rates (21.5%, 20.3%, and 84.5%, etc.). This is not surprising: when an auxiliary model handles sub-agent tasks and lacks capability, it introduces noise and regressions. Engineering recommendations:

    • Capability matching: the auxiliary model should at least be stable at retrieval plus local modification;
    • Cost tiering: push high-frequency, low-difficulty subtasks down to lightweight models, and leave cross-module reasoning to the main model;
    • Result verification: sub-agent output must be reviewed by the main model or test scripts to keep noise out of the patch.

    7. Solo Format: Single-Model Capability Depends on Post-Training Depth

    The solo format has no collaboration gains, so rankings reflect post-training quality more directly. The enhanced version reaching the top with 66.0% shows reinforcement learning is equally effective for a single model. Focus optimization on:

    • Long-chain self-correction;
    • Semantic understanding of error messages;
    • Minimal-change strategies.

    8. A Reproducible Experiment Matrix

    Use the following matrix for controlled comparison so conclusions are attributable:

    Group Base Model Post-Training Format Metrics
    A Same base None Team Pass rate, regression count
    B Same base RL Team Net gain
    C Same base RL Solo Long-chain repair success rate
    D General flagship None Solo Stability

    9. Common Pitfalls and How to Avoid Them

    • Looking only at pass rate: ignoring regressions overestimates gains;
    • Too-weak auxiliary model: drags down the team format;
    • Gameable reward: poor process-reward design leads to “pretending to run tests”;
    • Context bloat: key errors get truncated in large repositories;
    • Evaluation leakage: overlap between training and evaluation sets inflates scores.

    10. Conclusion

    The essence of “same base model, doubled gap” is that post-training hardens a verifiable coding loop into the policy: reproduce, minimal change, verify, collaborate. For developers, the reliable path to stable score gains is to align evaluation definitions first, then train with layered rewards and a tool-use loop, and finally match model combinations to the format.