SWE-RL: Self-Play Software Engineering with Reinforcement Learning

December 26, 2025 ยท View on GitHub

License: MIT arXiv

An implementation of Self-play SWE-RL (SSR) - where AI agents create their own software engineering training tasks and learn to solve them.


๐Ÿ™ Based on Groundbreaking Research

This project implements concepts from:

"SWE-RL: Advancing LLM Reasoning via Reinforcement Learning on Open Software Evolution"

Yuxiang Wei, Olivier Duchenne, Jade Copet, Quentin Carbonneaux, Lingming Zhang, Daniel Fried, Gabriel Synnaeve, Rishabh Singh, Sida I. Wang

Meta AI (FAIR) โ€ข University of Illinois Urbana-Champaign โ€ข Carnegie Mellon University

๐Ÿ“„ Read the paper

We are deeply grateful to the research team for publishing this innovative work that demonstrates how reinforcement learning on real-world software evolution data can advance LLM reasoning capabilities.


๐ŸŽฏ What is SSR?

Self-play SWE-RL is a paradigm where:

  1. An Injector Agent creates realistic bugs in working code
  2. A Validator ensures the bugs are meaningful and solvable
  3. A Solver Agent attempts to fix the bugs using only test feedback
  4. Both agents improve through this self-play loop
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚   Inject    โ”‚ โ”€โ”€โ”€โ”€ Creates bug + oracle test
     โ”‚    Agent    โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
            โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚  Validate   โ”‚ โ”€โ”€โ”€โ”€ 7-step verification
     โ”‚  (7 steps)  โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
            โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚   Solver    โ”‚ โ”€โ”€โ”€โ”€ Fixes bug using test only
     โ”‚    Agent    โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
            โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚   Reward    โ”‚ โ”€โ”€โ”€โ”€ +1.0 if solved, 0.0 otherwise
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Repository Structure

โ”œโ”€โ”€ ssr-studio/          # Main implementation
โ”‚   โ”œโ”€โ”€ demo.py          # Run a complete episode
โ”‚   โ”œโ”€โ”€ examples/        # Sample project for testing
โ”‚   โ”œโ”€โ”€ src/             # Python backend
โ”‚   โ””โ”€โ”€ ui/              # Next.js dashboard
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md            # You are here

๐Ÿš€ Quick Start

cd ssr-studio
pip install openai anthropic rich pytest

# Run the demo (requires API key)
python demo.py --api-key YOUR_OPENAI_KEY

See ssr-studio/README.md for full documentation.


๐Ÿ”ฌ Key Innovation: 7-Step Validation

The SSR paper introduces rigorous validation for generated bugs:

StepValidation
1Test file exists
2Code parses correctly
3Original tests still pass
4Bug is in allowed scope
5Oracle test fails on buggy code
6Oracle test passes on clean code
7Inverse mutation testing

This ensures every generated training example is meaningful.


๐Ÿ“Š Research Applications

  • Training data generation - Create unlimited bug/fix pairs
  • Model evaluation - Compare LLM fixing capabilities
  • Self-improvement - Enable agents to generate their own curriculum
  • Benchmark creation - Generate SWE-bench-style tasks

๐Ÿ“„ Citation

@article{wei2024swerl,
  title={SWE-RL: Advancing LLM Reasoning via Reinforcement Learning on Open Software Evolution},
  author={Wei, Yuxiang and Duchenne, Olivier and Copet, Jade and Carbonneaux, Quentin and Zhang, Lingming and Fried, Daniel and Synnaeve, Gabriel and Singh, Rishabh and Wang, Sida I.},
  journal={arXiv preprint arXiv:2512.18552},
  year={2024}
}

๐Ÿ“„ License

MIT License - see LICENSE for details.