Systematic Evaluation of Trajectory Curation for LoRA Fine-Tuning of Code Agents

Systematic study on trajectory filtering for LoRA fine-tuning of code agents. Quality-quantity trade-off and error-retry rate key. CE loss proxy validated.

sábado, 25 de julio de 2026 • 3 min read • Q2BSTUDIO Team

Calidad vs cantidad en datos de trayectoria para agentes de código

In the current software development landscape, the demand for intelligent agents capable of interacting with complex environments and autonomously executing programming tasks has grown exponentially. Supervised fine-tuning (SFT) of open-weight language models, such as Qwen2.5-Coder-7B-Instruct, has emerged as a promising approach to building code agents without relying on proprietary APIs. However, one critical factor determining the success of this process is the quality and quantity of training trajectories — sequences of actions performed by an expert agent — used during fine-tuning. In this article, we provide an in-depth analysis of a systematic study on trajectory curation for LoRA (Low-Rank Adaptation) applied to code agents, extracting key lessons that any engineering team should consider when implementing AI solutions in their workflows.

The underlying research is based on the SWE-trajectory dataset, containing 67,074 trajectories, of which 32,161 are labeled as “resolved”. The goal was to understand how the quality and quantity of these trajectories influence model performance after LoRA fine-tuning. To this end, the authors proposed a two-axis quality scoring framework: Efficiency and Style. The first axis assesses whether the agent completes the task in the fewest possible steps, while the second measures the coherence and structure of actions, ensuring the process is replicable and maintainable. This approach allowed them to classify trajectories by quality levels and experiment with different training subsets.

The results revealed a non-trivial interaction between quality and scale. At small scales (e.g., 500 trajectories), doubling the dataset yields a significant reduction in cross-entropy loss (approximately 12.7%). However, as the dataset grows, quality becomes more influential: with 2,000 trajectories, the difference between using the highest-quality trajectories and a random subset reaches 3.6% (p = 0.016). This suggests that for limited data budgets, investing in quantity is more efficient, while with more resources, quality becomes the differentiating factor.

Furthermore, the study broke down the impact of each sub-dimension of the quality framework. The error-retry rate turned out to be the dominant dimension, as by itself it matched the performance of the full composite with a difference of less than 0.2%. This finding is crucial because it greatly simplifies the curation task: instead of applying multiple metrics, teams can focus on removing trajectories that contain too many retries or unnecessary corrections, thereby accelerating the training cycle without sacrificing performance.

From a practical perspective, these results have direct implications for companies like Q2BSTUDIO, which integrates artificial intelligence solutions into its cloud AWS/Azure services. For example, when developing code agents to automate software maintenance tasks, the ability to select efficient training trajectories can significantly reduce cloud compute time and, consequently, operational costs. Moreover, integrating these agents with Business Intelligence platforms like Power BI enables dynamic reports on software performance, while cybersecurity benefits from agents capable of autonomously detecting and responding to vulnerabilities.

Q2BSTUDIO, as a custom software development company, has adopted such techniques to offer its clients more robust and scalable solutions. Applying LoRA with curated trajectories not only improves agent accuracy but also allows models with 7B parameters to achieve competitive performance without requiring massive infrastructure. This democratizes access to generative AI, enabling small and medium-sized enterprises to implement personalized coding assistants without relying on hyperscale resources.

Finally, the study validates an alternative evaluation protocol for 7B-scale models, where resolution rates on benchmarks like SWE-bench are near zero. The authors demonstrate that cross-entropy loss on held-out trajectories perfectly correlates with the quality of the first generated action (ROUGE-L, Spearman ρ = -1.00), providing a reliable proxy metric to guide fine-tuning. This approach is especially useful in enterprise environments where experimentation cycles must be fast and cost-effective.

In conclusion, trajectory curation for LoRA in code agents is a strategic component that combines art and science. Companies investing in AI, such as Q2BSTUDIO, should consider both the quantity and quality of their training data, prioritizing the reduction of erroneous retries when resources are limited. With the right tools — from cloud to artificial intelligence — it is possible to build code agents that not only solve tasks but do so efficiently, securely, and aligned with business objectives.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.