Reinforcement Learning for Coding Agents: A Practical Evaluation
This article presents a controlled evaluation of reinforcement learning for coding agents. It explains why replacing a base model with a stronger general-purpose model often fails to improve issue-resolution performance, then details the experiment setup, primary/auxiliary model routing, team and individual evaluation tracks, illustrative results, mechanisms behind the gains, a reproduction roadmap, and common pitfalls. The main finding is that task-specific post-training can produce measurable improvements, while weak auxiliary models can severely limit overall performance.
1. Background: Why a Stronger Base Model Often Does Not Help
When building intelligent coding tools, teams often make the same decision first: which base model to use. However, engineering practice repeatedly shows a counterintuitive result. Replacing the base model with a flagship model that has more parameters and a higher general-purpose benchmark score does not necessarily improve end-to-end issue-resolution success. In some cases, performance even drops.
There are usually three reasons:
Capability mismatch. General-purpose benchmarks measure broad knowledge and reasoning depth. Real software-engineering tasks measure something different: locating relevant files in an unfamiliar repository, understanding implicit conventions, and generating a minimal patch that can pass hidden tests. This depends heavily on long-context retrieval, tool-calling discipline, and self-correction after failure.
The agent scaffold is the bottleneck. The same model can perform several times better or worse depending on the retrieval strategy, command-execution sandbox, and context-compression method. The model is only one component of the scaffold.
The short-board effect in multi-model collaboration. When a primary model delegates subtasks to a much weaker auxiliary model, overall performance is often dragged down by the auxiliary model rather than lifted by the primary model.
Therefore, a more valuable question is not “which model should we choose?” but: Can reinforcement learning turn a general-purpose base model into a task-specific coding agent, and can we quantify its real gain over a general-purpose flagship combination?
2. Experiment Design: Controlling the Variables
The credibility of an evaluation depends on how the control groups are constructed. A rigorous comparison should keep the following factors identical: the task set, the sandbox, timeout and retry policies, and the maximum context length. Only the variable under test should change.
2.1 Control Group List
| Group | Primary Model | Auxiliary Model | Design Intent |
|---|---|---|---|
| G1 | General flagship A | General flagship B | Upper-bound reference |
| G2 | General flagship A | Lightweight fast model | Test whether replacing the criticized partner helps |
| G3 | General flagship A | Extra-large general-purpose model | Test whether pairing two strong models produces linear gains |
| G4 | General base M0 | Coding-specialized M1, post-trained from M0 | Same-origin control that isolates the post-training variable |
| G5 | General base M0 | Coding-specialized M2, further reinforcement-learned from M1 | Main focus of this study |
| G6 | General flagship A | Weak auxiliary model | Short-board effect control |
G4 and G5 are the most important comparison. The primary model is exactly the same. The only difference is whether the auxiliary model has undergone reinforcement-learning post-training for software-engineering tasks. The resulting difference can therefore be attributed more cleanly to post-training itself.
2.2 Engineering Motivation for Primary/Auxiliary Routing
The primary/auxiliary dual-model setup is not only for evaluation. It also reflects a common cost structure. The primary model handles planning and key decisions, while sub-agents handle high-frequency, low-difficulty calls such as searching, reading files, and running tests. These calls can be routed to a cheaper model.
Example configuration:
router:primary: model-primary # Planning, patch generation, final decisionsecondary: model-secondary # Default execution model for sub-agentsrules:- when: agent_role == "sub_agent"use: secondary- when: estimated_tokens > 120000use: primary # Long-context tasks fall back to the primary model- when: step_index > 40use: primary # Improve capability during long-tail repairfallback:on_timeout: primarymax_retries: 2
The hidden risk in this routing design is that if the secondary model is too weak, conclusions returned by sub-agents can pollute the primary model’s context and amplify errors. This is the mechanism behind the collapse observed in G6.
3. Evaluation Methodology: Team Track and Individual Track
The evaluation uses a dual-track design: a team track and an individual track. This makes it possible to measure collaboration gains and standalone capability separately.
- Team track: Two models form a primary/auxiliary pair and share one task budget. This measures collaboration efficiency.
- Individual track: A single model completes the task independently. This measures the standalone upper bound.
Metric definitions:
- Score rate = number of tasks passing all hidden tests / total number of tasks. This is issue-level and follows pass@1 semantics. Multiple samples for the same task are not allowed to select the best result.
- Win-tie-loss: Relative results are judged against a reference baseline. A tie means the patches are equivalent or fail in the same way.
- Patch:regression: The ratio of produced patches to regressions, where a regression means a previously passing test becomes failing. This helps identify cheating behavior such as deleting tests to improve scores.
Execution environment requirements: each task runs in an independent container. Dependencies are preinstalled, network access is restricted, and test commands are controlled by the evaluation side and hidden from the agent. Patches are collected in a unified diff format, replayed on a clean copy, and then evaluated with hidden tests.
4. Results (Illustrative Data)
| Rank | Participating Combination | Score Rate | Win-Tie-Loss | Patch:Regression |
|---|---|---|---|---|
| 1 | Flagship A + Flagship B | 99.5% | 787-4-1 | 9642:1035 |
| 2 | Flagship A + Extra-large C | 84.5% | 658-33-10 | 8290:2290 |
| 3 | Flagship D + Evolved E | 65.0% | 495-60-23 | 7456:2792 |
| 4 | Flagship F + General G | 60.1% | 455-63-27 | 4188:3558 |
| 5 | Base M0 + Coding-specialized M2 | 58.2% | 439-66-28 | 3980:3052 |
| 6 | Base M0 + Coding-specialized M1 | 38.9% | 284-73-43 | 2897:4583 |
| 7 | Flagship A + Weak auxiliary H | 21.5% | 140-92-56 | 1885:6173 |
| 8 | Flagship A + Lightweight K2-class model | 20.3% | 135-77-58 | 2577:5716 |
Individual track: the standalone coding-specialized model achieved a score rate of 66.0%. This is below the general-purpose flagship range of 79.8%–95.3%, but it is already in a usable range.
Three conclusions can be drawn:
Post-training gains are real. G5 improved from 38.9% to 58.2% compared with G4, while the primary model remained unchanged. The gain is about 19 percentage points. The patch:regression ratio also improved from 0.63 to 1.30, indicating that the improvement comes from fewer invalid and regression-inducing patches rather than more aggressive attempts.
The short-board effect is stronger than the long-board effect. The flagship primary models in the weak-auxiliary groups were dragged down to around 20%, below the same-origin base-model combination.
Collaboration still has a ceiling. G5’s 58.2% is still below the strongest combination’s 99.5%. This shows that post-training mainly solves standalone task capability. Retrieval quality, verification loops, and context management remain the main gaps in the team track.
5. Mechanism Analysis: Where the Gains Come From
(1) Verifiable rewards reduce reward-model bias. Software-engineering tasks naturally provide a binary signal: whether hidden tests pass. Compared with human-preference scoring, this reward is difficult to fool with patches that merely look reasonable. The gradient direction is cleaner.
(2) The training distribution aligns with the inference distribution. Post-training data is taken directly from real repository issue–patch pairs. The model learns a behavior sequence such as “reproduce first, locate next, then make the minimal change,” rather than a general question-answering distribution.
(3) Self-correction is explicitly rewarded. Multi-turn trajectories that include “run tests, read failure output, fix” are incorporated into training. As a result, the model is more willing to execute verification commands during inference and less likely to make a one-shot blind change.
(4) Long context and tool discipline. A context window of around 256k allows the model to hold repository structure, relevant files, and failure logs at the same time. Penalizing irrelevant file reads during training can significantly reduce ineffective exploration.
Pseudocode example:
for batch in replay_buffer.sample(batch_size):traj = rollout(policy, task=batch.task, scaffold=scaffold, max_steps=40)reward = run_hidden_tests(traj.patch) # 0/1 verifiable rewardreward -= 0.05 * traj.invalid_file_reads # Suppress ineffective explorationreward -= 0.10 * traj.regression_count # Penalize regressionsloss = policy_optimize(traj, reward, group_relative=True)if reward == 1 and len(replay_buffer) < cap:replay_buffer.add(traj) # Reuse for cold start and rejection sampling
In engineering practice, a three-stage approach is commonly used: rejection-sampling cold-start SFT, group-relative policy optimization, and difficulty curriculum sampling based on baseline pass-rate buckets. This avoids gradient vanishing caused by all-zero rewards in the early stage.
6. Reproduction Roadmap
Data layer: Construct issue–patch–test triples from historical pull requests in open-source repositories. Split by repository and by time. The training set must strictly predate the evaluation set to prevent contamination.
Sandbox layer: Use containerization, dependency snapshots, and a network allowlist. Hidden tests are executed only on the evaluation side. Large-scale concurrent rollback and trajectory archiving can rely on general cloud capabilities such as elastic containers, object storage, and logging services.
Training layer: Cold-start SFT, then reinforcement learning, then small-scale rejection-sampling iterations. Keep a fixed holdout set in each round to monitor overfitting.
Evaluation layer: Fix the scaffold version. Store the primary/auxiliary routing policy in configuration and version it. Any change on either side should be treated as a new experiment.
Rollout layer: During canary rollout, compare four metrics: score rate, average steps, regression rate, and cost per task. Roll back immediately if any metric deteriorates.
7. Common Pitfalls
- Reward hacking: The model modifies or skips tests. Countermeasures: make test files read-only, use a patch-path allowlist, and replay patches on the evaluation side.
- Data contamination: The training corpus includes future commits from evaluation repositories. Countermeasures: time-based splitting and near-duplicate detection.
- Metric overfitting: Repeatedly tuning on the same holdout set. Countermeasures: maintain a private rotating set.
- Ignoring the auxiliary model: Optimizing only the primary model. The data shows this is the lowest-return direction.
- Cost explosion: Sub-agents frequently call expensive models. Countermeasures: routing, context compression, and step limits.
8. Conclusion
The most important lesson from this controlled evaluation is that the capability ceiling of a coding agent is determined by task-specific post-training, scaffold design, and primary/auxiliary collaboration together, rather than by the general benchmark score of a single base model. Verifiable rewards give reinforcement learning a natural advantage in software engineering. The same-origin comparison, from 38.9% to 58.2%, provides clean causal evidence. Meanwhile, the collapse to around 20% caused by a weak auxiliary model reminds engineering teams to prioritize fixing short boards and verification loops. Solidifying this workflow—data splitting, sandboxing, reinforcement learning, dual-track evaluation, and canary rollout—is the sustainable path to continued gains.
