arXiv(opens in a new tab)cs.SEAug 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2608.27449

SWE-Prime: Fewer Trajectories, Better Performance

Dewu Zheng, Ruizhe Ye, Yanlin Wang, Yang Ye, Hongyu Zhang, Ensheng Shi, Xilin Liu, Yuchi Ma, Jianxing Yu, Zibin Zheng

Abstract

To improve large language models' ability to resolve real-world software issues, prior work has focused on constructing large-scale agent trajectory datasets and performing supervised fine-tuning (SFT) on successful trajectories. However, task success does not guarantee high-quality supervision: successful trajectories may still contain ineffective, redundant, or risky steps. Directly using such trajectories for SFT can introduce noisy supervision and encourage models to imitate undesirable problem-solving behaviors. Therefore, we propose SWE-PRIME, a multi-granularity, two-stage SFT data selection method that progressively filters training data at the trajectory and segment levels. Specifically, the first stage performs trajectory-level screening based on process quality, result quality, and data representativeness, selecting a high-quality and representative subset of successful trajectories. The second stage performs segment-level selection by grouping consecutive steps into semantic segments and assessing each segment based on its contribution to the final solution, learnability, and potential risks. During SFT, all segments remain in the sequence to preserve context, while only selected segments contribute to the loss computation. Experiments on SWE-Bench Pro and SWE-Bench Verified show that training on the 10% trajectory subset selected by SWE-PRIME outperforms training on the full resolved dataset, yielding relative performance gains of up to 12.2% and 24.2%, respectively.

Introduction

Software issue resolution in real-world repositories has received growing attention in recent years (Jimenez et al. 2024; Pan et al. 2024; Yang et al. 2025b; Li et al. 2026). To improve coding agents' performance on this long-horizon task, recent work has constructed large-scale software engineering datasets for supervised fine-tuning (SFT) (Pan et al. 2024; Yang et al. 2025b; Jain et al. 2025; Guo et al. 2025; Zheng et al. 2023). For example, SWE-Gym derives executable tasks from real-world GitHub issues, while SWE-smith and R2E-Gym use synthetic data generation to scale task and trajectory collection. These approaches then perform SFT on successful trajectories identified through execution-based verification.

However, task success alone does not guarantee high-quality supervision (Uesato et al. 2022; Lightman et al. 2023; Xiong et al. 2024; Wang, Pradel, and Liu 2026). Successful trajectories may still contain ineffective, redundant, or risky behaviors that should not be used as supervision for SFT (Chen et al. 2025b,a; Wang et al. 2025a). Figure 1 illustrates this issue from three perspectives.

Outcome View. Existing work adopts an outcome-based view and thus retains both successful trajectories (Pan et al. 2024; Yang et al. 2025b; Jain et al. 2025; Guo et al. 2025). Trajectory View. The trajectory view shows why Trajectory B is unsuitable for SFT through the following quality aspects:

(1) Problem-solving Pattern: Standard problem-solving processes help models learn systematic issue-resolution behaviors during SFT (Chen, Ma, and Jiang 2026). Trajectory A follows an observe-edit-verify workflow, whereas Trajectory B modifies the code without prior exploration.

(2) Tool Call Success Rate: Frequent tool failures introduce unreliable tool-use patterns into SFT supervision (Yang et al. 2025a). Trajectory B contains more such failures, whereas Trajectory A demonstrates stable tool use.

(3) Continuous Redundancy: Long-context repetition caused by losing track of prior actions introduces undesirable SFT supervision (Xiao et al. 2025). Accordingly, Trajectory B should be excluded because it repeats the same localization action without obtaining new information.

(4) Git Hacking: Leakage-based shortcuts introduce cheating behaviors into SFT supervision (Song et al. 2026; Tao et al. 2026). Trajectory B is unsuitable for SFT because it retrieves target repair information from version history.

(5) Result Quality: SFT should favor minimal yet sufficient patches to reduce regression risks (Chen and Jiang 2025). Trajectory A follows this principle, whereas Trajectory B modifies additional unnecessary files.

Segment View. Even a trajectory assessed as high-quality at the trajectory level may still contain segments of limited value for SFT (Xiong et al. 2024; Wang et al. 2025a; Deng et al. 2025b). Segment 2 exemplifies such low-value behavior. Its steps execute successfully, but the segment does not contribute to the final fix, making it unsuitable for supervision. We assess semantic segments rather than individual

∗^{*}These authors contributed equally.

†^{\dagger}Corresponding author.

Figure

Figure 1: Motivating example comparing outcome-only, trajectory-level, and segment-level data selection.

steps because a problem-solving behavior often spans multiple actions and observations that should be evaluated together to determine its intent, outcome, and contribution.

These observations suggest that high-quality SFT data should be compact and low-noise, providing demonstrations that models can reliably learn from (Chen et al. 2024; Liu et al. 2024). To this end, we propose SWE-PRIME, a multi-granularity, two-stage data selection method that progressively filters training data from the trajectory level to the semantic segment level. Specifically, Stage 1 operates at the trajectory level to select a high-quality and representative subset of successful trajectories. Stage 2 operates at the semantic segment level to identify high-value behaviors within the retained trajectories. During SFT, all segments remain in the sequence to preserve context, while only selected segments contribute to the loss.

We evaluate SWE-PRIME on two representative benchmarks, SWE-Bench Pro and SWE-Bench Verified. Models trained on the 10% subset selected by SWE-PRIME achieve relative gains of up to 12.2% and 24.2% over models trained on all successful trajectories, respectively.

Our main contributions are summarized as follows:

• We highlight that prior work largely overlooks differences in data quality among successful trajectories.

• We introduce semantic segments as behaviorally coherent units for fine-grained supervision-quality assessment in long-horizon trajectories, rather than isolated steps.

• We propose SWE-PRIME, a multi-granularity, two-stage method designed to provide compact, low-noise, and informative supervision for coding-agent SFT.

• Through extensive experiments across three models and two benchmarks, we demonstrate that SWE-PRIME substantially outperforms SFT on the full dataset while using only 10% of the trajectories.

References (45)