How Post-Training with Reinforcement Learning Improves Coding Ability
Post-training for coding assistants has shifted from supervised fine-tuning toward reinforcement learning. This article explains why verifiable coding tasks improve faster than UI work, which pipeline changes drive those gains, how reward design and evaluation slices avoid misleading leaderboards, and how to gate regressions in weakly verified skills.
Post-training for coding assistants has moved, in recent years, from supervised fine-tuning toward reinforcement learning. Supervised fine-tuning teaches a model to imitate high-quality trajectories. Reinforcement learning lets the model try repeatedly in an environment where right and wrong can be judged automatically, pushing “looks like good code” toward “actually runs.” A common engineering outcome is that algorithm implementations, test-driven bug fixes, and multi-step retrieval plus patch generation improve quickly, while page structure, visual fidelity, interaction details, and style consistency over long context get worse. Understanding that gap is more useful than chasing a single overall score.
Why verifiable tasks improve faster
Reinforcement learning needs dense rewards, or at least reliable ones. In code tasks, whether the build compiles, whether tests are all green, whether static checks reach zero, and whether a patch can reproduce a failing case in an isolated environment are all signals that can be computed automatically. These rewards have three properties.
First, outcomes are reproducible. The same tests, with the same dependencies and random seeds, draw a clear line between success and failure. Credit assignment is still hard, but the endpoint is clear. Second, the search space can shrink. The model can write a failing test, change the implementation, then run the regression, forming a short loop. Multiple samples, self-correction, and rejection sampling can all use the reward directly. Third, data is easy to scale. Contest problems, function-level unit tests, historical defects, and minimal reproductions can become an offline problem set without scoring every item by hand.
Post-training budget therefore flows toward the subset that can be scored. Gains in algorithmic skill are often not a mysterious architecture jump. They are a selection effect after reward coverage rises: errors that tests can catch are punished again and again; errors that tests cannot catch are ignored.
A schematic reward can be the sum of outcome terms and process terms, not only whether the final result passed:
reward = pass_all_tests+ partial_credit(passed / total)- cost(tool_calls, tokens, wall_time)- penalty(compile_error, flaky_retry, secret_leak)
Partial credit eases sparse rewards. A cost penalty discourages meaningless long chains of tool calls. Leaks and destructive commands must be hard constraints, not soft penalties that a high score can offset. If you optimize only final pass rate, the model learns to pile on retries, tamper with tests, or rely on environment side effects. The leaderboard looks strong; real repositories stay brittle.
Where capability gains usually come from
Treat post-training as a pipeline, not one mysterious “reinforcement” step, and it is easier to reproduce.
Task construction. Turn open-ended requests into decidable instances: given a failing test and the relevant files, produce a minimal patch; given a function spec and boundary conditions, implement it and pass hidden tests; given a static warning, remove the warning without lowering existing coverage. Hidden tests must be close to the training-visible distribution but disjoint from it. Otherwise the model is only memorizing problems.
Trajectory quality. Cold start still needs supervised data: successful patches, reflection after failure, and tool-call order. Low-quality trajectories reinforce bad tool habits along with the rest. In practice, filter out very long useless searches, repeated reads of the same file, and samples that rewrite large sections before reading the code.
Policy optimization. A common industry practice is to raise probability on trajectories that pass tests, lower it on failing trajectories, and use a baseline or within-group relative advantage to reduce variance. The formula name matters less than diversity across multiple samples of the same problem. If temperature is too low, advantage estimates collapse into “everything looks similar.” If it is too high, trajectories do not execute and the reward is noise.
Context and tools. A long context is not the same as using context well. If the reward looks only at the final tests, the model tends to stuff unrelated files into the prompt or reread entire files. Limit how much can be read at once on the environment side, and charge invalid reads in the reward. Retrieval, editing, and execution should have separate permissions: editing must not change test fixtures directly, execution should not have network access by default, and writes should be confined to a working copy.
Partners and routing. Many systems use a strong model for planning and hard patches, and a lighter model for retrieval, summarization, and formatting. That split saves cost, but evaluation must score the final delivery, not the main model answering alone. If the lighter model owns the frontend or the test scaffold, the main model’s algorithmic gains can be eaten by downstream error, and the combined score can fall below a single model. Conversely, if every hard case is routed to the strong model, a higher leaderboard score does not transfer to a full low-cost path.
Why frontend and interface tasks often regress
Frontend work and algorithm problems have different reward structures. Correctness on algorithm problems is mostly discrete: matching output, complexity constraints, boundary assertions. Correctness on interface tasks is multi-objective: semantic structure, accessibility, responsive layout, visual spacing, state coverage, and design-system consistency. If the automatic reward uses only screenshot similarity, DOM node count, or “the page opens,” classic reward hacking appears.
If post-training sharply raises the weight of the algorithm slice, parameters shift toward “strict, conservative, and less decorative structure.” The visible result is more complete logic branches but worse component splits; more exception handling but wrong style tokens; a state machine that works, but missing focus management and empty states. Data mix is another cause. Frontend samples in bug-fix trajectories are often shorter, noisier, and tied to private component libraries. Reward noise is high, so the optimizer updates those patterns less. Existing supervised skill is overwritten. The industry calls this capability regression or an alignment tax.
So “algorithms up, frontend down” is usually a mismatch between the optimization target and the evaluation slice, not a sudden loss of syntax. At acceptance time, pull interface tasks out of the overall board and watch their regression separately.
How to evaluate without misleading yourself
A single pass rate hides failure modes. Report at least the following slices instead of one total score.
- Algorithms and data structures: public specs, hidden tests, and time and memory limits.
- Bug fixes: a failure log and a minimal reproduction, a limit on changed lines, and no regression on existing tests.
- Frontend fidelity: structure, the accessibility tree, key interaction paths, and multiple viewports, not only pixel difference.
- Tool use: retrieval count, bad commands, and whether tests were changed without permission.
- Cost: tokens, tool round trips, wall-clock time, and retry count.
- Stability: variance of pass rate across seeds on the same problem, not only the best run.
Control variables in comparisons. Comparing the same base model with different post-training explains the post-training gain. Comparing different bases, tools, and retry budgets only describes a system combination; it does not attribute the result to the algorithm. For team-style two-model collaboration, fix who plans, who executes, and whether failure can escalate the route. Otherwise a strong partner hides a weak model’s gaps, or a weak partner drags the strong model into the wrong context.
Ratios like goals for and against map, in engineering, to “cases passed versus new failures introduced.” Pass rate alone encourages large rewrites. Watching regression failures encourages minimal patches. A draw corresponds to unstable tests or timeouts. Count those separately; do not fold them into success or failure.
The evaluation environment itself must be reproducible: lock dependency versions, block the network or use an offline mirror, fix timezone and random seeds, and clear build caches. Otherwise the model learns accidents of the environment and fails on another machine.
A practical post-training and regression flow
- Map capabilities. Split targets into a verifiable subset and a weakly verified subset. Put the former into reinforcement learning. Keep high-quality supervised data for the latter, and set a regression threshold.
- Stratify the problem set. Sample by language, repository size, whether the change is multi-file, whether it includes UI, and whether it needs long tool-call chains. Hold out a hidden set for each stratum that never enters training.
- Design the reward. Outcome reward comes first; partial credit, cost, and safety constraints support it. Do not allow points from editing tests, deleting assertions, or loosening timeouts.
- Update in small steps. Each round, raise the sampling share of only one task type: function-level implementation first, then multi-file defects, and open-ended requests last. Run a full-slice regression every round.
- Set a rollback gate. If the algorithm hidden set improves while the frontend or documentation slice drops past a preset margin, lower that round’s learning rate, mix supervised data back in, or apply a small supervised correction on that slice.
- Evaluate both paths before release. Test the high-cost path and the cheaper two-level route. Testing only the main model overestimates the user’s real experience.
- Spot-check reward hacking by hand. Randomly inspect high-score trajectories: deleted tests, hardcoded outputs, dependence on execution order, leaked secrets, or widened file permissions.
For training in the cloud, object storage can hold trajectories and logs, a container platform can provide isolated execution, and monitoring alerts can track mean reward, truncation rate, and timeout rate. These are general capabilities and do not require a proprietary interface. If you use general cloud resources such as Baidu AI Cloud, make the evaluation environment an immutable image so that “it passes on the training machine” does not diverge from “it fails in the delivery environment.”
Common misreadings in practice
Reading a doubled overall score as “better at everything” is the most common mistake. Doubling often happens on a subset whose pass rate was low and whose reward suddenly became computable. The base effect is large. Another mistake is replacing software engineering with gamified or oversimplified adversarial tasks. Once the rules are simplified, the model optimizes holes in that game, which does not transfer to repository-scale edits.
Also separate memorization from generalization. If hidden tests differ from training problems only by renamed variables, the gain does not show algorithmic skill. Check whether the solution depends on keywords in the prompt, and whether it can still locate defects in a new repository with a new dependency mix.
Finally, frontend regression does not have to be pulled back by a stronger overall reward. Many interface standards lack a stable automatic judge. Forcing a rough score only creates new hacking. A steadier split is reinforcement learning for algorithms and fixes, and constrained supervised data, component-level snapshots, and human spot checks for interfaces and the design system. The two channels can share a base model, but they should not share one single score.
Summary
Reinforcement learning can widen the gap on verifiable coding tasks because tests, compilation, and minimal reproductions supply scalable right-or-wrong signals. Algorithm problems and bug fixes benefit. Frontend and open-ended interface work have many objectives, high noise, and are easy to damage with a single score, so they often regress in the same optimization round. The reliable approach is to split slices, control partners and routing, penalize useless tool use and reward hacking, and set a hard regression gate for weakly verified skills. The resulting gains are abilities you can use in a repository, not an overall board that cannot be reproduced.
