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

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

arXiv:2611.02074 · 2026-11-03 공개 · arXiv · PDF

coding-agents swe-bench model-training trajectory-collection agent-decision-making trajectory-guidance history-guided swe-trail

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.

한국어 요약

한 줄 요약

SWE-Trail은 이전 트래젝토리 정보를 활용해 새로운 코드 생성 트래젝토리를 수집하는 방식으로, 학습 모델의 성능을 향상시킨다.

핵심 기여도

핵심 아이디어

기존 방법은 각 이슈에 대해 독립적으로 여러 트래젝토리를 샘플링하고, 그 중 일부만 선택적으로 사용한다. 그러나 이는 중복된 탐색을 유발하며, 이전 트래젝토리에서 도출할 수 있는 유용한 정보를 활용하지 못한다. SWE-Trail은 이전 트래젝토리(히스토리)를 코드 에이전트의 컨텍스트에 노출시키지 않고, 수집 과정을 안내하는 방식을 제안한다. 구체적으로, 히스토리에서 유의미한 분기점(예: 성공 vs. 실패)을 식별하고, 해당 상태에서 코드 에이전트가 다양한 후보 행동을 제안하도록 유도한다. SWE-Trail은 동일 체크포인트에서 후보 행동을 실행해 가장 유리한 경로를 선택한 후, 코드 에이전트가 해당 경로를 따라 트래젝토리를 완성하도록 한다. 이 방식은 히스토리 정보를 수집 과정에 활용하면서도, 테스트 시 히스토리에 의존하지 않도록 모델을 학습시킨다.

기술적 접근법

주요 결과

의의 및 한계

SWE-Trail은 히스토리 정보를 수집 과정에 활용하면서도, 테스트 시 히스토리에 의존하지 않도록 모델을 학습시킴으로써 train-test mismatch를 방지한다. 이는 기존 방법에서 히스토리 정보를 코드 에이전트의 컨텍스트에 노출시키는 방식과 구별된다. 실험 결과는 히스토리가 단순히 수집 성공을 높이는 데 그치지 않고, 학습 데이터의 질을 향상시킬 수 있음을 보여준다. 그러나 현재 실험은 단일 수집 모델(GLM-5.1)과 단일 에이전트 프레임워크를 사용했으며, 히스토리가 수집 라운드 내에서 고정되어 있어, 다양한 모델과 동적 히스토리 업데이트를 고려한 연구가 필요하다.

실용적 활용

SWE-Trail은 코드 생성 에이전트의 학습 데이터 수집 과정을 최적화할 수 있어, 소프트웨어 엔지니어링 자동화, 코드 리뷰 시스템, 코드 테스트 자동화 등에 활용 가능하다. 특히, 대규모 모델 학습에서 효율적인 트래젝토리 수집이 필요한 상황에서 유용하다.