Trajectory Data Quality Impacts Code Agent Fine-Tuning

Yunze Han· July 21, 2026 View original

Summary

This study systematically evaluates how the quality and quantity of expert agent trajectories affect LoRA fine-tuning of open-weight LLMs for code agents. It proposes a two-axis quality scoring framework (Efficiency and Style) and finds a scale-dependent quality-quantity trade-off, with error-retry rate being a dominant quality dimension.

Fine-tuning open-weight Large Language Models (LLMs) with expert agent trajectories is a popular method for developing capable code agents, especially without relying on proprietary models. However, the precise impact of trajectory data quality and quantity on model performance has remained largely unexplored. This research provides a systematic empirical study on how filtering trajectory data affects LoRA fine-tuning for code agents. The study introduces a two-axis quality scoring framework, evaluating trajectories based on "Efficiency" and "Style." Through 16 controlled experiments, it investigates the interplay of strategy, scale, and various ablations. Given the low resolve rates of 7B-scale models on SWE-bench, cross-entropy (CE) loss on held-out trajectories is used as the primary metric, validated by its strong correlation with ROUGE-L. Key findings reveal a scale-dependent trade-off between quality and quantity. At smaller dataset scales, doubling the quantity yields significant performance gains, while at larger scales, the quality gap (e.g., between top-quality and random trajectories) becomes more pronounced. The error-retry rate is identified as a particularly influential sub-dimension of quality. These results underscore that trajectory-level quality scoring is a viable, though scale-sensitive, lever for fine-tuning code agents.

Why it matters

Professionals developing AI code assistants or automated software engineering tools can significantly improve model performance and efficiency by strategically curating their training data, focusing on quality over mere quantity, especially at larger scales.

How to implement this in your domain

  1. 1Develop a data curation pipeline that scores expert trajectories based on efficiency and style metrics.
  2. 2Prioritize filtering out low-quality trajectories, especially those with high error-retry rates, before fine-tuning.
  3. 3Experiment with different scales of high-quality data to find the optimal balance for LoRA fine-tuning.
  4. 4Adopt cross-entropy loss on held-out trajectories as a proxy metric for evaluating code agent performance in early development stages.

Who benefits

Software DevelopmentAI/ML DevelopmentDevOpsEdTech

Key takeaways

  • Trajectory data quality significantly impacts code agent fine-tuning performance.
  • A two-axis framework (Efficiency and Style) can score trajectory quality.
  • The quality-quantity trade-off is scale-dependent, favoring quality at larger scales.
  • Minimizing error-retry rates in trajectories is crucial for better models.

Original post by Yunze Han

"arXiv:2607.17205v1 Announce Type: new Abstract: Supervised fine-tuning (SFT) of open-weight LLMs on expert agent trajectories has emerged as a prominent approach to building capable code agents without reliance on proprietary models. A central yet underexplored question is how tr…"

View on X

Originally posted by Yunze Han on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses