TL;DR
The paper introduces R2E-Gym, the largest procedurally-curated executable environment for training open-weight Software Engineering (SWE) agents. By combining a novel synthetic data generation recipe (SWEGEN) with a Hybrid Test-time Scaling approach that merges execution-based and execution-free verifiers, the authors achieve a new state-of-the-art 51.0% resolve rate on SWE-bench Verified, outperforming proprietary models like OpenAI o1-preview and Claude 3.5 Sonnet (with tools).
What Problem Does This Paper Address?
While large language models (LLMs) have shown massive potential as autonomous software engineers, the state-of-the-art performance is heavily dominated by closed-source, proprietary models. Open-weights models lag significantly behind.
The authors identify two fundamental bottlenecks preventing open-source models from catching up:
- Data Curation Bottleneck: Training effective SWE agents requires high-quality, executable environments (with unit tests and natural language problem descriptions). Existing benchmarks rely on human-written GitHub issues and pull requests (PRs), which are difficult to scale and often lack reproducible execution environments.
- Inference-Time Scaling Bottleneck: Maximizing performance at test-time requires smart verification to choose the best solution from multiple generated candidates. Existing verifiers are either execution-based (running tests) or execution-free (evaluating text trajectories), but both hit early performance plateaus when scaled independently.
Methods
To solve these challenges, the authors introduce two core contributions:
1. SWEGEN: Procedural Data Generation
Instead of relying on human-written issues, SWEGEN curates training data directly from raw GitHub commits.
- Environment Setup: It automatically extracts commit histories, filters for small-scoped bug fixes, and uses Docker to resolve dependencies and build reproducible environments.
- Test Generation: It identifies existing Fail$\rightarrow$Pass (F2P) tests or automatically generates new ones using the ground-truth patch as context.
- Back-translation: To create natural language problem statements, it uses LLM back-translation. Crucially, it prompts the LLM with both the code changes and the test execution traces (assertion failures), ensuring the generated issue accurately reflects the technical essence of the bug.
2. Hybrid Test-Time Scaling
To optimize test-time compute, the authors design a hybrid verification framework that ranks multiple agent-generated patches:
- Execution-Based (EB) Verifier: A specialized testing agent interacts with the environment to generate 10 diverse test cases per problem, scoring patches based on how many tests they pass, while a regression filter ensures backward compatibility.
- Execution-Free (EF) Verifier: A trajectory reward model (based on Qwen-2.5-Coder-14B) evaluates the agent's step-by-step reasoning thoughts, actions, and code patches to predict a correctness probability (YES/NO).
- The Hybrid Score: The verifiers are combined by using the execution-free model to filter the top-$n$ highest-quality trajectories, and then using the execution-based test pass counts to break ties and make the final selection.
Datasets
The authors introduce R2E-Gym, containing 8,135 instances with executable gym environments, unit tests, and natural language task descriptions.
To prevent data contamination during evaluation, they filter out repositories that overlap with the SWE-bench test set, resulting in R2E-Gym-Subset (4,578 instances) across 10 major Python repositories (including pandas, numpy, and pillow).
Evaluation is performed on the standard SWE-bench Lite and SWE-bench Verified benchmarks.
Key Insights and Ideas
- Synthetic Issues Match Real Ones: Remarkably, agents trained on procedurally generated synthetic issues achieved nearly identical performance (27.8%) to those trained on real, human-written GitHub issues (28.0%). This proves that simulation can successfully substitute for human data in SWE training.
- The Blind Spots of Verifiers: The paper provides a brilliant look into why standard verifiers plateau:
- Execution-based verifiers suffer from low distinguishability—for over 80% of problems, less than 20% of generated tests can successfully differentiate between top correct and incorrect patches. They are also vulnerable to rare "toxic tests" that accidentally pass buggy code but fail correct code.
- Execution-free verifiers provide better discrimination but are heavily biased by heuristics. Attention analysis revealed that these models disproportionately judge correctness based on the "sentiment" or confidence in the agent's thought process rather than the technical validity of the final patch.
- Complementarity Wins: Because the failure modes of EB and EF verifiers are completely orthogonal, combining them allows the hybrid model to bypass individual plateaus, jumping from ~43% to 51%.
Key Results
- Base Model Scaling: Supervised Fine-Tuning (SFT) on R2E-Gym trajectories significantly boosts base model performance. The Qwen-2.5-Coder-32B model trained on R2E-Gym achieved a 34.4% Pass@1 on SWE-bench Verified, a 14% absolute improvement over the previous SWE-Gym baseline.
- State-of-the-Art Scaling: When applying the Hybrid Verifier at test-time, the 32B model reaches 51.0% on SWE-bench Verified, setting a new state-of-the-art for open-weights models and matching or beating top-tier commercial systems.
Limitations and Future Work
- Dependency Resolution: Setting up historical execution environments remains a semi-manual, brittle process due to evolving API changes and dependency conflicts. The authors note that leveraging LLMs to fully automate Docker environment setup is a critical next step.
- Context Length Constraints: Due to compute limitations, the agents were trained with a maximum context length of 20K tokens. Implementing context-parallelism in future iterations will allow open-weights agents to tackle larger, more complex codebases.
Summary updated