SWE-smith: Scaling Data for Software Engineering Agents
Read first: Synthetic RL environments for agent training: a map · SWE-agent: Agent-Computer Interfaces for Software Engineering
TL;DR. SWE-bench-style datasets start from a real issue and build an environment for each task, which is slow and costs terabytes. SWE-smith turns this around. It installs each repository once, then synthesizes bugs in it and keeps those that make a passing test fail. An LM writes the issue text. From 128 Python repos it gets 50,137 tasks in 295 GB for about 1,360 USD. SFT on 5,016 resolved Claude 3.7 Sonnet trajectories gives SWE-agent-LM-32B 40.2% on SWE-bench Verified. The page also covers the two per-task alternatives it compares against, SWE-Gym and R2E-Gym.
Why it matters now. Software engineering is the best-verified agent domain: tests define success. Open SWE agents depend on how many executable tasks exist. SWE-smith shows that the bottleneck is environment construction, not task count, and that cheap synthetic bugs are nearly as useful as real ones. The same “environment first, tasks second” idea transfers to any domain where you can install a system once and perturb it, including retrieval codebases.
Key idea
Section titled “Key idea”Environment first. SWE-agent installs each repository and runs its tests in at most 100 steps; the result is kept if more than 80% of tests pass, and becomes one Docker image. Human effort is about 7 minutes per repo to check the installation and 1 minute to write a test-log parser, roughly 20 hours in total. Repos come from the top 5,000 PyPI packages with at least 1,000 stars, excluding the 12 SWE-bench test repositories.
Then tasks. Five strategies propose candidate bugs:
- LM Modify: ask an LM to introduce a subtle bug in a function.
- LM Rewrite: have an LM re-implement a function from its signature and docstring; mistakes become bugs.
- Procedural: 13 AST transforms (flip a condition, remove a loop, swap operands, and so on).
- Combine: merge bugs from the same file or module into harder tasks.
- PR Mirror: have an LM undo the effect of a real pull request on the current code.
A candidate is kept only if it breaks at least one previously passing test within a 2-minute test run. The broken tests become fail-to-pass tests; the others must keep passing. An LM then writes a GitHub-style issue from the diff, one failing test and its output. The reward is the usual SWE-bench one: resolved if all fail-to-pass tests pass and no pass-to-pass test breaks.
Key results
Section titled “Key results”- Dataset (Table 1). 50,137 instances from 128 repos (mean about 390 per repo). Yield, the share of candidates that break a test, is 96.9% for Combine, 56.0% LM Modify, 40.2% Procedural, 35.0% LM Rewrite and 33.8% PR Mirror. Total cost 1,360 USD: 1,000 for bugs, 160 for installation, 200 for issues on 10K bugs.
- Footprint (Table 2). 295 GB, against about 6 TB for SWE-Gym’s 2.4k tasks and 4 TB for R2E-Gym’s 4.6k-task subset. Building 50k tasks the SWE-bench way would take 50–150 TB by the paper’s estimate.
- Training (§4, Table 3). Expert trajectories were attempted on 8,686 instances (17.3% of the dataset); the expert resolved 36% of 17,906 attempts. Capping each instance at three trajectories left 5,016. Qwen2.5-Coder-32B reaches 40.2% on SWE-bench Verified (30.7% Lite); the 7B model reaches 15.2%.
- Same-size comparison. With 500 trajectories, 28.2% versus 20.6% for SWE-Gym-32B with 491; R2E-Gym-32B reaches 34.4% with about 3.3k.
- Ablations (Tables 4–5, 7B). By bug strategy (Table 4): PR Mirror 9.2, LM Rewrite 8.8, Procedural 8.6, LM Modify 5.7. By issue text (Table 5): original 7.8, LM 7.7, failing test 7.3, fixed template 6.4. Task difficulty ratings did not predict training value.
- Failure analysis. More than 25% of the 32B model’s trajectories contain a repeated action sequence of length 10 or more (under 4% for Claude 3.7 Sonnet), 53% of its failures end at the cost or step limit, and localization is the dominant failure mode.
The per-task alternatives. SWE-Gym (Pan et al., ICML 2025) semi-manually builds executable environments for 2,438 real issues from 11 Python repositories. Training on it gives up to 19 points absolute, and verifiers trained on its trajectories lift the agent to 32.0% Verified. R2E-Gym (Jain et al., 2025) builds tasks from commits rather than issues. Where tests are missing it generates fail-to-pass tests, and it back-translates the commit into a problem statement, prompting with the failing tests. This yields 8,135 tasks (4,578 after removing SWE-bench repositories); its 32B model reaches 34.4% pass@1 and 51% with hybrid test-time verification.
2026 update: task-first at scale. SWE-smith’s premise was that per-task environments are too costly to scale. ScaleSWE (2602.09892) automates the task-first route instead: three agents handle environment setup, test creation and problem-statement writing over 6 million pull requests in 5,200 repositories, producing 100K verified instances. Distilled trajectories (71,498) lift Qwen3-30B-A3B-Instruct from 22.0% to 64.0% on SWE-bench Verified. Under the same distillation pipeline, SFT on SWE-Gym data reaches 54.8% and on SWE-smith 54.6% (Table 4), and the authors find SWE-smith’s synthetic bugs skewed toward logic errors. This is SFT, not RL, and SWE-smith’s lesson about amortizing one installation over many tasks still applies wherever storage and setup cost bind.
Limitations & open questions
Section titled “Limitations & open questions”- Synthetic bugs are not real issues: they are local, often single-function, and their issue text is written from the answer.
- Training is SFT on an expert’s successes, so the dataset’s value for RL (exploration, reward hacking, stability) is untested here.
- Python only, with one commit per repository; real projects change dependencies and APIs over time.
- Tests are the verifier, and weak tests make hackable tasks; see SWE-bench audits and ImpossibleBench.
Connections
Section titled “Connections”- Environments map: SWE-smith is the scalable end of the real-sandbox family.
- SWE-agent is the harness used both to install repos and to collect trajectories.
- Frontier-lab pipelines: DeepSeek-V3.2 and Kimi K2 build SWE environments from real issue–PR pairs at much larger scale, for RL rather than SFT.
- Agent Lightning and context folding use SWE environments for RL.
- Reward hacking in agents: test-based rewards invite test editing.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
SWE-smith reports 295 GB for 50,137 tasks from 128 repos, while SWE-Gym's 2,438 tasks average about 2.6 GB of image each. Compute the storage per task for both designs and the storage SWE-Gym's design would need for 50k tasks. Then explain where SWE-smith's saving comes from and what it costs in task diversity.
What a strong answer covers
- SWE-smith: 295 GB / 50,137 ≈ 5.9 MB per task (really about 2.3 GB per repository image shared by about 390 tasks).
- SWE-Gym: 2.6 GB × 2,438 ≈ 6.3 TB, matching the reported 6 TB; scaled to 50k tasks, about 130 TB, inside the paper's 50–150 TB estimate.
- The saving comes from sharing one environment per repository at one commit; each task is just a patch that breaks tests on top of that image.
- Cost: all tasks in a repo share one version of its dependencies and code, and bugs are synthetic, so the distribution differs from real issues; diversity has to come from more repositories, which the repo-count ablation shows helps roughly logarithmically.
- Mechanism
Explain how one SWE-smith task instance is made and validated, step by step, and say which step defines the reward signal for an agent trained on it.
What a strong answer covers
- Install: SWE-agent installs the repository and runs its tests in at most 100 steps; the environment is kept if more than 80% of tests pass; one Docker image per repo.
- Generate candidate bugs with LM Modify (ask for a bug in a function), LM Rewrite (re-implement a function from its signature), procedural AST transforms (13 kinds), Combine (merge bugs) or PR Mirror (revert the effect of a real PR with an LM).
- Validate: apply the patch, run the tests with a 2-minute limit, and keep it only if at least one previously passing test now fails; those tests become fail-to-pass, the rest pass-to-pass.
- Describe: an LM writes the issue from the diff, one fail-to-pass test and its output. The reward is resolving the instance: all fail-to-pass tests pass and no pass-to-pass test breaks.
- What if…
Tables 4 and 5 ablate bug strategy (1,000 instances each, 7B student) and issue text (600 PR Mirror instances), respectively. Summarize the findings and explain the mechanism behind the drop when the issue includes a failing test.
What a strong answer covers
- Bug strategy (SWE-bench Verified, 7B): PR Mirror 9.2, LM Rewrite 8.8, Procedural 8.6, LM Modify 5.7, with training capped at the smallest successful-trajectory count (507). Cheap procedural bugs nearly match PR mirrors.
- Issue text: original 7.8, LM-generated 7.7, failing-test-as-issue 7.3, fixed template 6.4; LM issues are as good as real ones for training.
- Including a fail-to-pass test leaks the evaluation criterion; trained agents learn to skip writing a reproduction script. Reproduction attempts on Verified fell from 379 to 127 of 500 runs.
- Fixed templates produce homogeneous expert trajectories (31% fewer unique actions), so the student learns fewer strategies.
- Critique
SWE-smith trains with rejection-sampled SFT from Claude 3.7 Sonnet, not RL. Critique what its results do and do not tell an RL researcher about the value of the environments, and compare with how SWE-Gym and R2E-Gym evaluate their environments.
What a strong answer covers
- The 40.2% result measures distillation from a stronger agent on SWE-smith tasks; it shows the environments yield useful trajectories, not that RL inside them works or is stable.
- The expert resolved only 36% of 17,906 attempts on 8,686 instances, and only 17.3% of the dataset was used for trajectories, so the training signal comes from a filtered, expert-solvable slice.
- At 500 trajectories SWE-smith reaches 28.2% vs SWE-Gym-32B's 20.6% with 491; R2E-Gym-32B reaches 34.4% with about 3.3k trajectories. These compare data sources under similar SFT, not RL.
- SWE-Gym and R2E-Gym also train verifiers for test-time selection; R2E-Gym finds execution-based and execution-free verifiers each plateau around 42–43% and a hybrid reaches 51%.
- For RL, open issues are synthetic-bug hackability (tests that can be special-cased) and whether a synthetic bug distribution produces reward hacks that real issues would not.
- Design
You want SWE-smith-style environments for a retrieval codebase (for example Pyserini or a dense-retrieval library) to train an agent that fixes IR pipeline bugs. Design the install, bug generation, validation and reward, including what counts as a test for ranking code.
What a strong answer covers
- Install once per repo with pinned indexes and small fixture corpora so tests run in seconds; keep one image per repo.
- Bugs: procedural edits to scoring code (sign flips, wrong normalization, off-by-one in top-k), LM rewrites of tokenizers or analyzers, and PR mirrors of real fixes.
- Tests: unit tests plus regression tests on small qrels (for example nDCG on a toy collection must stay above a threshold); keep bugs that break at least one passing test.
- Reward: all fail-to-pass pass and no pass-to-pass break; guard against agents editing tests or fixture files by making them read-only or by checking the diff.
- Research idea
SWE-smith finds no correlation between rated task difficulty and training value, but a strong effect of repository count. Propose an experiment that tells whether environment diversity (repos) or task diversity (bugs per repo) matters more for RL, not SFT, on SWE tasks.
What a strong answer covers
- Grid: vary repos (for example 8, 32, 128) and bugs per repo at a fixed total task count and fixed RL compute.
- Use the same base policy and RL recipe (GRPO-style with fail-to-pass reward), and filter tasks to non-zero pass rate so groups have signal.
- Evaluate on held-out repositories (SWE-bench Verified repos are excluded from SWE-smith) and on real-issue subsets, and track reward hacking rates.
- Compare with the environment-versus-task exponents reported in the agentic-data-scaling analysis; a steeper curve in repos would support environment-first scaling.