Quality, Not Just Outcome: A Structural Scoring Framework for Selecting Coding-Agent Trajectories for Supervised Fine-Tuning
Organizations: National Key Laboratory for Multimedia Information Processing, Peking University · Huawei Technologies Co., Ltd.
Abstract
Open coding agents are commonly trained through supervised fine-tuning on interaction trajectories whose final patches pass the benchmark test suite. However, this outcome-level filtering criterion ignores process quality: trajectories that eventually succeed may still contain inefficient interaction patterns such as repetitive file inspection, unstable tool usage, or delayed modification behavior, all of which become part of the imitation target. We propose TQS (Trajectory Quality Score), a structural scoring framework for coding-agent trajectories that operates directly on trajectory structure, requires no LLM judge, and runs in linear time. TQS characterizes trajectory quality through structural signals organized around structured convergence: information focus, intent--action alignment, and policy dynamics. Using 155,144 successful trajectories from a public open-license corpus, we rank trajectories by TQS and fine-tune coding agents on filtered subsets. Models trained on top-ranked trajectories consistently outperform those trained on random or bottom-ranked subsets on SWE-Bench-Verified. Our results suggest that process-level trajectory quality is an important factor in coding-agent supervision and that structural trajectory filtering provides an effective and scalable alternative to LLM-based data selection.
Figures & tables
| Subset | Top | Bottom | Random |
| # trajectories | 1,024 | 1,024 | 1,024 |
| Mean tqs | 0.714 | 0.454 | 0.589 |
| Mean steps | 34.2 | 53.0 | 41.0 |
| Mean tokens (K) | 28.1 | 26.3 | 26.9 |
| Tasks / repos | 847/209 | 847/204 | 825/217 |
| Max per task | 30 | 30 | 59 |
| pass@1 by difficulty (%) | |||||||
| ID | Method | Easy | Medium | Hard | Overall | Base | |
| No-SFT control | |||||||
| B0 | Qwen3-Coder-30B-A3B (base, no SFT) | — | 36.6 | 19.2 | 2.2 | 24.4 | — |
| Subset baselines (matched 1,024 trajectories, identical SFT recipe) | |||||||
| B1 | Random- | 1,024 | 40.7 | 16.9 | 2.2 | 24.8 | 0.4 |
| B2 | Bottom- (lowest tqs ) | 1,024 | 33.5 | 16.9 | 0.0 | 21.8 | 2.6 |
| Validation statistic | Human | Sonnet-5 |
| High vs. Low agreement | 85.2 (208/244) | 81.1 (198/244) |
| Mid vs. Low agreement | 74.2 (190/256) | 77.0 (197/256) |
| High vs. Mid agreement | 76.8 (172/224) | 67.4 (151/224) |
| Overall agreement | 78.7 (570/724) | 75.4 (546/724) |
| Pooled concordance | 73.3 (631/861) | 76.2 (656/861) |
| Full-order match | 45.7 (137/300) | 41.3 (124/300) |
| Selection signal | pass@1 |
| Full tqs -Top | 27.6 |
| w/o Information focus | 24.6 |
| w/o Intent–action alignment | 23.0 |
| w/o Policy dynamics | 25.8 |
| Random- | 24.8 |
| Base (no SFT) | 24.4 |
| Training Data | Fine-tuned models | |||
| Process metric | Top- | Top | Rand | Bottom |
| Mean Steps | 34.2 | 50.66 | 57.64 | 63.46 |
| Mean oec | 0.603 | 0.571 | 0.521 | 0.484 |
| Mean psn | 0.753 | 0.570 | 0.548 | 0.568 |
| Mean scp | 0.994 | 0.777 | 0.798 | 0.772 |
| Mean ped | 0.826 | 0.192 | 0.267 | 0.164 |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Component | Weight | Run 2 | Run 4 |
| oec | 0.30 | 0.7384 | 0.3120 |
| iac | 0.25 | 0.6667 | 0.5610 |
| psn | 0.10 | 0.8491 | 0.5708 |
| tte | 0.10 | 0.5718 | 0.4046 |
| scp | 0.05 | 0.9904 | 0.5280 |
| ped | 0.10 | 1.0000 | 0.0000 |
| Human | Claude Sonnet-5 | |||||
| Contrast | Agreement | 95% CI | Agreement | 95% CI | ||
| High vs. Low | 85.2% (208/244) | 80.3–89.1 | 81.1% (198/244) | 75.8–85.6 | ||
| Mid vs. Low | 74.2% (190/256) | 68.5–79.2 | 77.0% (197/256) | 71.4–81.7 | ||
| High vs. Mid | 76.8% (172/224) | 70.8–81.8 | 67.4% (151/224) | 61.0–73.2 | ||
| Overall | 78.7% (570/724) | 75.6–81.6 | 75.4% (546/724) | 72.1–78.4 | ||
| Human rubric | Claude Sonnet-5 rubric | ||||||
| Contrast | Conc. | 95% CI | Conc. | 95% CI | Ties | ||
| High vs. Low | 78.3% (227/290) | 73.2–82.6 | 82.1% (238/290) | 77.2–86.1 | 10 | ||
| Mid vs. Low | 69.5% (203/292) | 64.0–74.5 | 75.7% (221/292) | 70.5–80.3 | 8 | ||
| High vs. Mid | 72.0% (201/279) | 66.5–77.0 | 70.6% (197/279) | 65.0–75.6 | 21 | ||
| Pooled | 73.3% (631/861) | 70.2–76.1 | 76.2% (656/861) | 73.2–78.9 | 39 | ||
| Component | Mean | Std. | Undefined |
| oec | 0.429 | 0.118 | 0.0% |
| psn | 0.646 | 0.153 | 0.0% |
| iac | 0.570 | 0.098 | 0.0% |
| tte | 0.550 | 0.038 | 0.0% |
| scp | 0.978 | 0.060 | 0.0% |
| ped | 0.580 | 0.232 | 0.7% |
| Score / Component | Pair-AUC |
| tqs composite | 1.000 |
| oec | 0.996 |
| iac | 0.963 |
| ped | 0.961 |
| psn | 0.839 |
| Source | Passing | Eligible | Retention |
| SWE-Smith | 89,501 | 23,569 | 26.3% |
| SWE-Rebench | 44,739 | 7,821 | 17.5% |
| R2E-Gym | 20,904 | 6,992 | 33.4% |
| All | 155,144 | 38,382 | 24.7% |
| Weight setting | Top-1024 overlap |
| Main weights | 100.0% |
| 93.1% | |
| 93.6% | |
| 93.1% | |
| 94.1% | |
| 98.3% |