NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Code-A1: Adversarial Evolving of Code LLM and Test LLM via Reinforcement Learning

Aozhe Wang, Yuchen Yan, Nan Zhou, Zhengxi Lu, Weiming Lu, Jun Xiao, Yueting Zhuang, Yongliang ShenarXiv 2026

TL;DR

Code-A1 introduces an adversarial co-evolution framework that pairs a Code LLM with a Test LLM to continuously challenge and improve each other via reinforcement learning. By architecturally separating code generation from test generation, it eliminates the "self-collusion" risks plaguing single-model self-play systems and safely unlocks white-box test generation. The resulting models match or exceed the performance of those trained on human-annotated data while significantly boosting test generation capabilities.

What Problem Does This Paper Address?

Using Reinforcement Learning (RL) to improve code generation relies heavily on executable unit tests to provide verifiable rewards. However, high-quality, human-annotated test suites are scarce, static, and fail to adapt as a model's capabilities evolve.

To bypass this bottleneck, recent approaches have turned to "self-play" frameworks where a single model generates both the code and its corresponding tests. This introduces a fundamental dilemma:

  1. White-box access (allowing the model to see its own code while writing tests) leads to self-collusion, where the model generates trivial tests to guarantee easy rewards.
  2. Black-box restriction (limiting the model to only see the problem description) prevents collusion but results in generic tests that miss implementation-specific bugs.
Comparison of three training paradigms for code generation.

Methods

The authors propose Code-A1, which decouples code and test generation into two separate models with opposing objectives:

  • Code LLM: Rewarded for passing more tests, incentivizing robust and correct code solutions.
  • Test LLM: Rewarded for exposing defects in the Code LLM's solutions, incentivizing the discovery of edge cases and subtle bugs.

Because the models are separate, the Test LLM can safely perform white-box testing—inspecting the candidate code structure to craft targeted adversarial tests—without any risk of self-collusion.

Overview of the Code-A1 training framework.

To stabilize this adversarial dynamic, Code-A1 introduces two key mechanisms:

  1. Mistake Book: A per-question experience replay buffer that records historically failed tests. This prevents the Code LLM from regressing on previously fixed bugs (catastrophic forgetting) and provides a stable baseline for reward computation.
  2. Composite Reward Shaping: The Test LLM receives a reward that balances test validity (it must execute correctly against a ground-truth oracle) with adversarial difficulty (it must successfully break the Code LLM's candidate code).
  3. TopVar Sampling: To balance compute, the framework uses an asymmetric sampling strategy that prioritizes updating the Test LLM only on test suites exhibiting the highest reward variance.

Datasets

  • Training: 9,688 hard-difficulty programming questions from KodCode-V1.
  • Code Evaluation: Evaluated across three standard benchmarks: HumanEval+, MBPP+, and BigCodeBench.
  • Test Evaluation: Evaluated on a 10% subset of UnLeakedTestBench using metrics like pass@k (test accuracy) and mut@k (mutation score/bug-finding power).

Key Insights and Ideas

  • Decoupling is the Antidote to Collusion: Architectural separation completely resolves the self-play cheating loophole. It turns white-box access from a vulnerability into a debugging advantage.
  • Dynamic Curriculum Generation: The adversarial setup creates a natural curriculum. Early on, the Test LLM generates simple tests. As the Code LLM masters them, the Test LLM is forced to find increasingly subtle edge cases to earn rewards, pushing both models past static performance ceilings.
  • Adversarial Training Beats Parameter Scaling: Co-evolution discovers bug-revealing patterns so effectively that smaller models trained with Code-A1 can outperform significantly larger base models on test generation tasks.

Key Results

The authors evaluated Code-A1 using Qwen2.5-Coder models at three scales (1.5B, 3B, and 7B).

  • Code Generation: Code-A1 consistently achieved the highest average scores, outperforming both the static "Golden Tests" baseline (trained on human annotations) and standard Self-Play across all model sizes.
  • Test Generation Efficiency: The 3B Test LLM trained via Code-A1 achieved a composite test quality score (Mul score of 15.29) that surpassed the much larger 7B Base model (14.72).
Performance comparison of Code LLMs across benchmarks.

Limitations and Future Work

  • Dependence on Ground Truth: Code-A1 still requires ground-truth solutions during the training phase to validate whether the Test LLM's generated tests are correct. This limits its use in domains where reference implementations do not exist.
  • Strict Format Constraints: The framework relies on simple assertion-based test formats (assert func(args) == answer). This excludes complex testing paradigms like stateful interactions, property-based testing, or I/O-heavy validations.
  • Language and Scope Limits: The current implementation was exclusively trained and evaluated on Python function-level generation. Extending the co-evolution dynamics to other languages and multi-file repositories remains an open challenge.

Summary updated

BibTeX
@misc{wang2026code,
  author = {Aozhe Wang and Yuchen Yan and Nan Zhou and Zhengxi Lu and Weiming Lu and Jun Xiao and Yueting Zhuang and Yongliang Shen},
  title = {{Code-A1: Adversarial Evolving of Code LLM and Test LLM via Reinforcement Learning}},
  year = {2026},
  eprint = {2603.15611},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.15611},
}
Figure