TL;DR
This guide develops RL for Code: Unit Tests as Reward, Replication Training, and SWE-Agent Post-Training from its central engineering problem to practical design choices and limitations. It synthesizes the roadmap topics without claiming new experimental results. Reported findings belong to the cited sources.
Target searches: “RL for code generation”, “training coding agents”
Why This Topic Matters
Modern LLM and agent training turns familiar reinforcement-learning ideas into systems problems: actions may be tool calls, rewards may come from fallible graders, and trajectories may span many partially observed steps. The classical foundation is POMDPs and belief states; this article focuses on what changes in the newer setting.
The Core Ideas
1. Why code is the ideal RLVR domain — the verifier already exists and it’s called the test suite
2. Reward design: pass rate, partial credit for compilation, penalties for test modification
3. Replication training (Mechanize’s thesis) — have the agent recreate a known implementation from spec; the reference gives a dense, cheap reward signal
4. The SWE-bench-style setup: repo, issue, patch, test
5. Reward hacking in code RL as a first-class problem — agents that edit tests, monkey-patch scoring, delete assertions, or exit early. Forward-link to E1
6. Long-horizon issue: real fixes span many files and many steps
Practical Checklist
- Define the state, action, termination condition, and reward before choosing an optimizer.
- Log raw trajectories and every reward component, not only the aggregate score.
- Separate training measurements from held-out evaluation and adversarial tests.
- Treat generated code, tool calls, and environment actions as untrusted.
- Record model, framework, benchmark, and grader versions so comparisons remain reproducible.
Limitations
This area changes quickly. Framework support and benchmark leaderboards are time-sensitive, while many recent methods are preprints rather than settled practice. The article describes mechanisms and reported evidence; it does not present an original training run.
Key Learnings
- Why code is the ideal RLVR domain — the verifier already exists and it’s called the test suite
- Reward design: pass rate, partial credit for compilation, penalties for test modification
- Replication training (Mechanize’s thesis) — have the agent recreate a known implementation from spec; the reference gives a dense, cheap reward signal