[Paper Review] Code-A1: Adversarial Evolving of Code LLM and Test LLM via Reinforcement Learning
Code-A1 introduces adversarial co-evolution of a Code LLM and a Test LLM, enabling white-box adversarial test generation with a Mistake Book for stable RL training, achieving strong code-generation and test-generation performance without human-annotated tests.
Reinforcement learning for code generation relies on verifiable rewards from unit test pass rates. Yet high-quality test suites are scarce, existing datasets offer limited coverage, and static rewards fail to adapt as models improve. Recent self-play methods unify code and test generation in a single model, but face a inherent dilemma: white-box access leads to self-collusion where the model produces trivial tests for easy rewards, yet black-box restriction yields generic tests that miss implementation-specific bugs. We introduce Code-A1, an adversarial co-evolution framework that jointly optimizes a Code LLM and a Test LLM with opposing objectives. The Code LLM is rewarded for passing more tests, while the Test LLM is rewarded for exposing more defects. This architectural separation eliminates self-collusion risks and safely enables white-box test generation, where the Test LLM can inspect candidate code to craft targeted adversarial tests. We further introduce a Mistake Book mechanism for experience replay and a composite reward balancing test validity with adversarial difficulty. Experiments on Qwen2.5-Coder models demonstrate that Code-A1 achieves code generation performance matching or exceeding models trained on human-annotated tests, while significantly improving test generation capability.
Motivation & Objective
- Motivate improving verifiable rewards for code generation beyond scarce static test suites.
- Propose a decoupled adversarial framework with opposing objectives for Code LLM and Test LLM to avoid self-collusion.
- Introduce a Mistake Book to stabilize experience replay and track historical failures.
- Design composite rewards balancing test validity and adversarial difficulty.
- Demonstrate that adversarial co-evolution matches or exceeds human-annotated-test RL while producing better tests.
Proposed method
- Decoupled dual-model architecture with Code LLM generating candidate solutions and Test LLM generating challenging tests conditioned on the code.
- Adversarial rollout: generate multiple code candidates, generate multiple test suites per candidate, validate tests against the ground-truth solution, and execute code with validated tests to obtain pass rates.
- Mistake Book: per-question experience replay storing historically failed tests to stabilize rewards and track capability evolution.
- Composite rewards: Code LLM reward combines historical and new test pass rates to encourage robustness; Test LLM reward balances test validity and adversarial difficulty via a weighted sum.
- Policy optimization via Group Relative Policy Optimization (GRPO) with asymmetric sampling and top-variance selection to balance training Compute.
- Training dynamics foster curriculum-like co-evolution where stronger code demands harder tests and harder tests push for stronger code.

Experimental results
Research questions
- RQ1How can we safely enable white-box adversarial test generation without self-collusion?
- RQ2Can adversarial co-evolution of Code LLM and Test LLM outperform RL trained on human-annotated tests across multiple code benchmarks?
- RQ3Does a Mistake Book stabilize training and prevent catastrophic forgetting during adversarial co-evolution?
- RQ4What is the impact of balancing test validity and adversarial difficulty on learning dynamics and final performance?
- RQ5Can test generation quality from Code-A1 match or surpass traditional golden-test RL approaches?
Key findings
- Code-A1 matches or exceeds models trained on human-annotated tests for code generation across HumanEval+, MBPP+, and BigCodeBench.
- The Test LLM in Code-A1 achieves higher discriminative test generation capability than supervised fine-tuning or self-play baselines.
- A Mul score of 15.29 for the 3B model’s test generation surpasses the 7B base model’s 14.72, indicating efficiency from adversarial co-evolution.
- The Mistake Book stabilizes training and enables progressive uncovering of bugs, with historical failures guiding reward computation and preventing forgetting.
- Removing white-box access, the Mistake Book, or the predicted-answer requirement degrades performance, confirming the contributions of each component.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.