SWE-Replay: Efficient Test-Time Scaling for Software Engineering Agents

Yifeng Ding, Lingming Zhang

TL;DR

SWE-Replay is a novel test-time scaling framework for software engineering (SWE) agents that avoids the massive computational cost of generating full agent trajectories from scratch. By stochastically recycling prior trajectories and branching at critical, reasoning-intensive steps, it reduces inference costs by up to 17.4% while simultaneously boosting bug-resolving performance by up to 3.8%. Crucially, it achieves these gains entirely without relying on noisy, brittle LLM-as-a-judge value estimators.

What Problem Does This Paper Address?

Large Language Model (LLM) agents have evolved from simple code-completion tools to autonomous systems capable of navigating repositories, running tests, and generating patches. To maximize their success on complex software engineering tasks, researchers frequently turn to test-time scaling—sampling multiple candidate trajectories and using test feedback to select the best final patch.

However, repeatedly sampling long trajectories from scratch is incredibly expensive. While prior works attempted to mitigate these costs using Monte Carlo Tree Search (MCTS) or reward models to prune unpromising paths early, they suffer from two fatal flaws:

  1. Model Miscalibration: LLM-based value judges and reward models are notoriously prone to overconfidence and noise, leading to bad pruning decisions.
  2. Lack of Generalization: Existing methods rely on rigid, pre-defined tool templates (like structured search tools). Modern SWE agents, however, dynamically synthesize custom bash scripts without templates, making tool-specific evaluation prompts completely incompatible.

Methods

SWE-Replay introduces a generalizable, judge-free approach to test-time scaling by maintaining a Trajectory Archive and using a simple select-and-replay mechanism.

Overview of SWE-Replay

For each scaling iteration, the framework stochastically decides (with a 50% probability) whether to explore by sampling a completely new trajectory from scratch, or exploit by branching from an existing trajectory in the archive. When exploiting, it utilizes a hierarchical step-selection pipeline:

  1. Trajectory Filtering: It discards any trajectories whose final patches cause existing repository regression tests to fail, ensuring the agent doesn't branch off inherently broken paths.
  2. Grouping via Abstraction: To avoid fragmentation from superficial differences, steps are grouped into "states" based on the set of repository files explored up to that point. Rarer states are assigned higher sampling probabilities via Softmax normalization to encourage diverse exploration.
  3. Reasoning-Intensive Selection: Within the chosen state group, the framework selects specific steps where the agent demonstrated high "reasoning intensity," using the number of paragraphs in the agent's thought process as a structural proxy.

Once a step is selected, SWE-Replay efficiently restores the environment state by applying recorded repository diffs (avoiding slow action replays) and commands the agent to branch out and complete a new trajectory.

Datasets

The authors evaluated SWE-Replay across three primary benchmarks:

  • SWE-Bench Verified: A human-validated subset of 500 tasks from the original SWE-Bench dataset. A 50-problem subset (SWE-Bench Verified mini) was used for ablation studies.
  • SWE-Bench Pro: A more complex dataset containing 731 enterprise-level software engineering problems.
  • SWE-Bench Multilingual: A benchmark consisting of 300 tasks spanning 9 different programming languages (including JavaScript, Rust, Go, and C/C++).

Key Insights and Ideas

  • Paragraph Count Over Token Length: When identifying critical decision points, raw token length is a noisy metric because it can be artificially inflated by verbose code snippets or raw inputs. Counting the number of distinct paragraphs serves as a far more robust structural proxy for genuine agent deliberation.
  • File-Level Abstraction is the Sweet Spot: Grouping agent steps by the exact lines or methods modified creates overly sparse, fragmented groups. Abstracting steps at the file level provides the optimal balance for grouping semantically related exploration behaviors.
  • Escaping Local Optima: Issue descriptions often contain misleading hints that cause naive scaling methods to fixate on the wrong files. By explicitly biasing exploration toward rarely visited file states, SWE-Replay successfully pushes agents into the "long tail" of repository files, helping them discover the true root causes of bugs.

Key Results

SWE-Replay was tested across multiple LLM backends (Gemini-2.5-Pro, Gemini-3-Pro, Devstral-Small-2) and agent scaffolds (mini-SWE-agent, Live-SWE-agent).

  • SWE-Bench Verified: SWE-Replay consistently outperformed naive scaling, reducing computational costs by up to 17.4% while improving the problem resolve rate by up to 3.8%.
  • SWE-Bench Multilingual: The framework demonstrated massive generalizability, yielding a 22.6% relative performance gain alongside a 9.0% cost reduction.
  • vs. LLM-as-a-Judge: In ablation studies, replacing SWE-Replay's heuristic selection with an LLM judge actually degraded the resolve rate (dropping from 60.0% to 54.0%) while more than doubling the total cost due to the judge's prompt overhead.

Limitations and Future Work

While the paper does not include a dedicated limitations section, a few constraints are apparent from the methodology:

  • Dependency on Regression Tests: The trajectory filtering phase relies entirely on the presence of pre-existing regression tests within the repository. For repositories lacking robust test suites, filtering quality might degrade.
  • Agent Scaffold Assumptions: The reasoning intensity metric assumes that the underlying agent scaffold is designed to output explicit, paragraph-separated thought blocks before executing tool calls. Scaffolds that do not follow this design pattern may require alternative intensity heuristics.

Summary updated

BibTeX
@inproceedings{ding2026swe,
  author = {Yifeng Ding and Lingming Zhang},
  title = {{SWE-Replay: Efficient Test-Time Scaling for Software Engineering Agents}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=zXbem3FJR0},
}
Figure