As large language models (LLMs) increasingly transition from conversational assistants into autonomous agents capable of executing complex multi-step workflows, the mechanism by which they discover and utilize external software tools has become a critical area of study. A new research paper authored by Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, and Michael Xu investigates the fundamental architectural choice in tool-augmented LLM systems: whether to retrieve relevant software application programming interfaces (APIs) before planning an execution, or to plan an abstract execution strategy before performing retrieval.

The findings offer a nuanced look at the limitations of finite context windows and the mechanics of tool discovery within massive registries. Tool-augmented LLM agents rely on discovering relevant APIs from large registries before they can plan their execution. However, finite context windows strictly prohibit injecting all available tool definitions into a single prompt. This constraint forces system designers to develop efficient retrieval pipelines to bridge the gap between user intent and external software capabilities.

To address this challenge, the research examines two distinct paradigms. The dominant industry approach, termed Retrieve-then-Plan (RtP), embeds the user query and retrieves similar tools via approximate nearest-neighbor search directly from a vector database or registry. In contrast, the authors study an alternative paradigm known as Plan-then-Retrieve (PtR). In the PtR framework, the LLM first generates Abstract Tool Stubs—hypothesized function signatures that describe the specific capabilities needed to solve a user’s request. These generated stubs then serve as the retrieval queries against the API registry, rather than the raw user prompt itself.

To rigorously evaluate these competing paradigms, the researchers tested them on ToolBench, a comprehensive benchmark featuring 46,984 unique API endpoints distributed across 50 distinct functional categories. The evaluation was structured across three query subsets reflecting increasing levels of task complexity: single-tool tasks (G1), intra-category multi-tool tasks where multiple tools from the same domain are required (G2), and cross-category multi-tool tasks that demand coordination across disparate functional domains (G3).

The empirical results reveal a clear and decisive complexity-dependent crossover between the two methods. The study found that RtP outperforms PtR on single-tool queries, where direct semantic matching between the user prompt and the target API name is usually sufficient to find the right tool. Conversely, PtR outperforms RtP on complex multi-tool queries, where a single direct search fails to capture all the multifaceted requirements embedded in the request.

Crucially, this crossover phenomenon is remarkably stable. The research demonstrates that the performance crossover holds true across every tested retrieval budget, spanning from a retrieval parameter of $k=1$ up to $k=20$. Furthermore, the findings are robust across varying registry scales, maintaining consistency from compact registries of 1,000 APIs up to the full-scale benchmark of 47,000 APIs. The crossover is also model-agnostic, holding steady across different advanced model families, including Gemini 2.5 Flash and gpt-oss-120b.

A deeper analysis of the underlying mechanics reveals a fascinating failure mode unique to the PtR approach, which the authors characterize as stub hallucination. In this phenomenon, the LLM invents plausible but entirely non-existent API names and signatures during the planning phase. Interestingly, this behavior acts as a double-edged sword within the agentic pipeline. On simple queries, PtR’s generated stubs tend to abstract away proper-noun signals and specific naming conventions that the traditional RtP method matches directly and successfully. This unnecessary abstraction layer hurts performance on straightforward tasks.

However, on complex queries, that exact same hallucination and abstraction mechanism becomes a powerful asset. It enables the model to decompose a multifaceted, sprawling user intent into distinct functional sub-needs, creating targeted queries that unearth more relevant tools than a monolithic search could achieve.

The researchers also conducted a detailed evaluation of token overhead and computational costs. They showed that PtR’s required extra discovery call roughly doubles the overall inference cost of the system. For multi-tool queries, this added expense is well worth the investment, as the superior discovery performance pays off in task success rates. For single-tool queries, however, the doubled inference cost represents an inefficient use of resources without a corresponding gain in accuracy.

This economic trade-off points toward a practical engineering solution: complexity-adaptive routing. By dynamically routing simple queries to the lighter RtP pipeline and complex queries to the PtR framework, systems can optimize both performance and cost. The authors note that this routing decision can be driven efficiently by a zero-cost signal already natively present in the standard pipeline—specifically, RtP’s top-1 retrieval score, which naturally indicates whether a query is straightforward or requires deeper decomposition.

Related readings and updates in the broader research community highlight the ongoing evolution of these techniques. Large Language Models are increasingly employed for complex multi-step planning tasks, where the Tool Retrieval step is crucial for achieving successful outcomes. Two prevalent approaches for tool retrieval have historically included single-step retrieval, which utilizes the complete query, and sequential retrieval using Task Decomposition, where a full query is segmented into discrete atomic subtasks. While single-step retrieval often lacks the flexibility to handle complex workflows, ongoing academic exploration continues to refine how models discover and integrate external capabilities.

Academic contributions in this domain have frequently appeared at specialized venues. For instance, related work on progressive tool retrieval and context tuning for retrieval-augmented generation has been featured at forums such as the UncertaiNLP workshop at EACL, emphasizing the scientific community’s sustained focus on optimizing how artificial intelligence systems interact with external software registries and vast knowledge bases.