TL;DR
Researchers have introduced SWE-Gym, the first large-scale, executable training environment designed specifically for software engineering (SWE) agents. By fine-tuning open-weight models on successful trajectories within this environment and using a trained verifier to rank candidate solutions, the team achieved a new state-of-the-art for open-weight agents, reaching a 32.0% resolution rate on the SWE-Bench Verified benchmark.
The Problem: A Lack of Executable Training Data
While Large Language Models (LLMs) have shown immense promise in automating coding tasks, the most capable "agents" typically rely on proprietary models like GPT-4 or Claude. A major reason open-weight models lag behind is the scarcity of high-quality, executable training data for the software engineering domain.
Existing resources, such as the original SWE-Bench training set, provide "gold patches" (the final correct code), but they omit the step-by-step interactions, tool usage, and debugging processes a developer takes to arrive at that solution. Furthermore, they lack the pre-configured runtime environments (dependencies, libraries, etc.) needed to actually run and test code during training. Without a "gym" to practice in, open-weight models struggle to learn complex planning and debugging behaviors, often getting "stuck in loops" or failing to use tools effectively.
Methodology
The authors bridge this gap by creating an interactive environment where agents can execute code, receive feedback, and learn from their mistakes.
- Rejection Sampling Fine-tuning: The researchers collected 491 successful "trajectories" (sequences of thoughts, commands, and code edits) from powerful teacher models (GPT-4o and Claude 3.5 Sonnet) solving tasks in SWE-Gym. They then fine-tuned open-weight models (specifically Qwen-2.5-Coder) on these successful paths.
- Verifier Training (ORM): They trained an Outcome-supervised Reward Model (ORM). This verifier evaluates an agent's entire trajectory and predicts the probability that the resulting code patch will successfully pass the unit tests.
- Inference-Time Scaling: Instead of relying on the model's first guess, the system generates multiple candidate solutions (up to 16) and uses the trained verifier to select the best one. This "Best@k" approach allows the system to trade additional compute at inference time for higher accuracy.
- Agent Scaffolds: The models were tested across two different frameworks: OpenHands (a general-purpose tool-use agent) and MoatlessTools (a specialized workflow-based agent).
Datasets
- SWE-Gym (New): The core contribution. It features 2,438 real-world task instances from 11 popular Python repositories (like
pandas,scikit-learn, andflask). Each instance includes a natural language issue description, a codebase, and a fully functional Dockerized environment with unit tests. - SWE-Gym Lite (New): A subset of 230 easier tasks designed for faster iteration and testing.
- SWE-Gym Raw (New): A massive collection of 64,689 GitHub issues across 358 repositories, provided without executable environments to fuel future research in automatic environment synthesis.
Key Insights
- Fixing the "Stuck-in-Loop" Bug: One of the biggest hurdles for open-weight models is repetitive behavior. Fine-tuning on real trajectories from SWE-Gym significantly reduced the "stuck-in-loop" rate (e.g., dropping from 29.4% to 23.8% for a 32B model), effectively teaching the model how to pivot when a tool fails.
- Scaling Laws in SWE: The research demonstrates clear log-linear gains in performance. As you sample more solutions at inference time (and let the verifier choose), performance climbs steadily. Similarly, performance improves as more training trajectories are added, suggesting that simply scaling up data collection from the existing 2,438 tasks will yield even stronger models.
- Open-Weight SOTA: This work proves that with the right training environment, open-weight models (like Qwen-2.5-Coder-32B) can compete with—and even outperform—proprietary-model-based systems that lack domain-specific fine-tuning.
Key Results
- Massive Gains: Fine-tuning on SWE-Gym led to absolute improvements of up to 13.6% in resolution rate over zero-shot baselines.
- New State-of-the-Art: The combination of a fine-tuned 32B agent and a 32B verifier achieved 32.0% on SWE-Bench Verified and 26.0% on SWE-Bench Lite.
- The Power of Inference Compute: The theoretical maximum resolution rate if an oracle chose the best patch out of 16 attempts (Pass@16) reached 42.8%, while the verifier-selected rate (Best@16) reached 32.0%. Both are massive leaps over the single-attempt Pass@1 rate of 20.6%, highlighting the huge potential of inference-time compute.
Limitations and Future Work
- Environment Diversity: Currently, SWE-Gym is limited to 11 Python repositories because manually configuring these environments is highly labor-intensive (requiring ~200 human hours).
- Automatic Synthesis: A critical future direction is "Automatic Environment Synthesis"—using AI to automatically set up Docker containers and dependencies for the 64,000+ tasks in the "Raw" dataset.
- Self-Improvement: While the models improved significantly through rejection sampling, "true" self-improvement (where a model learns purely from its own generated successes without a teacher model) remains less effective than distillation from frontier models like GPT-4o.
- Human-in-the-loop: The current setup focuses entirely on autonomous completion. Future work could explore how these agents might collaborate with human developers in real-time.
Summary updated