Table of Contents
Fetching ...

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 Li

TL;DR

This work tackles the generalization bottleneck of code agents operating under the Model Context Protocol by shifting synthetic data emphasis from quantity to trajectory diversity. TDScaling introduces a four-stage pipeline that builds tool-space via Business Clusters, crafts scenario blueprints for coherent multi-agent synthesis, and employs adaptive evolution guided by Domain Entropy, Reasoning Mode Entropy, and Cumulative Action Complexity, with a sandboxed code tool regularizing reasoning. Empirical results on general tool-use benchmarks and coding tasks show that diversity scaling can surpass quantity scaling, achieving higher performance ceilings with smaller data budgets and reducing negative transfer between tool tuning and intrinsic coding abilities. The approach offers a practical, data-efficient path to robust code agents and includes plans to release the full codebase and synthesized dataset to support future diversity-focused research.$H_{\text{dom}}$, $H_{\text{mode}}$, and CAC are central to measuring and driving the diversity that underpins these gains.

Abstract

As code large language models (LLMs) evolve into tool-interactive agents via the Model Context Protocol (MCP), their generalization is increasingly limited by low-quality synthetic data and the diminishing returns of quantity scaling. Moreover, quantity-centric scaling exhibits an early bottleneck that underutilizes trajectory data. We propose TDScaling, a Trajectory Diversity Scaling-based data synthesis framework for code agents that scales performance through diversity rather than raw volume. Under a fixed training budget, increasing trajectory diversity yields larger gains than adding more trajectories, improving the performance-cost trade-off for agent training. TDScaling integrates four innovations: (1) a Business Cluster mechanism that captures real-service logical dependencies; (2) a blueprint-driven multi-agent paradigm that enforces trajectory coherence; (3) an adaptive evolution mechanism that steers synthesis toward long-tail scenarios using Domain Entropy, Reasoning Mode Entropy, and Cumulative Action Complexity to prevent mode collapse; and (4) a sandboxed code tool that mitigates catastrophic forgetting of intrinsic coding capabilities. Experiments on general tool-use benchmarks (BFCL, tau^2-Bench) and code agent tasks (RebenchT, CodeCI, BIRD) demonstrate a win-win outcome: TDScaling improves both tool-use generalization and inherent coding proficiency. We plan to release the full codebase and the synthesized dataset (including 30,000+ tool clusters) upon publication.

Beyond Quantity: Trajectory Diversity Scaling for Code Agents

TL;DR

This work tackles the generalization bottleneck of code agents operating under the Model Context Protocol by shifting synthetic data emphasis from quantity to trajectory diversity. TDScaling introduces a four-stage pipeline that builds tool-space via Business Clusters, crafts scenario blueprints for coherent multi-agent synthesis, and employs adaptive evolution guided by Domain Entropy, Reasoning Mode Entropy, and Cumulative Action Complexity, with a sandboxed code tool regularizing reasoning. Empirical results on general tool-use benchmarks and coding tasks show that diversity scaling can surpass quantity scaling, achieving higher performance ceilings with smaller data budgets and reducing negative transfer between tool tuning and intrinsic coding abilities. The approach offers a practical, data-efficient path to robust code agents and includes plans to release the full codebase and synthesized dataset to support future diversity-focused research., , and CAC are central to measuring and driving the diversity that underpins these gains.

Abstract

As code large language models (LLMs) evolve into tool-interactive agents via the Model Context Protocol (MCP), their generalization is increasingly limited by low-quality synthetic data and the diminishing returns of quantity scaling. Moreover, quantity-centric scaling exhibits an early bottleneck that underutilizes trajectory data. We propose TDScaling, a Trajectory Diversity Scaling-based data synthesis framework for code agents that scales performance through diversity rather than raw volume. Under a fixed training budget, increasing trajectory diversity yields larger gains than adding more trajectories, improving the performance-cost trade-off for agent training. TDScaling integrates four innovations: (1) a Business Cluster mechanism that captures real-service logical dependencies; (2) a blueprint-driven multi-agent paradigm that enforces trajectory coherence; (3) an adaptive evolution mechanism that steers synthesis toward long-tail scenarios using Domain Entropy, Reasoning Mode Entropy, and Cumulative Action Complexity to prevent mode collapse; and (4) a sandboxed code tool that mitigates catastrophic forgetting of intrinsic coding capabilities. Experiments on general tool-use benchmarks (BFCL, tau^2-Bench) and code agent tasks (RebenchT, CodeCI, BIRD) demonstrate a win-win outcome: TDScaling improves both tool-use generalization and inherent coding proficiency. We plan to release the full codebase and the synthesized dataset (including 30,000+ tool clusters) upon publication.
Paper Structure (42 sections, 9 equations, 10 figures, 3 tables)

This paper contains 42 sections, 9 equations, 10 figures, 3 tables.

Figures (10)

  • Figure 1: Contrast between Existing Quantity Scaling and our Diversity Scaling. Instead of relying on costly, data-hungry expansion, our approach optimizes for trajectory diversity. This strategy addresses the poor generalization of Code Agents in custom MCP environments, achieving stronger robustness with a smaller, high-quality dataset.
  • Figure 2: Overview of the TDScaling framework. The pipeline has four stages: (1) Tool-Space Construction: Raw MCP definitions are organized into Business Clusters and filtered via greedy selection to maximize functional coverage. (2) Blueprint Synthesis: Conditioned on the selected toolset and Global Memory scarcity, a Blueprint Agent generates a Scenario Blueprint with goals, plans, constraints, and strategies. (3) Multi-Agent Execution: User, Assistant, and Observation agents generate trajectories, dynamically invoking a Code Tool for programmatic reasoning, while a Quality Agent enforces format adherence and logical consistency. (4) Adaptive Evolution: Validated trajectories are scored for diversity and complexity; successful traces update Global Memory, which adjusts strategy profiles to steer generation toward under-explored reasoning modes and higher-complexity regions.
  • Figure 3: Diversity Analysis. We quantitatively compare the Reasoning Mode Entropy ($H_{\text{mode}}$) and Domain Entropy ($H_{\text{dom}}$). Ours (Red) achieves significantly higher entropy scores ($8.97$ and $4.25$) compared to the Baseline ($5.42$ and $2.15$). Mechanism: This performance gap stems from our dynamic tagging-and-evolution loop, where the system autonomously tags generated trajectories with reasoning modes and actively guides subsequent synthesis to not only fill distributional gaps but also explore novel, non-prespecified strategies suitable for complex tool clusters.
  • Figure 4: Data Scaling Analysis on BFCL Benchmark. Our method (Red) achieves strong performance with only 1k samples and reaches 40.44% at 5k samples. In contrast, baselines (dashed lines) exhibit Inverse Scaling, where performance degrades with more data, indicating overfitting to low-quality, homogeneous patterns.
  • Figure 5: Detailed Dataset Statistics.(a-b) Domain Interaction Density: Ours (b) demonstrates significantly richer cross-domain interactions compared to the sparse w/o All configuration (a). (c) Complexity Distribution: The KDE plot confirms that our evolutionary framework generates trajectories with much higher complexity ($\mu=20.9$) than the w/o All baseline ($\mu=11.3$).
  • ...and 5 more figures