Beyond Quantity: Trajectory Diversity Scaling for Code Agents

Guhong Chen, Chenghao Sun, Cheng Fu, Qiyao Wang, Zhihong Huang, Chaopeng Wei, Guangxu Chen, Feiteng Fang, Ahmadreza Argha, Bing Zhao, Xander Xu, Qi Han, Hamid Alinejad-Rokny, Qiang Qu, Binhua Li, Shiwen Ni, Min Yang, Hu Wei, Yongbin LiarXiv 2026 · OpenReview

TL;DR

This paper introduces TDScaling, a novel data synthesis framework for training code agents that prioritizes diversity over sheer quantity. By focusing on diverse trajectories, TDScaling achieves better generalization and coding proficiency, outperforming quantity-based scaling and even surpassing larger models with less data. This offers a more efficient path to robust code agents.

What Problem Does This Paper Address?

Large language models (LLMs) are increasingly being used as "agents" that can interact with external tools (like APIs or code interpreters) to perform complex tasks. However, training these agents is hampered by the limitations of synthetic data. Simply generating more and more training examples (quantity scaling) leads to diminishing returns and an "early bottleneck" where models fail to generalize to new or less common scenarios. This is especially problematic because real-world tool ecosystems are dynamic and often feature "long-tail" behaviors (e.g., complex error handling, multi-step tool composition) that are hard to capture with simple, repetitive synthetic data. The paper aims to solve this by proposing a method that scales agent performance through the diversity of training trajectories, rather than just their volume.

Methods

TDScaling is a multi-faceted framework designed to generate high-quality, diverse training data for code agents. Its key innovations include:

  • Business Cluster Mechanism: Instead of treating all tools as isolated entities, TDScaling groups them into "Business Clusters" based on real-world service dependencies. This ensures that synthesized trajectories reflect logical relationships between tools, improving semantic coverage.
  • Blueprint-Driven Multi-Agent Paradigm: A multi-agent system (UserAgent, AssistantAgent, ObservationAgent) collaborates to generate trajectories. A "BlueprintAgent" creates a Scenario Blueprint (goal, plan, constraints, strategy profile) that guides the synthesis process, ensuring coherence and logical depth.
  • Adaptive Evolution with Diversity Metrics: This is the core of TDScaling. It uses a global memory to track and steer synthesis towards under-explored areas. Three key metrics guide this process:
  • Domain Entropy: Measures the breadth of tool domains covered.
  • Reasoning Mode Entropy: Quantifies the diversity of reasoning patterns (e.g., direct execution, error correction, multi-step planning).
  • Cumulative Action Complexity (CAC): Assesses the intrinsic difficulty and depth of interactions. This adaptive mechanism actively seeks out "long-tail" scenarios to prevent mode collapse and improve generalization.

  • Sandboxed Code Tool: A crucial component that acts as a regularizer. It allows agents to offload complex computations (like sorting or arithmetic) to a deterministic Python interpreter. This not only enhances programmatic reasoning but also mitigates "catastrophic forgetting" of intrinsic coding abilities that can occur during tool-specific fine-tuning.

Datasets

The paper utilizes a large-scale collection of 30,000+ raw MCP-compliant tool definitions as the source for its Business Clusters.

For training and evaluation, they use:

  • General Tool-Use Benchmarks:
    • BFCL (Augmented Multi-Turn subset): Evaluates stateful reasoning under complex conditions.
  • τ²-Bench: A dual-control Dec-POMDP environment for dynamic coordination.
  • Agentic Coding Tasks:
    • SWE-rebench (RebenchT): Assesses repository navigation and engineering adaptation.
  • CodeCI (Live-CodeBench): Evaluates end-to-end skills like self-repair and test prediction.
  • BIRD: A large-scale text-to-SQL benchmark.

The paper also mentions synthesizing complex tool-use trajectories from these clusters using their framework, which can be considered a newly generated dataset.

Key Insights and Ideas

  • Diversity is King (for Agent Training): The most significant insight is that simply increasing the quantity of synthetic data for code agents yields diminishing returns. The paper convincingly demonstrates that focusing on diversity (in terms of domains, reasoning modes, and complexity) is a far more effective strategy for improving generalization and performance, especially under fixed data budgets.
  • The "Early Bottleneck" is Real: Quantity-based scaling hits a performance ceiling prematurely because it fails to capture the rich, long-tail behaviors present in real-world tool interactions. TDScaling directly addresses this by actively seeking out these complex scenarios.
  • Bridging the Gap Between Tool Use and Core Coding: The sandboxed Code Tool is a clever way to prevent negative transfer. By integrating programmatic reasoning alongside tool use, it ensures that agents don't lose their fundamental coding skills, leading to a more robust overall capability.
  • A Principled Approach to Data Synthesis: TDScaling moves beyond random generation. The Business Cluster mechanism, Blueprinting, and adaptive evolution metrics provide a structured, goal-oriented approach to creating training data that is more aligned with real-world agent requirements.

Key Results

  • Data Efficiency: With only 500 training samples, TDScaling achieved 36.66% on the challenging BFCL Multi-turn benchmark, outperforming a much larger Qwen3-Coder-480B-A35B-Instruct baseline (35.91%).
  • Performance Ceiling: When scaled to 5,000 samples, TDScaling reached 40.44% on BFCL, surpassing previous State-of-the-Art (SOTA) and demonstrating a higher performance ceiling compared to quantity-based scaling.
  • General Improvement: TDScaling consistently improved performance across both general tool-use benchmarks (BFCL, τ²-Bench) and agentic coding tasks (RebenchT, CodeCI, BIRD).
  • Positive Transfer: Unlike baseline methods that sometimes suffered from negative transfer (eroding coding skills), TDScaling showed a positive gain of +4.00% overall on coding agent tasks, reaching 34.99%.
  • Higher Diversity Metrics: The synthesized dataset exhibited significantly higher Domain Entropy (4.25 vs. 2.15) and Reasoning Mode Entropy (8.97 vs. 5.42) compared to baselines, indicating broader coverage and reduced risk of mode collapse.
  • Increased Complexity: Trajectories generated by TDScaling had a higher Cumulative Action Complexity (μ = 20.9) compared to baselines (μ = 11.3), indicating more complex, multi-step reasoning chains.

Limitations and Future Work

  • Compute and Cost Intensity: Achieving high-quality, diverse trajectories requires a sophisticated multi-agent pipeline and powerful teacher models, making the synthesis process compute- and cost-intensive. The paper acknowledges trading generation speed for higher quality density.
  • Limited Interaction Scope: The current framework is limited to text-based tool calls and Python execution. Many real-world agents interact with graphical user interfaces and visual web content, which are multi-modal and have more complex state transitions.
  • Future Work: The authors suggest extending diversity and complexity signals to multi-modal settings and validating whether the same diversity-scaling behavior holds. They also plan to open-source their framework and synthesized dataset to encourage further research into diversity metrics and programmatic grounding for robust code agents.

Summary updated

BibTeX
@misc{chen2026beyond,
  author = {Guhong Chen and Chenghao Sun and Cheng Fu and Qiyao Wang and Zhihong Huang and Chaopeng Wei and Guangxu Chen and Feiteng Fang and Ahmadreza Argha and Bing Zhao and Xander Xu and Qi Han and Hamid Alinejad-Rokny and Qiang Qu and Binhua Li and Shiwen Ni and Min Yang and Hu Wei and Yongbin Li},
  title = {{Beyond Quantity: Trajectory Diversity Scaling for Code Agents}},
  year = {2026},
  eprint = {2602.03219},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.03219},
}
Figure