The engineering behind inference.Contact ↗
Batch & Release/Inference

Apple Study Compares Tool Discovery Orders Across 47k API Registry

Apple researchers compared Retrieve-then-Plan and Plan-then-Retrieve tool discovery on ToolBench, finding a complexity-dependent crossover: single-tool queries favor retrieval first, multi-tool queries favor planning first.

Apple Study Compares Tool Discovery Orders Across 47k API Registry
Illustration generated with AI for this article.

Apple researchers presented a scale study of tool discovery architectures for LLM agents at EMNLP, comparing two orders of operation against a registry of 46,984 unique API endpoints across 50 categories. The paper, authored by Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, and Michael Xu, evaluates Retrieve-then-Plan (RtP) and Plan-then-Retrieve (PtR) on the ToolBench benchmark using Gemini 2.5 Flash and gpt-oss-120b.

The Two Architectures

Tool-augmented agents must discover relevant APIs from large registries before planning execution, but finite context windows prevent injecting all tool definitions into a single prompt. The dominant approach, RtP, embeds the user query and retrieves similar tools via approximate nearest-neighbor search. The alternative, PtR, has the LLM first generate Abstract Tool Stubs, hypothesized function signatures describing needed capabilities, which then serve as retrieval queries against the registry.

The study evaluates three query subsets: single-tool queries (G1), intra-category multi-tool queries (G2), and cross-category multi-tool queries (G3). The central finding is a 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 from k=1 to 20, remains robust across registry sizes from 1k to 47k APIs, and is consistent across both model families tested.

Stub Hallucination as a Double-Edged Sword

The paper characterizes a stub-hallucination failure mode in which the LLM invents plausible but non-existent API names. On simple queries, PtR's stubs abstract away proper-noun signals that RtP matches directly, which explains why retrieval-first wins in the single-tool case. On complex queries, the same mechanism decomposes multi-faceted intent into functional sub-needs, which is why planning-first wins when multiple tools are required.

Cost and Routing Implications

The analysis of token overhead shows that PtR's extra discovery call roughly doubles inference cost. That added expense pays off on multi-tool queries but hurts on single-tool ones. The authors suggest complexity-adaptive routing as a practical direction, driven by a zero-cost signal already present in the pipeline: RtP's top-1 retrieval score. Since RtP runs first in any routing scheme, its top-1 score can indicate query complexity without additional inference cost, letting a system decide whether to proceed with RtP results or trigger the more expensive PtR path.

For inference engineers serving tool-augmented agents, the practical takeaway is that the choice between retrieval-first and planning-first discovery depends on expected query complexity. Systems handling mostly single-tool requests can stay with RtP and avoid the doubled inference cost. Systems facing frequent multi-tool or cross-category requests may justify the extra PtR call. The proposed routing signal, derived from RtP's top-1 retrieval score, offers a way to make that decision dynamically without adding latency or cost to the pipeline.

Sources & references

Apple: Plan or Retrieve First? A Scale Study of Tool Discovery Architectures ↗Source consulted: 2026-10-16

Privacy choices

We remember your answer in this browser for 180 days. Come back here whenever you want to change it.

EssentialSaves your answer in this browser. No cookies, no third parties.Always active