As Large Language Models (LLMs) evolve from simple conversational interfaces into autonomous agents capable of complex multi-step execution, the engineering challenge of equipping them with external capabilities has taken center stage. Tool-augmented LLM agents rely heavily on discovering relevant Application Programming Interfaces (APIs) from massive, centralized registries before they can plan and execute actions. However, the hard realities of finite context windows prevent developers from injecting thousands of tool definitions into a single prompt.

To navigate this constraint, the artificial intelligence research community has relied predominantly on a paradigm known as Retrieve-then-Plan, or RtP. In this standard framework, an incoming user query is embedded into a vector space, and the system retrieves similar tools via approximate nearest-neighbor search, filtering down the options before handing them over to the LLM for planning.

A new research paper authored by Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, and Michael Xu challenges this status quo by conducting a rigorous empirical study of an alternative paradigm: Plan-then-Retrieve, or PtR. In this inverted approach, the LLM first generates what the researchers call Abstract Tool Stubs—hypothesized function signatures that describe the needed capabilities—which are subsequently used as retrieval queries against the API registry.

The research team evaluated both paradigms across the comprehensive ToolBench benchmark, which encompasses a staggering 46,984 unique API endpoints distributed across 50 distinct categories. To capture the full spectrum of operational demands, the evaluation spanned three core query subsets: single-tool tasks, categorized as G1; intra-category multi-tool tasks, categorized as G2; and cross-category multi-tool tasks, categorized as G3.

The findings reveal a clear and definitive complexity-dependent crossover between the two approaches. According to the study, RtP outperforms PtR when handling single-tool queries. When the task requires only a single API endpoint, the direct embedding of the user query finds the correct tool more efficiently than forcing the model to hypothesize a function stub first.

However, the dynamic reverses entirely when confronting multi-tool queries. For tasks requiring multiple APIs—whether within the same functional category or spanning across disparate ones—PtR decisively outperforms RtP.

Crucially, the research demonstrates that this performance crossover is remarkably stable. The crossover holds true across every tested retrieval budget, spanning from a tight constraint of $k=1$ up to $k=20$ retrieved items. Furthermore, the pattern remains robust across varying registry scales, holding steady whether the system searches through a modest collection of 1,000 APIs or the full-scale registry of nearly 47,000 endpoints. The consistency of this behavior was also verified across diverse model families, confirming that the phenomenon is not an artifact of a single proprietary architecture, but rather a fundamental characteristic of LLM agent retrieval dynamics, verified on systems including Gemini 2.5 Flash and gpt-oss-120b.

To understand why this crossover occurs, the researchers conducted a deep qualitative and quantitative analysis, characterizing what they term a "stub-hallucination" failure mode. In the PtR paradigm, the LLM frequently invents plausible-sounding but non-existent API names when generating its abstract stubs. Interestingly, the authors discovered that this hallucination tendency acts as a double-edged sword.

On simple queries, PtR’s generated stubs inadvertently abstract away crucial proper-noun signals that the standard RtP approach can match directly against the registry, harming performance. But on complex queries, that exact same generative mechanism serves a vital decomposition function. By breaking down a multi-faceted user intent into discrete functional sub-needs, the hallucinated or hypothesized stubs successfully guide the retrieval engine to unearth disparate tools that a single direct query vector would otherwise miss.

Beyond raw accuracy and retrieval precision, the research team also evaluated the token overhead and computational economics of both paradigms. Their analysis indicates that PtR’s preliminary discovery call roughly doubles the total inference cost compared to traditional RtP.

For multi-tool queries, this added computational expense pays off handsomely through significantly improved task success rates and more accurate tool discovery. However, for simple, single-tool queries, the doubled inference cost represents an inefficient overhead with no performance justification.

This economic and performance split naturally points toward a practical engineering solution: complexity-adaptive routing. By dynamically switching between RtP and PtR based on the estimated complexity of the incoming task, agent architectures could capture the best of both worlds, deploying expensive sequential planning only when the query demands it.

Significantly, the paper suggests that implementing such an adaptive router does not require adding a heavy classification model to the inference pipeline. Instead, the routing decision can be driven by a zero-cost signal already natively present in the standard RtP workflow: the top-1 retrieval score generated during the initial approximate nearest-neighbor search.

As the field of AI agents continues to mature, balancing the trade-offs between computational overhead and task complexity remains a central hurdle for developers deploying large-scale systems in production environments.

Related readings and updates.

Large Language Models (LLMs) 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 are 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 lacks the flexibility to handle complex, multi-faceted instructions across expansive API registries, sequential task decomposition methods introduce additional latency and computational overhead. Researchers continue to explore progressive retrieval strategies to bridge this gap and optimize agent efficiency in dynamic operational environments.

This paper was accepted and presented at the UncertaiNLP workshop at EACL, highlighting the growing academic and industrial interest in managing uncertainty and optimization in natural language processing pipelines.

Large language models have the remarkable ability to solve new tasks with just a few examples, but they need access to the right tools to interact with external systems and databases. Retrieval Augmented Generation addresses this problem by retrieving a list of relevant tools or documents for a given task. However, standard retrieval-augmented generation tool retrieval steps often require all necessary information to be explicitly present in the input query, creating bottlenecks when user instructions are ambiguous, underspecified, or require multi-step logical synthesis.

Leave a Reply

Your email address will not be published. Required fields are marked *