ToolSearcher: Optimizing Tool Selection at Scale via Reinforcement Learning

Zhenlong Dai, Xujie Song, Zitong Wang, Tong Niu, Jian liu, Weiqiang Wang, Xiu Tang, Sai Wu, Chang Yao, Jingyuan Chen

TL;DR

ToolSearcher is a reinforcement learning (RL) framework designed to help Large Language Model (LLM) agents navigate massive, real-world tool repositories. By using fine-grained reward signals and category-specific training, it significantly improves an agent's ability to search for, distinguish between, and successfully compose tools for complex tasks.

What Problem Does This Paper Address?

While LLMs are increasingly used as "agents" that can call external APIs, most research assumes the agent has access to a small, predefined set of tools. In reality, ecosystems like PyPI or HuggingFace contain thousands of tools.

This "large-scale tool selection" presents three major hurdles:

  1. Context Constraints: You cannot fit documentation for 10,000 tools into a single prompt.
  2. Functional Similarity: Many tools perform nearly identical tasks (e.g., multiple weather APIs), making it hard for an LLM to pick the correct one for a specific interface requirement.
  3. Composition Complexity: Complex tasks require chaining tools together, meaning the agent must reason about whether the output of Tool A is compatible with the input of Tool B.

Existing RL methods for search (often designed for knowledge retrieval/RAG) fail here because they focus on finding information rather than functional compatibility.

Methods

ToolSearcher introduces three novel components to the RL training pipeline:

  • Category-Constrained Tool Discrimination (CCTD): To sharpen the model's "eyes," the authors first train it in a highly constrained environment. The agent must choose between functionally similar tools within a single category (e.g., choosing the right "Sports" API). This forces the model to attend to subtle differences in API schemas.
  • Event-Level Search Modeling (ESM): Instead of only rewarding the final answer, ESM provides rewards for the specific "event" of discovering a necessary target tool for the first time during a multi-turn search. This encourages active, efficient exploration.
  • Trajectory-Aligned Credit Allocation (TCA): This addresses the "credit assignment" problem. In a multi-step trajectory, some steps might be successful searches while the final selection fails. TCA assigns objective credit based on the agent's progress at different stages, ensuring that a good search isn't "punished" just because the final decision-making step was flawed.
Figure 1: Overview of ToolSearcher. (a) Illustration of the category-constrained tool discrimination. (b) Illustration of RL for tool selection that contains event-level search modeling and trajectory- aligned credit allocation.

Datasets

The authors evaluated ToolSearcher using:

  • StableToolBench: A large-scale benchmark containing over 16,000 APIs across 49 categories. It includes three scenarios: I1 (single-tool), I2 (multi-tool within one category), and I3 (complex multi-tool across different collections).
  • AppWorld: A high-quality environment featuring 457 APIs across 9 apps, used to test "out-of-distribution" (OOD) robustness in stateful, real-world scenarios.

Key Insights and Ideas

  • Search is Planning: The paper argues that tool selection isn't just a retrieval task; it's a planning task. The agent must hypothesize a tool chain and then search for the specific links to complete that chain.
  • Nuance Matters: Training on "hard" subsets (CCTD) makes the model better at "easy" global searches. By forcing the model to distinguish between two very similar tools early in training, it becomes much more robust when searching the entire 16k-tool repository.
  • De-coupling Search from Selection: A key "aha moment" is that an agent can be a great "searcher" but a poor "decider." ToolSearcher’s reward structure (TCA) recognizes this, allowing the model to optimize search capabilities even when the final tool-calling logic isn't yet perfect.

Key Results

ToolSearcher demonstrated substantial improvements over strong RL baselines like GDPO and Search-R1:

  • Massive Performance Jumps: On the Qwen2.5-7B model, ToolSearcher improved the overall F1 score from a baseline of 9.8% to 51.3%.
  • Superior Composition: In the most challenging "I3" scenario (complex tool composition), ToolSearcher outperformed the second-best method (GDPO) by 6.6% in F1 score.
  • Better Balance: As shown in Figure 2, ToolSearcher effectively balances "Search Recall" (finding the tools) and "Final Recall" (selecting the right ones), whereas other models often sacrifice one for the other.
Comparison of tool-selection capabilities across different scenarios, showing the balance between SRecall and Recall.

Limitations and Future Work

  • Synthetic Data Bias: The training data (from StableToolBench) features many "parallel" tool calls. Real-world tasks often require "sequential" dependencies (Tool B needs Tool A's output), which remains a challenge.
  • Statefulness: While the model was tested on AppWorld (which is stateful), the training data was largely stateless. Future work could involve training on environments where tool actions change the world state.
  • Context Window: The current framework is limited to 8 interaction turns due to context length constraints, which may be insufficient for extremely complex, long-tail tasks.

Summary updated

BibTeX
@inproceedings{dai2026toolsearcher,
  author = {Zhenlong Dai and Xujie Song and Zitong Wang and Tong Niu and Jian liu and Weiqiang Wang and Xiu Tang and Sai Wu and Chang Yao and Jingyuan Chen},
  title = {{ToolSearcher: Optimizing Tool Selection at Scale via Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=EFnOrwjviv},
}
Figure