ToolSearcher: Optimizing Tool Selection at Scale via Reinforcement Learning
Organizations: Zhejiang University · Ant Group
Abstract
Large language models (LLMs) excel at natural language processing but struggle to interact with external environments. Tool learning provides a promising way to extend LLMs into actionable agents, where tool selection is a critical prerequisite for successful tool use. Existing work often assumes a small or predefined set of tools, leaving large-scale tool selection underexplored. Real-world repositories contain a vast and diverse array of tools, making it difficult for LLMs to effectively search, distinguish, and compose tools under context-length constraints. We identify large-scale tool selection as a new challenge for agentic reinforcement learning, highlighting that existing RL methods for knowledge-based question answering are inadequate for selecting tools while considering compatibility. To address this challenge, we propose ToolSearcher, a novel RL framework for effective multi-turn search and fine-grained optimization in large-scale tool selection. Specifically, we introduce category-constrained tool discrimination to improve the model's ability to distinguish functionally similar tools, event-level search modeling to explicitly optimize the discovery of target tools during multi-turn search, and trajectory-aligned credit allocation to provide fine-grained reward signals for different stages of the search-selection process. Extensive experiments on large-scale tool selection benchmarks demonstrate that ToolSearcher consistently outperforms a set of strong baselines in challenging settings involving iterative search and complex tool composition.
Figures & tables
| Method | Overall | I1 | I2 | I3 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| F1 | Recall | Precision | Match | Inst. | Tool | Cate. | Inst. | Cate. | Inst. | |
| Qwen2.5-7B-Instruct | ||||||||||
| RAG | 0.194 | 0.285 | 0.174 | 0.075 | 0.257 | 0.226 | 0.230 | 0.139 | 0.105 | 0.126 |
| RAG SFT | 0.441 | 0.433 | 0.470 | 0.250 | 0.536 | 0.546 | 0.522 | 0.316 | 0.322 | 0.170 |
| Multi-turns | 0.098 | 0.110 | 0.100 | 0.046 | 0.119 | 0.161 | 0.099 | 0.039 | 0.065 | 0.054 |
| Search-R1 | 0.327 | 0.311 | 0.361 | 0.152 | 0.415 | 0.321 | 0.320 | 0.321 | 0.297 | 0.194 |
| Method | Tool Selcetion | Tool Calling | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| F1 | Recall | Precision | SRecall | Avg | Difficulty-1 | Difficulty-2 | ||||
| TGC | SGC | TGC | SGC | TGC | SGC | |||||
| Qwen2.5-7B-Instruct | ||||||||||
| Multi-turns | 0.327 | 0.263 | 0.483 | 0.428 | 0.133 | 0.029 | 0.140 | 0.053 | 0.125 | 0.00 |
| Search-R1 | 0.455 | 0.381 | 0.640 | 0.591 | 0.181 | 0.086 | 0.298 | 0.158 | 0.042 | 0.00 |
| GSPO | 0.478 | 0.411 | 0.657 | 0.601 | 0.123 | 0.057 | 0.175 | 0.105 | 0.062 | 0.00 |
| Datasets | Method | F1 | Recall | Precision | SRecall |
|---|---|---|---|---|---|
| StableToolBench | ToolSearcher | 0.513 | 0.511 | 0.534 | 0.680 |
| w/o CCTD | 0.477 | 0.466 | 0.510 | 0.583 | |
| w/o ESM | 0.394 | 0.377 | 0.433 | 0.456 | |
| w/o TCA | 0.461 | 0.444 | 0.501 | 0.538 | |
| AppWorld | ToolSearcher | 0.514 | 0.444 | 0.669 | 0.697 |
| w/o CCTD | 0.433 | 0.375 | 0.576 | 0.452 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Data Source | Number of Samples | API Count (Mean/Max) |
|---|---|---|
| I1 | 11,329 | 2.13/5 |
| I2 | 2,253 | 2.30/5 |
| I3 | 836 | 2.56/5 |
| Total | 14,418 | 2.18/5 |
Tool Selection
Tool selection studies how AI agents decide when to use external tools and which APIs, models, or physical tools best fit a task.
See all 25 papers