NTH

SWE-Trail: History-Guided Trajectory Collection for Coding Agent Training

AuthorsZiming Li, Lu Yu, Jiatan Huang, Qing Cui, Jun Zhou, Chuxu Zhang

Affiliations1University of Connecticut 2Ant Group {ziming.li,chuxu.zhang}@uconn.edu jun.zhoujun@antgroup.com †Corresponding authors

November 7, 2026 3 min read
Watch on YouTube
The one-line take

SWE-Trail uses earlier coding-agent attempts to steer which paths to explore next, helping produce more useful training data without giving the agent hidden advice.

Key results

300
SWE-rebench V2 issues

Issues used to collect the training trajectories.

2.33
Ling-3.0-flash-base gain on SWE-bench Multilingual

Percentage-point improvement over independent sampling.

1.60
Ling-3.0-flash-base gain on SWE-bench Pro

Percentage-point improvement over independent sampling.

3.11
Qwen3-14B-Base gain on SWE-bench Multilingual

Percentage-point improvement over independent sampling.

2.42
Qwen3-14B-Base gain on SWE-bench Pro

Percentage-point improvement over independent sampling.

What the paper found

SWE-Trail improves coding-agent training data by using prior attempts to decide where to spend collection effort, without showing that history to the coding agent. An offline compiler turns each issue’s history into state detectors and comparison criteria; when a detector fires, the agent proposes actions from its ordinary context, and the collector executes alternatives from the same checkpoint before choosing a route based on repository evidence. Each rollout includes at most one comparison, and the exported trajectory contains only the selected route. On 300 SWE-rebench V2 issues, trajectories collected with five prior attempts improved the 124B Ling-3.0-flash-base student by 2.33 percentage points on SWE-bench Multilingual and 1.60 points on SWE-bench Pro versus independent sampling. The gains also transferred to Qwen3-14B-Base: 3.11 and 2.42 points on those benchmarks. A history-free control produced more resolved trajectories but only a 0.11-point Multilingual improvement, suggesting that collection success alone does not account for the training gains. OpenAI’s GPT-5.6-Sol and GLM-5.1 independently audited whether prior attempts expose useful decision points; the approach itself uses GLM-5.1 for collection.

Original abstract

Coding agents solve repository issues through long sequences of exploration, editing, and validation. These trajectories are increasingly used as post-training data, so how they are collected shapes what the trained model learns. A common approach is to sample multiple trajectories independently for each issue and then select or curate them. However, as more trajectories are sampled independently, later trajectories become increasingly redundant, even though earlier trajectories could guide where subsequent collection effort should be spent. A natural way to use this history is to expose it to the coding agent as advice. But training on such trajectories can make the model rely on advice that is unavailable at test time, creating a train-test mismatch. Instead, we argue that history should guide where collection effort is spent, while the coding agent decides what to generate. We introduce SWE-Trail, a trajectory collector that uses earlier trajectories to guide subsequent collection while keeping that history outside the coding agent's context. During a new rollout, SWE-Trail uses history to identify a state where additional collection effort may be useful. There, the coding agent proposes candidate next actions from its ordinary context, and SWE-Trail briefly executes them from the same checkpoint to decide which route continues. We evaluate collection approaches by training student models on the trajectories they produce. For a 124B student initialized from Ling-3.0-flash-base, SWE-Trail improves mean resolution over independent sampling by 2.33 and 1.60 percentage points on SWE-bench Multilingual and SWE-bench Pro, respectively. Without history, the same pipeline produces more resolved trajectories than independent sampling, but improves by only 0.11 points on Multilingual. These results show the value of using history to guide collection without exposing it to the coding agent.

Read the original paper

More in Code Generation

Browse all 52 papers →
01Code Generation

CompoundingKernel: Self-Improving from Zero to First

Qian Qu, Hongyang Wang, Wenbo Chen, Yichuan Li, Jingguo Liu, Xian Li, Xuan Wang, Ruochen Wen, Leo Fan, Yiming Yan, Zheshen Wang, Benoit Dumoulin

CompoundingKernel uses parallel agents and an archive of successful attempts to discover fast, correct GPU kernels.

Read analysis