TL;DR
SWE-Trail is a novel trajectory collection method that uses the "history" of previous attempts to guide where a coding agent should focus its efforts during training data generation. By keeping this history hidden from the agent and using it only to select better execution paths, the authors achieve significant performance gains on SWE-bench without creating a "train-test mismatch" where models rely on advice unavailable at test time.
What Problem Does This Paper Address?
Training effective coding agents requires high-quality "trajectories"—step-by-step records of an agent exploring a codebase, editing files, and running tests. The standard approach is independent sampling: just run the agent multiple times on the same issue and keep the successful runs.
However, this is inefficient. As shown in Figure 1, independent attempts quickly become redundant, often revisiting the same files and making the same mistakes.
One could give the agent "advice" based on previous failures, but this creates a train-test mismatch. If a model is trained on trajectories where it received hints, it may perform poorly in the real world where no such hints exist. SWE-Trail asks: How can we use history to collect better data without showing that history to the agent?
Methods
The authors propose a two-stage pipeline called SWE-Trail (Figure 2).
- Offline Compilation: The system analyzes a "history" of prior attempts (e.g., 5 independent runs) to identify "allocation signals"—states where the agent was uncertain or where successful and failed runs diverged. It compiles these into detectors (rules) and comparison objectives.
- Online Collection: A new rollout begins. The agent acts normally, seeing only the current issue and its own previous steps. When a detector triggers (e.g., "the agent edited code but didn't run a test"), the collector pauses. It samples multiple candidate actions from the agent, executes them in parallel from the same checkpoint for a short horizon, and uses the comparison objective to pick the "winning" route (e.g., the one that actually ran a test and got a signal).
Crucially, the history remains "outside the context." The agent proposes actions based on its ordinary view, but the collector uses history to decide which of those actions are worth pursuing.
Datasets
- Collection History: 300 repository-level issues from SWE-rebench V2, using 5 independent attempts as the "SeedBank" history.
- Evaluation Benchmarks: SWE-bench Multilingual (300 tasks across 9 languages) and SWE-bench Pro (731 complex, multi-file tasks).
- Student Models: The trajectories were used to fine-tune a 124B Ling-3.0-flash-base model and a 14B Qwen3-Base model.
Key Insights and Ideas
- History as a Search Guide, Not Advice: The core "aha moment" is that history is most valuable as a meta-signal for the data collector, not as direct input for the agent. This preserves the integrity of the training data.
- Execution Evidence is King: Instead of relying on an LLM to "guess" which path is better, SWE-Trail briefly executes candidates. This provides ground-truth feedback (like test results) that is far more reliable than static reasoning.
- Reducing Redundancy: By forcing the agent to explore alternatives at critical decision points identified by history, the resulting trajectories are more diverse and informative.
- Cleaner Process: Guided trajectories tend to be more efficient. Agents trained on SWE-Trail data take fewer actions and perform fewer redundant file reads (Figure 5).
Key Results
The researchers found that training on SWE-Trail trajectories (the H5 condition) consistently outperformed independent sampling and other curation methods:
- 124B Student: Improved mean resolution by 2.33 percentage points on Multilingual and 1.60 on Pro compared to the SeedBank baseline.
- 14B Student: Showed even larger gains, improving by 3.11 (Multilingual) and 2.42 (Pro) points.
- Ablation (H0): A version of the pipeline that used the parallel execution mechanism without history-guided detectors performed better than simple sampling but significantly worse than the full SWE-Trail. This proves that the "history" component is doing the heavy lifting.
Limitations and Future Work
- Computational Cost: While SWE-Trail is more efficient than massive independent sampling, the parallel execution and offline compilation do add overhead (roughly 13% more tokens than a simple baseline).
- Scope: The current work focuses on coding. Applying this to other domains like web navigation would require environments that support easy state restoration (checkpoints).
- Iterative Collection: The authors used a fixed history. Future work could explore "active" versions where the history is updated continuously as new trajectories are collected.
Summary updated