SWE-Trail: History-Guided Trajectory Collection for Coding Agent Training
Organizations: University of Connecticut · Ant Group
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.
Figures & tables
| Multilingual | SWE-Pro | |||||
| Coding-trajectory condition | Mean | Range | Mean | Range | ||
| SeedBank independent rollouts | 63.33 | [63.00, 63.67] | 41.22 | [41.18, 41.31] | ||
| SWE-Gym ( Pan et al., 2025 ) , outcome-conditioned transform | 64.00 | (+0.67) | [63.33, 65.00] | 40.86 | (−0.36) | [40.36, 41.59] |
| SWE-TRACE ( Han et al., 2026 ) , critical-path reduction | 64.44 | (+1.11) | [63.33, 65.33] | 40.77 | (−0.46) | [40.08, 41.72] |
| SWE-Lego ( Tao et al., 2026 ) , strict tool-error masking | 64.56 | (+1.22) | [63.00, 66.00] | 41.63 | (+0.41) | [39.81, 42.95] |
| SWE-Exp ( Chen et al., 2025 ) , agent-visible experience | 62.00 | (−1.33) | [61.00, 63.00] | 38.44 | (−2.78) | [38.30, 38.58] |
| Acquisition | Recorded compute | Student utility | |||||
|---|---|---|---|---|---|---|---|
| Condition | Hist. | Res. | Issues | Acq.-only | Total | Multi. | Pro |
| SWE-Trail-H0 | 0 | 329 | 92 | 164M † | 1.845B † | 63.44 | 41.95 |
| SWE-Trail-H5 (main) | 5 | 345 (+16) | 98 (+6) | 307M (+143M † ) | 1.914B (+69M † ) | 65.67 (+2.22) | 42.82 (+0.87) |
| SWE-Trail-H10 | 10 | 341 (+12) | 94 (+2) | 510M (+346M † ) | 2.160B (+315M † ) | 65.89 (+2.44) | 42.95 (+1.00) |
| Dataset | Multilingual | SWE-Pro |
|---|---|---|
| SeedBank | 63.33 | 41.22 |
| Top-5-of-10 | 64.11 | 41.86 |
| SWE-Trail-H5 | 65.67 | 42.82 |
| Top-5-hybrid | 66.22 | 43.14 |
| Method | Resolved | Solved issues | Verified positive |
|---|---|---|---|
| SeedBank | 292 | 88 | 263 |
| SWE-Trail-H0 | 329 | 92 | 272 |
| SWE-Trail-H5 | 345 (+16) | 98 (+6) | 285 (+13) |
Appendix figures & tables28 assets
Supplementary material from the paper’s appendix.
Appendix
| Main text | Appendix |
|---|---|
| Section 2.1 : marginal coverage of independent rollouts | Appendix A.1 |
| Section 2.2 : mixed-outcome audit and its replication | Appendices A.2 and A.3 |
| Section 3 : compiler, runtime, selector, export, prompts | Appendix B |
| Section 4.1 : issue pool, conditions, training, evaluation | Appendices C and D |
| Section 4.2 : main runs, paired contrasts, language breakdown | Appendix E |
| Section 4.2 : second student | Appendix E.4 |
| History type | |||||
|---|---|---|---|---|---|
| Stable-solved | 89.96% | 93.98% | 96.58% | 98.38% | 100% |
| Mixed | 73.20% | 86.42% | 92.96% | 96.98% | 100% |
| Never-solved | 80.09% | 88.89% | 93.75% | 97.19% | 100% |
| History type | Issues | Pairs | ||||
|---|---|---|---|---|---|---|
| Stable-solved | 37 | 370 | 0.605 | 0.629 | 0.665 | 0.918 |
| Mixed | 51 | 510 | 0.491 | 0.560 | 0.625 | 0.745 |
| Never-solved | 212 | 2,120 | 0.503 | 0.571 | 0.642 | 0.841 |
| Stage | Count | Share of 51 | Retention |
|---|---|---|---|
| Selected mixed-issue pairs | 51 | 100.0% | 100.0% |
| Naturally completed unresolved pair | 43 | 84.3% | 84.3% |
| Complete audit disposition | 43 | 84.3% | 100.0% |
| Localized divergence and dual-order audit | 40 | 78.4% | 93.0% |
| Decision point supporting comparison | 31 | 60.8% | 77.5% |
| Family | Classification | All (51) | Primary (43) | Censored (8) |
| Stage 1 | Localized divergence | 44 | 40 | 4 |
| No meaningful divergence | 3 | 3 | 0 | |
| Not analyzed: API long tail | 4 | 0 | 4 | |
| Divergence type | Hypothesis | 3 | 3 | 0 |
| Implementation | 28 | 25 | 3 | |
| Validation | 13 | 12 | 1 |
| Track | Set | A | B | Both | Raw | Pos. | Neg. | AC1 | ||
|---|---|---|---|---|---|---|---|---|---|---|
| End to end | Primary | 43 | 31 | 26 | 20 | 60.5% | 70.2% | 41.4% | .129 | .285 |
| End to end | Censored | 4 | 3 | 3 | 3 | 100.0% | 100.0% | 100.0% | 1.000 | 1.000 |
| Fixed boundary | Primary | 28 | 24 | 16 | 15 | 64.3% | 75.0% | 37.5% | .205 | .397 |
| Fixed boundary | Censored | 4 | 3 | 2 | 2 | 75.0% | 80.0% | 66.7% | .500 | .529 |
| Component | Visible prefix | Prior attempts | Private record | Executed suffix pair |
|---|---|---|---|---|
| Offline compiler | issue only | H-dependent | yes | no |
| Candidate generation | yes | no | no | no |
| Private shortlist | yes | yes | yes | no |
| Blind suffix selector | yes | private | private | yes |
| Exported trajectory | selected route | no | no | selected only |
| Stage | Structured inputs | Required output | Downstream consumer |
|---|---|---|---|
| History diagnosis | issue, ordered attempts, outcomes | mechanisms, decision differences, unresolved questions | repository-check planner |
| Repository exploration | diagnosis, repository snapshot | bounded commands, findings, provenance | evidence auditor |
| Evidence audit | diagnosis, repository observations | supported/contradicted claims, uncertainty | rule synthesis |
| State synthesis/compiler | audited evidence, feature schema | states, predicates, objectives, abstentions | private detector |
| Candidate shortlist | visible prefix, candidates, private record | default plus one existing candidate index | matched executor |
| Suffix selector | shuffled suffixes, comparison objective, private record as prior | select A, select B, or tie with evidence | trajectory continuation |
| Condition | Source | History visible to agent | New collection | Training record | Role |
|---|---|---|---|---|---|
| SeedBank | independent rollouts | no | complete rollout | generated trajectory | sampling baseline |
| SWE-Gym ( Pan et al., 2025 ) , outcome-conditioned transform | SeedBank | no | no | outcome-conditioned record | outcome control |
| SWE-Lego ( Tao et al., 2026 ) , strict tool-error masking | SeedBank | no | no | masked record | step control |
| SWE-TRACE ( Han et al., 2026 ) , critical-path reduction | SeedBank | no | no | compressed record | compression control |
| SWE-Exp ( Chen et al., 2025 ) , agent-visible experience | five attempts | yes | complete rollout | experience retained | visibility control |
| SWE-Trail-H0 | no history | no | history-free collection | selected trajectory | no-history control |
| Field | Controlled setting |
|---|---|
| Initialization | Ling-3.0-flash-base |
| Model scale | 124B total; 5.1B activated non-embedding parameters |
| Coding trajectories | 1,500 per condition; all outcomes retained |
| Background mixture | identical |
| Tokenizer and tool representation | identical |
| Context length and packing | identical |
| Multilingual | SWE-Pro | |||||||
|---|---|---|---|---|---|---|---|---|
| Condition | R1 | R2 | R3 | Mean | R1 | R2 | R3 | Mean |
| SeedBank independent rollouts | 63.00 | 63.67 | 63.33 | 63.33 | 41.18 | 41.31 | 41.18 | 41.22 |
| SWE-Gym (outcome-conditioned transform) | 63.67 | 65.00 | 63.33 | 64.00 | 40.36 | 41.59 | 40.63 | 40.86 |
| SWE-TRACE (critical-path reduction) | 65.33 | 64.67 | 63.33 | 64.44 | 41.72 | 40.08 | 40.49 | 40.77 |
| SWE-Lego (strict tool-error masking) | 66.00 | 63.00 | 64.67 | 64.56 | 39.81 | 42.13 | 42.95 | 41.63 |
| SWE-Exp (agent-visible experience) | 62.00 | 61.00 | 63.00 | 62.00 | 38.44 | 38.58 | 38.30 | 38.44 |
| Contrast | Multilingual [95% CI] | W/L/T | SWE-Pro [95% CI] | W/L/T |
|---|---|---|---|---|
| H5 H0 | 2.22 [−0.2, 4.6] | 55/35/210 | 0.87 [−0.8, 2.5] | 130/111/490 |
| H10 H0 | 2.44 [−0.1, 4.9] | 61/39/200 | 1.00 [−0.7, 2.7] | 134/112/485 |
| H10 H5 | 0.22 [−2.0, 2.5] | 51/49/200 | 0.14 [−1.3, 1.6] | 117/114/500 |
| Stricter selector H5 | −1.78 [−4.0, 0.4] | 42/58/200 | −0.91 [−2.6, 0.8] | 105/125/501 |
| Language | Tasks | SeedBank | H0 | H5 | SeedBank | H0 |
|---|---|---|---|---|---|---|
| C | 30 | 60.0 | 56.7 | 68.9 | (+8.9) | (+12.2) |
| C++ | 12 | 63.9 | 69.4 | 69.4 | (+5.6) | 0.0 |
| Go | 42 | 34.1 | 36.5 | 37.3 | (+3.2) | (+0.8) |
| Java | 43 | 72.9 | 72.1 | 72.9 | 0.0 | (+0.8) |
| JavaScript | 31 | 74.2 | 72.0 | 71.0 | (−3.2) | (−1.1) |
| PHP | 43 | 69.8 | 72.9 | 72.1 | (+2.3) | (−0.8) |
| Multilingual | SWE-Pro | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Training dataset | R1 | R2 | R3 | Mean | R1 | R2 | R3 | Mean | ||
| SeedBank | 11.67 | 11.00 | 11.33 | 11.33 | 10.94 | 11.22 | 11.08 | 11.08 | ||
| SWE-Trail-H0 | 12.67 | 13.00 | 12.67 | 12.78 | +1.44 | 11.90 | 11.76 | 12.04 | 11.90 | +0.82 |
| SWE-Trail-H5 | 14.33 | 14.67 | 14.33 | 14.44 | +3.11 | 13.27 | 13.54 | 13.68 | 13.50 | +2.42 |
| SWE-Trail-H10 | 15.33 | 15.33 | 15.67 | 15.44 | +4.11 | 13.82 | 13.95 | 13.82 | 13.86 | +2.78 |
| Condition | Mean actions | Mean repeated reads | Post-edit validation |
|---|---|---|---|
| SeedBank | 43.37 | 8.78 | 86.62% |
| SWE-Trail-H0 | 40.89 | 7.59 | 88.91% |
| SWE-Trail-H5 | 39.51 | 7.01 | 89.53% |
| SWE-Trail-H10 | 40.72 | 7.46 | 88.65% |
| Multilingual | SWE-Pro | |||||
|---|---|---|---|---|---|---|
| Metric | H0 | H5 | H0 | H5 | ||
| Actions / trajectory | 84.55 | 78.30 | −6.25 | 77.84 | 75.34 | −2.50 |
| Repeated reads / trajectory | 16.41 | 14.89 | −1.52 | 15.17 | 14.52 | −0.65 |
| Repeated-read share (%) | 48.12 | 46.61 | −1.51 | 44.77 | 44.17 | −0.61 |
| Post-final-edit check rate (%) | 81.43 | 80.57 | −0.86 | 86.39 | 87.43 | +1.04 |
| Resolved trajectories | Solved issues | |||||
| History type | H0 | H5 | H0 | H5 | ||
| Stable-solved | 176 | 176 | 0 | 37 | 37 | 0 |
| Mixed | 130 | 143 | +13 | 40 | 45 | +5 |
| Never-solved | 23 | 26 | +3 | 15 | 16 | +1 |
| All | 329 | 345 | +16 | 92 | 98 | +6 |
| Condition | History type | Traj. | Candidate sampling | Distinct actions | Executed comparison | Alt. selected | Semantic progress | Resolved |
|---|---|---|---|---|---|---|---|---|
| H0 | stable-solved | 185 | 36.22% | 91.04% | 86.89% | 30.19% | 21.08% | 95.14% |
| H5 | stable-solved | 185 | 53.51% | 90.91% | 92.22% | 43.37% | 35.14% | 95.14% |
| H0 | mixed | 255 | 53.73% | 93.43% | 95.31% | 43.44% | 35.29% | 50.98% |
| H5 | mixed | 255 | 83.53% | 94.37% | 94.53% | 41.05% | 56.47% | 56.08% |
| H0 | never-solved | 1,060 | 43.40% | 88.91% | 94.13% | 38.80% | 28.49% | 2.17% |
| H5 | never-solved | 1,060 | 78.77% | 88.50% | 94.05% | 35.68% | 37.92% | 2.45% |
| Compiler class | Issues | Mean rules | Active rules | Abstention |
|---|---|---|---|---|
| Stable-solved | 37 | 2.38 | 0.62 | 37.84% |
| Mixed | 41 | 2.22 | 1.61 | 7.32% |
| Never-solved | 210 | 2.29 | 1.47 | 13.81% |
| Insufficient | 12 | 2.33 | 0.00 | 100.00% |
| Condition | Coding actions | Validations | Trajectory-hours |
|---|---|---|---|
| SeedBank | 65,056 | 6,814 | 355.2 |
| SWE-Trail-H0 | 61,329 | 6,760 | 196.2 |
| SWE-Trail-H5 | 59,260 | 6,700 | 239.4 |
| SWE-Trail-H10 | 61,085 | 6,721 | 208.1 |
| Candidate set | Res. | Solved issues | Strict | Never traj. | Never issues |
|---|---|---|---|---|---|
| 10 SeedBank | 394 | 99 | 313 | 15 | 11 |
| 5 SeedBank + 5 H5 | 413 | 104 | 321 | 26 | 16 |
| Multilingual | SWE-Pro | |||
|---|---|---|---|---|
| Trajectory corpus | Mean | Range | Mean | Range |
| SeedBank | 63.33 | [63.00, 63.67] | 41.22 | [41.18, 41.31] |
| Top-5-of-10 | 64.11 | [63.33, 65.00] | 41.86 | [41.45, 42.13] |
| SWE-Trail-H5 | 65.67 | [64.00, 67.67] | 42.82 | [41.72, 43.37] |
| Top-5-hybrid | 66.22 | [65.33, 66.67] | 43.14 | [42.82, 43.37] |
| Training corpus | Multilingual | SWE-Pro |
|---|---|---|
| Independent SeedBank | 63.33 | 41.22 |
| Advice removed | 63.00 | 42.23 |
| Advice retained | 64.56 | 41.63 |
| SWE-Trail-H5 | 65.67 | 42.82 |
| Use of prior attempts | Consumer | Effect on later computation | Primary goal |
|---|---|---|---|
| Retrieved reflection or memory | Coding agent | Adds previous feedback or experience to the visible context | Improve the current solve |
| Distilled skill or workflow | Coding agent or workflow | Supplies reusable procedural guidance | Improve the current solve |
| Inference-time replay or refinement | Search harness and coding agent | Reuses prefixes or conditions generation on prior summaries | Improve or select a current solution |
| History-guided collection (ours) | Collector | Guides where additional collection effort is spent while history remains outside the agent context | Collect training trajectories |
LLM Agent Training
Large language model agent training teaches models to plan, use tools, and learn from multi-step interaction with environments.
See all 622 papers