An answer-first approach to generating efficient tool-use datasets for AI agents

ToolGrad introduces an answer-first framework for generating synthetic tool-use data, reversing traditional search-based paradigms.

2 min read

An answer-first approach to generating efficient tool-use datasets for AI agents

As AI agents become increasingly responsible for executing real-world tasks—such as navigating web searches, reading local files, or running generated scripts—large language models must learn to use tools both correctly and efficiently. Traditional data generation methods often rely on a query-first approach, using search algorithms like depth-first search to find tool paths for randomly sampled instructions. This process is frequently expensive and inefficient.

Presented at ACL 2026, a new framework called ToolGrad reverses this paradigm. It generates a verified tool-use chain first, and only then derives the corresponding user prompt. This design provides unambiguous ground-truth information, streamlining the annotation process into a single step and enabling the creation of long-horizon tool-use data at a significantly lower cost.

Key facts

Authors
Zhongyi Zhou and 7 other authors
Dataset
ToolGrad-500
Diagram comparing ToolGrad and prior art showing mini-batch API sequences versus annotation failures.
Comparison of ToolGrad's sequential API mini-batch method against traditional search-based paradigms., Source ↗

Adapting textual gradients for synthetic data

Table outlining target, batched data, gradient definition, and optimization steps for ML, TextGrad, and ToolGrad.
Table comparing the optimization components across Machine Learning, TextGrad, and ToolGrad., Source ↗

Machine learning models traditionally improve by calculating numerical loss gradients across mini-batches. Building on prior prompt engineering techniques that use descriptive plain-text feedback, ToolGrad applies the concept of textual gradients to dataset generation. Rather than optimizing static prompts, it uses these gradients to construct valid API workflows from extensive tool libraries iteratively.

The framework relies on four core modules:

Architecture flowchart showing API Proposer, Executors, Selector, and LLM Updater modules in action.
Flowchart illustrating the four core modules of the ToolGrad workflow., Source ↗
  • API Proposer, which narrows down a sampled set of APIs into promising candidates.
  • API Executors, which test selected APIs in parallel to produce detailed execution reports.
  • API Selector, which reviews reports to choose the best-performing API call, acting as a textual gradient for directional feedback.
  • LLM Updater, which revises the user query and AI response to match the updated API set.

Performance and evaluation

When evaluated against traditional query-first baselines using the ToolBench database, ToolGrad demonstrated higher pass rates and lower generation costs. Furthermore, small-scale datasets generated by the framework were used to fine-tune Gemma-3 models ranging from 1B to 12B parameters.

Tested on the Berkeley Function Calling Leaderboard, the fine-tuned models showed consistent improvements across all sizes. Notably, the ToolGrad-12B model achieved a score of 83.1, outperforming several advanced proprietary models and outscoring open-source alternatives. These results indicate that answer-first generation frameworks offer a scalable and economically viable path toward training capable digital agents.

Source: Original announcement

Worth a read?

Report

Comments