AppleBenchmark
Plan or Retrieve First? A Scale Study of Tool Discovery Architectures
Summary
Tool-augmented LLM agents must discover relevant APIs from large registries before planning, but finite context windows prevent injecting all tool definitions into a single prompt. Two competing architectures are Retrieve-then-Plan (RtP), which embeds the query and retrieves similar tools via nearest-neighbor search, and Plan-then-Retrieve (PtR), which first generates abstract tool stubs as retrieval queries. Evaluating on ToolBench with 46,984 API endpoints across 50 categories reveals a clear complexity-dependent crossover: RtP outperforms PtR on single-tool queries while PtR outperforms RtP on multi-tool queries. PtR’s stub-hallucination failure mode acts as a double-edged sword—on simple queries it abstracts away proper-noun signals, yet on complex queries it decomposes multi-faceted intent into functional sub-needs. PtR roughly doubles inference cost, which pays off on multi-tool queries but hurts on single-tool ones, motivating complexity-adaptive routing driven by RtP’s top-1 retrieval score.
Approach / What changed
Plan-then-Retrieve (PtR): the LLM first generates Abstract Tool Stubs (hypothesized function signatures describing needed capabilities) which then serve as retrieval queries against the registry.
Takeaways
A complexity-dependent crossover exists: RtP outperforms PtR on single-tool queries, while PtR outperforms RtP on multi-tool queries, consistent across retrieval budgets, registry sizes, and model families.
PtR’s stub-hallucination (inventing plausible but non-existent API names) is a double-edged sword: it abstracts away proper-noun signals on simple queries but decomposes multi-faceted intent on complex queries.
PtR’s extra discovery call roughly doubles inference cost, beneficial for multi-tool queries but wasteful for single-tool ones, motivating complexity-adaptive routing using RtP’s top-1 retrieval score as a zero-cost signal.
FAQ
When does PtR outperform RtP?
PtR outperforms RtP on multi-tool queries (both intra-category and cross-category) because its abstract tool stubs decompose multi-faceted intent into functional sub-needs that retrieve more relevant APIs.
What is stub-hallucination in PtR?
Stub-hallucination is when the LLM invents plausible but non-existent API names during stub generation. It acts as a double-edged sword: harmful on simple queries by abstracting away proper-noun signals, but helpful on complex queries by breaking down intent.
How does PtR's inference cost compare to RtP?
PtR's extra discovery call roughly doubles inference cost compared to RtP. This trade-off pays off on multi-tool queries but is wasteful on single-tool queries, motivating a complexity-adaptive routing approach.
Source and freshness
- Source
- machinelearning.apple.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.