TL;DR
SWE-Replay is a new framework that makes test-time scaling for software engineering (SWE) agents significantly more efficient by "recycling" successful parts of previous attempts. By branching from critical intermediate steps instead of starting every trial from scratch, it reduces computational costs by up to 17.4% while maintaining or even slightly improving bug-fixing performance.
What Problem Does This Paper Address?
In the world of AI software engineers, "test-time scaling"—generating multiple candidate solutions and picking the best one—is the gold standard for boosting performance. However, this approach is notoriously expensive. If an agent takes 100 steps to navigate a repository and submit a patch, running 10 trials means paying for 1,000 steps.
Previous attempts to cut these costs usually rely on "value agents" or "LLM-as-a-Judge" to prune bad paths early. But these methods have two major flaws:
- Model Miscalibration: LLMs are often overconfident or noisy when grading their own work.
- Lack of Generalizability: Modern agents (like SWE-agent) are flexible; they write custom bash scripts on the fly. Existing efficiency methods are often hard-coded for specific tool templates and can't handle this "free-form" tool use.
Methods
The authors introduce SWE-Replay, which ditches noisy LLM judges in favor of a "select-and-replay" mechanism. The core idea is to maintain a Trajectory Archive of previous attempts and stochastically choose between exploring from scratch or "exploiting" an existing path by branching off at a critical point.
The "secret sauce" is how the agent selects where to branch. They use a hierarchical selection pipeline:
- Filtering: They immediately discard any trajectory that fails existing regression tests. If a patch breaks the build, its intermediate steps are likely misleading.
- Abstract State Grouping: To avoid getting lost in minor differences, they group steps based on the set of files the agent has visited. They then prioritize branching from "rare" states to encourage the agent to explore parts of the codebase it previously ignored.
- Reasoning Intensity: Within a chosen group, they pick steps where the agent seemed to be "thinking hard." Interestingly, they found that the number of paragraphs in the agent's thought process is a better proxy for reasoning quality than raw token count, which is often bloated by copied code.
To make replaying fast, they use repository diffs to restore the environment state in milliseconds, rather than re-executing every previous command.
Datasets
The researchers evaluated SWE-Replay across three major benchmarks:
- SWE-Bench Verified: 500 human-validated software tasks.
- SWE-Bench Pro: A more difficult set of 731 enterprise-level problems.
- SWE-Bench Multilingual: 300 tasks spanning 9 different programming languages (e.g., Rust, Go, Java).
They tested these using various LLM backends, including Gemini-2.5-Pro, Gemini-3-Pro, and Devstral-Small-2.
Key Insights and Ideas
- Diversity Beats Verbosity: The agent often gets stuck in "local optima"—for example, fixating on a file mentioned in the bug report that isn't actually the root cause. By prioritizing rare file-visitation states, SWE-Replay forces the agent to look at the "long tail" of the repository.
- Structural Reasoning Signals: One of the most practical findings is that structural markers (like paragraph breaks) are more reliable indicators of intense reasoning than token length. This helps the system identify critical decision points without being fooled by "verbose but empty" LLM outputs.
- Mathematical Intuition: The authors provide a proof showing that as long as your selection mechanism is even slightly better than random, replaying will always be more efficient than naive scaling.
Key Results
- Cost Efficiency: SWE-Replay reduced total inference costs by up to 17.4% on SWE-Bench Verified.
- Performance Gains: Despite the lower cost, the resolve rate actually increased by up to 3.8%. On the Multilingual benchmark, the improvement was even more dramatic, with a 22.6% relative increase in resolved tasks.
- Exploration Quality: Analysis showed that SWE-Replay successfully shifted the agent's focus toward task-relevant files that naive scaling completely overlooked.
Limitations and Future Work
- Test Dependency: The filtering mechanism relies on the existence of regression tests. In repositories with poor test coverage, the system might struggle to prune low-quality trajectories effectively.
- Branching Complexity: Currently, the system uses a relatively simple branching strategy. The authors suggest that future work could integrate more complex tree-search algorithms or adaptive branching factors based on the difficulty of the task.
- Prompt Caching: The cost savings assume the use of explicit prompt caching. While most major providers support this, the exact savings can vary based on the provider's specific caching policy.
Summary updated