arXiv(opens in a new tab)cs.AIOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.19068

Plan or Retrieve First? A Scale Study of Tool Discovery Architectures

Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, Michael Xu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, Michael Xu

Apple

Tool-augmented LLM agents discover relevant APIs from large registries before planning execution, yet finite context windows prohibit injecting all tool definitions into a single prompt. The dominant approach, which we term Retrieve-then-Plan (RtP), embeds the user query and retrieves similar tools via approximate nearest-neighbor search. We study an alternative Plan-then-Retrieve (PtR) paradigm in which the LLM first generates Abstract Tool Stubs (hypothesized function signatures describing needed capabilities) which then serve as retrieval queries against the registry. Evaluating on ToolBench (46,984 unique API endpoints, 50 categories) across single-tool (G1), intra-category multi-tool (G2), and cross-category multi-tool (G3) query subsets, we find a clear complexity-dependent crossover: RtP outperforms PtR on single-tool queries while PtR outperforms RtP on multi-tool queries. This crossover holds at every retrieval budget (k=1 to 20), is robust across registry sizes from 1k to 47k APIs, and is consistent across model families (Gemini 2.5 Flash and gpt-oss-120b). We characterize a stub-hallucination failure mode (the LLM invents plausible but non-existent API names) that acts as a double-edged sword: on simple queries PtR's stubs abstract away proper-noun signals that RtP matches directly, yet on complex queries the same mechanism decomposes multi-faceted intent into functional sub-needs. We further analyze token overhead and show that PtR's extra discovery call roughly doubles inference cost, which pays off on multi-tool queries but hurts on single-tool ones, motivating complexity-adaptive routing as a practical direction — one that can be driven by a zero-cost signal already present in the pipeline (RtP's top-1 retrieval score).

Venue: Accepted at EMNLP 2026 (Industry Track)

Correspondence: mingfei_zhang@apple.com

Date: 01 Jun 2026

1 Introduction

Tool-augmented LLM agents operate over registries of thousands of APIs under tight context constraints (Qin et al., 2024b; Patil et al., 2024). The dominant approach directly embeds the user query and retrieves the top-k most similar APIs before passing them to the planner (Patil et al., 2024; Qin et al., 2024b; Yuan et al., 2024), assuming the semantic gap between user intent and API documentation is small enough to bridge by embedding alone. Recent work shows this assumption often fails (Shi et al., 2025; Huang et al., 2024), motivating an alternative direction where the LLM generates query reformulations or plans before retrieval to better express functional intent (Fang and Glass, 2026). However, such works propose training-dependent systems aimed at improving retrieval quality, rather than characterizing when and why each approach is preferable. The underlying paradigm comparison remains unexplored.

Prior work has studied retrieval-side improvements: Tool Retrieval Bridge (Chen et al., 2026) rewrites queries into retriever-friendly forms; Re-Invoke (Chen et al., 2024) enriches tool descriptions with synthetic queries; TaskBench (Shen et al., 2024) benchmarks the decompose-then-select pipeline; and Tool-MVR (Ma et al., 2025) treats stub hallucination as a bug to fix (we show it is a feature on complex queries). ToolFlood (Jawad and Brunel, 2026) and a recent survey (Qin et al., 2024a) provide broader context on retrieval robustness and tool learning. A related line of work uses LLM-guided tool selection, where the model draws on parametric knowledge rather than vector retrieval: HuggingGPT (Shen et al., 2023) has ChatGPT select specialized models from HuggingFace; AnyTool (Du et al., 2024) uses GPT-4 to hierarchically narrow API categories;

Comparison: Tool calling workflows

Figure

Figure 1 Comparison of the two discovery architectures. Left (RtP): the user query is embedded directly and matched against the tool registry via vector search; the top-k results are passed to the LLM planner. Right (PtR): the LLM first generates a draft plan with imaginary tool stubs, whose embeddings are used to query the registry; the matched real tools are returned to the planner for final execution planning.

and LATM (Cai et al., 2024) has LLMs create tools from scratch.

The closest prior work to the paradigm we study is TOOLQP (Fang and Glass, 2026), which generates multi-round query reformulations to improve API retrieval, trained with reinforcement learning. Our approach differs in three ways: stubs are generated in a single zero-shot prompt call with no training, we generate hypothetical function signatures rather than query reformulations, and we study PtR as a controlled paradigm rather than proposing a new system. Despite this active area, no prior work has directly compared these two retrieval paradigms in a controlled setting at large registry scale, characterized how the trade-off changes with query complexity, or analyzed how retrieval differences cascade into planner behavior.

We term the dominant paradigm Retrieve-then-Plan (RtP) and the alternative Plan-then-Retrieve (PtR), and present the first systematic apples-to-apples comparison at industrial scale (50k APIs). A key analytical lens we introduce is Intent-Registry Coupling: the semantic gap between how users describe tasks and how APIs are documented. Our PtR instantiation generates Abstract Tool Stubs (hypothesized function signatures) as retrieval queries in a single zero-shot prompt call with no training. Our contributions: (1) a complexity-dependent crossover (RtP wins on simple queries, PtR wins on multi-tool queries) robust to retrieval budget, registry size, and model family; (2) a characterization of stub hallucination as a dual mechanism: it degrades retrieval when queries have high Intent-Registry Coupling, and improves it when they do not; (3) an analysis of token overhead showing that directing single-tool queries to RtP and multi-tool queries to PtR reduces discovery-call overhead by ∼36%\sim36\% with no retrieval quality loss, motivating complexity-adaptive routing as a practical direction consistent with prior work on complexity-aware retrieval (Jeong et al., 2024).