TL;DR
While Large Language Models (LLMs) excel at single-step tool use, they frequently stumble when orchestrating complex, multi-step API sequences due to precise parameter errors and a lack of intermediate feedback. This paper introduces a reinforcement learning (RL) framework that pairs a deterministic, cache-backed training environment with a novel "graduated reward" system to give LLMs dense learning signals. The resulting models show substantial improvements in multi-step orchestration accuracy and successfully transfer these skills to entirely unseen API ecosystems.
What Problem Does This Paper Address?
When an LLM needs to solve a real-world user request, it often can't rely on a single function call. Instead, it must perform multi-step tool orchestration: invoking a sequence of APIs in the correct order while passing the outputs of earlier calls as inputs to subsequent ones (e.g., finding a hotel ID, then using that ID to fetch room details).
While single-turn function calling is relatively mature, multi-step orchestration remains a major bottleneck. State-of-the-art models frequently fail because of parameter errors—either failing to extract parameters correctly from natural language or failing to propagate values between dependent steps.
Applying Reinforcement Learning (RL) to fix this faces two massive roadblocks:
- Environment Instability: Existing training environments often rely on live APIs (which suffer from latency and state changes) or synthetic simulators that fail to capture real-world data dependencies.
- Sparse Rewards: Standard RL relies on binary success/failure signals. If a model successfully executes 4 out of 5 complex steps but makes a minor typo on the 5th, a binary reward of
0provides no signal for partial correctness, leading to flat optimization landscapes.
Methods
The authors propose a systematic framework to address both environment and reward challenges:
1. Deterministic RL Training Environment & Constrained Synthesis
Instead of hitting live endpoints, the authors built a cache-based environment containing over 100,000 real API responses (grounded in Booking.com APIs). To generate high-quality training data without violating API constraints, they used a pipeline consisting of:
- Workflow Templates: Skeletons defining valid function sequences and their exact parameter dependency structures.
- Constraint-Aware Sampling: A three-level inverted index used to sample real, matching action-observation pairs step-by-step from the cache.
- Query Generation: An LLM synthesizes a natural language user query based on the sampled parameters, using an "echo-back" mechanism to ensure parameter fidelity.
2. Graduated Reward Design
To eliminate the sparse reward problem, the total reward ($R_{total}$) is split into two dense, complementary components:
- Atomic Validity ($R_{atomic}$): Evaluates local correctness. It uses Abstract Syntax Tree (AST) validation across three granular levels (correct function name, correct parameter structure/types, and exact value matching) combined with actual execution success in the environment.
- Orchestration Consistency ($R_{orch}$): Enforces global causal structure. It aligns predicted calls to ground-truth steps and applies a strict multiplicative gate: a step receives zero credit if any of its prerequisite steps are missing or executed out of order.
The framework utilizes Group Relative Policy Optimization (GRPO) to update the model based on these combined rewards.
Datasets
- ComplexFuncBench: A benchmark of 1,000 test samples spanning five travel-related domains (hotels, flights, car rentals, attractions, taxis), averaging 3.26 steps per query.
- BFCL v4 (Berkeley Function Calling Leaderboard): Used specifically to test cross-benchmark and cross-domain generalization on its Agentic category (which includes entirely different ecosystems like web search and memory management).
Key Insights and Ideas
- The Danger of One-Sided Rewards: Decomposing the reward is absolutely vital. As shown in the training dynamics, optimizing for $R_{atomic}$ alone causes "orchestration collapse" (the model generates valid individual calls but cannot sequence them). Conversely, optimizing for $R_{orch}$ alone causes "atomic collapse" (the sequence order is right, but the calls are semantically broken).
- SFT Struggles to Generalize: Supervised Fine-Tuning (SFT) on limited templates actually degraded cross-domain performance. SFT caused the models to overfit to specific query phrasings and increased function selection errors, whereas direct RL training via GRPO allowed the model to explore and generalize better.
- Template Diversity > Data Volume: Scaling analysis revealed that performance plateaus quickly when adding more samples per template. The real constraint is template diversity; exposing the model to a wider variety of causal structures is much more valuable than densifying existing ones.
Key Results
- Substantial Accuracy Gains: In an "oracle" setting (training on in-domain queries), RL training improved turn accuracy by 14.6% for Qwen3-8B and 17.1% for Qwen2.5-7B-Instruct.
- Robust Complexity Handling: Performance gains were particularly pronounced at higher dependency depths (e.g., a relative gain of +31% at depth 4) and on difficult "fan-out" parallel dependency patterns.
- Cross-Domain Transfer: When evaluated on the completely unseen BFCL v4 Agentic benchmark, the GRPO-trained Qwen3-8B model improved Web Search accuracy from 3.5% to 10.5% and Memory task accuracy from 17.4% to 21.7%, proving that the model learned fundamental orchestration skills rather than just memorizing the training domain.
Limitations and Future Work
- Domain Scope: The training environment and data synthesis pipeline were grounded primarily in travel APIs (Booking.com). Extending and validating this framework across broader enterprise API domains remains an open step.
- Manual Template Curation: The workflow templates used as skeletons for data synthesis currently require manual curation. The authors note that automating template derivation directly from raw API specifications (like OpenAPI/Swagger docs) is a promising avenue for future work.
Summary updated