Introduction
While Large Language Models (LLMs) have demonstrated significant proficiency in single-turn function calling, their performance often degrades in complex, multi-turn agentic workflows. Real-world tasks frequently require a sequence of interdependent tool calls, the ability to handle nested logic, and the discernment to ask for clarification when information is missing.
This paper introduces Magnet, a novel framework designed to synthesize high-quality, multi-turn tool-use data. By modeling API dependencies as a graph and employing a "Graph Translation" approach, Magnet generates structured trajectories that train models to navigate the nuances of long-form tool interaction. The resulting 14B parameter model not only sets new benchmarks for open-source models but also surpasses its own teacher model, Gemini-1.5-pro, on the Berkeley Function Calling Leaderboard (BFCL-v3).
The Multi-Turn Challenge
Current LLMs typically struggle with three primary failure modes in agentic scenarios:
- Nested/Implicit Calls: Tasks where a model must autonomously decide to call an intermediate function (e.g., unit conversion) to satisfy a user's primary request.
- Long-Term Dependencies: Scenarios where information retrieved in early turns must be accurately retained and utilized several turns later.
- Irrelevance and Missing Information: The tendency to hallucinate parameters or execute incorrect functions instead of identifying missing data and asking the user for clarification.
Existing datasets often lack the structural complexity required to address these failures, typically focusing on simple, independent tool calls rather than coherent, multi-step reasoning.
Methodology: Graph Translation
The core of the Magnet framework is the concept of Graph Translation. The researchers curated a pool of 5,011 APIs from StableToolBench and BFCL-v3, treating these APIs as nodes in a "local dependency graph." A directed edge is established between nodes if the output of one function can serve as the input for another.
The Synthesis Pipeline
The data generation process follows a structured four-step pipeline:
- FSP Generation: The system performs random walks on the dependency graph to create Function Signature Paths (FSPs)—logical sequences of tools that can work together to solve a hypothetical problem.
- Node Operations: To simulate real-world complexity, Magnet applies three structural operations to these paths:
- Insert: Adds "hidden" intermediate steps (like data formatting) to create nested call scenarios.
- Merge: Combines multiple functions into a single turn to test complex parallel reasoning.
- Split: Deliberately removes a required parameter or function, forcing the model to learn how to generate clarification questions.
- Back-and-Forth Translation: A teacher model (Gemini-1.5-pro) translates these FSPs into natural user queries (back-translation) and subsequently generates the executable code and responses (forth-translation).
- Hint-Based Distillation & mDPO: To ensure data quality, the teacher model is provided with "hints" (the intended FSP) during generation. Additionally, the framework generates "negative" trajectories—deliberately flawed paths—to facilitate multi-turn Direct Preference Optimization (mDPO).
Experimental Results
Magnet was evaluated against leading benchmarks, including the Berkeley Function Calling Leaderboard (BFCL-v3) and ToolQuery.
- BFCL-v3 Performance: The Magnet-14B-mDPO model achieved a score of 68.01, ranking 4th overall. This score notably surpasses proprietary models such as OpenAI’s o1 and the raw performance of Gemini-1.5-pro.
- ToolQuery Success: On the ToolQuery benchmark, which focuses on complex agentic tasks in domains like weather and cinema, the model reached a 73.3% success rate, a significant improvement over the base model's 51.7%.
- Multi-turn Proficiency: In scenarios specifically testing multi-turn interactions, Magnet models showed an improvement of over 30 points compared to the base Qwen2.5-Coder models, validating the effectiveness of the graph-based synthesis approach.
Key Insights
The Student Surpassing the Teacher
A significant finding of the Magnet research is that a smaller "student" model can outperform its teacher. By providing the teacher model with structural hints (the FSP) during data synthesis, the resulting trajectories are of higher quality than what the teacher would produce in a zero-shot setting. Training on this "gold standard" data allows the 14B student to exceed the teacher's baseline capabilities.
The Logic of Graphs
Unlike random sampling, which often results in nonsensical tool sequences, walking a dependency graph ensures that each turn in a conversation is logically linked to the previous one. This creates a coherent narrative that is essential for teaching models the "story" of a multi-step task.
The "Goldilocks Zone" of Irrelevance
The researchers identified a critical trade-off between tool-use accuracy and the ability to detect missing information. They found that a mixture of 15-17% irrelevance data (scenarios where the model should not call a tool or should ask for more info) is the optimal balance for maintaining high performance across both skills.
Conclusion and Future Work
Magnet demonstrates that structured, graph-based data synthesis is a powerful tool for enhancing the agentic capabilities of LLMs. While the current framework is limited to English text-based tools, it provides a blueprint for future expansions into multi-lingual and multi-modal tool use. Future research will also focus on improving "self-correction" mechanisms, enabling models to autonomously retry or pivot when a tool returns an error, further closing the gap between models and autonomous agents.
Summary updated