Relevance Is Not Necessity: Selecting the Necessary API Set for Tool-Using LLMs

Chen WangNeurIPS 2026

TL;DR

When AI agents use external tools, standard pipelines shortlist APIs by how textually relevant they look one by one, even though downstream tasks require an exact, harmonious set of tools working together. This paper proves why scoring tools individually hits a mathematical ceiling when APIs depend on one another, and introduces TC-MASS—a tiny, blazingly fast offline refiner that fixes an LLM’s tool choices by evaluating whole combinations at once, boosting accuracy without a single extra LLM call.

What Problem Does This Paper Address?

Imagine asking an AI agent to plan a trip. Facing a library of thousands of APIs, a standard system uses a retriever to grab a shortlist of textually similar tools, then hands them to an LLM to build a plan.

Suppose the task requires {flight_search, hotel_book}, and the agent instead calls {flight_search, hotel_search}. Here, the retriever did its job—hotel_search is undeniably relevant to the prompt. Yet the plan fails because hotel_book was necessary (meaning, part of the exact required set defined by the benchmark's verifier).

The author calls this the relevance–necessity gap, driven by three headaches:

  1. Confusable siblings: Related APIs (hotel_search vs. hotel_book) look equally relevant in isolation, even when only one is needed.
  2. Wrong tool counts (cardinality): Standard top-$k$ retrieval doesn't adapt to how many tools a specific task actually demands.
  3. Blindness to combinations: Scoring APIs individually ignores how tools complement or duplicate one another.
Figure 1: Relevance is not necessity. Left: per-task GPT-4o upstream plan size versus gold necessary- set size on ToolBench G2/G3; off-diagonal points indicate wrong cardinality. Right: TC-MASS recovers exact matches from the same frozen trace while preserving most upstream-correct tasks.

Methods

Instead of re-prompting a massive LLM or rebuilding the retriever, the author proposes TC-MASS (Task-Conditioned Minimal API-Set Selection). Taking an already-generated ("frozen") LLM plan and the retrieved shortlist, TC-MASS edits the tool selection offline in four lightweight steps:

  1. Candidate Pool with Search Hints: Combines the retrieved APIs and the LLM's initial choices, enriching each with a compact text "hint" built from its family name, identifiers, and description.
  2. Necessity Scoring: A logistic regression model scores each API across 17 features—going beyond text similarity to include family redundancy, structural penalties, and whether the upstream LLM picked it.
  3. Cardinality Prediction: Estimates the target number of tools ($\hat{k}$) the task actually needs.
  4. Set-Level Exact Reranker: What is truly novel here is shifting the statistical target. TC-MASS generates a menu of ~61 candidate sets around size $\hat{k}$ and uses a fast tree-based model (Histogram-based Gradient Boosting, or HGBT; plus a heavier Set-Transformer variant) trained directly on a binary question: does this entire combination exactly match the required gold set?
Figure 2: TC-MASS framework. A frozen upstream trace and retrieved candidate pool are converted into augmented API features, necessity scores, and a predicted target cardinality. TC-MASS then enumerates candidate API sets and selects the set with the highest set-exact reranker score.

Datasets

  • HSR-Bench (Primary): A leakage-controlled slice of ToolBench (spanning multi-tool groups G2 and G3) featuring 300 tasks across 1,129 unique APIs, where test-set tool combinations are strictly unseen during training.
  • Out-of-Distribution Probes: Tested zero-shot on BFCL (Berkeley Function Calling Leaderboard: parallel_multiple, multiple, and live_multiple splits) and APIBank-real to diagnose how the model behaves when task structures shift.

Key Insights and Ideas

  • Individual tool scores hit a mathematical wall: The paper proves formally (Proposition 1) that when APIs are correlated—like mutually exclusive siblings or complementary pairs—any selector looking only at individual API probabilities can fail, even with a perfect tool-count predictor. In experiments, four distinct per-API selection algorithms (including submodular greedy and integer linear programming) all slammed into the exact same accuracy ceiling (47.7%).
  • Prompting harder doesn't fix set selection: Asking GPT-4o to use Chain-of-Thought or "draft-and-self-verify" barely budged exact-match accuracy (+0.7% to +1.3%). The frozen initial trace already contains enough clues to fix mistakes—you just have to ask a learner a set-level question.
  • Predictable failure modes: Theory (Proposition 2) predicts set-level training helps on correlated multi-tool tasks, while simple per-API rules suffice for independent single-tool tasks. When tested zero-shot on single-tool benchmarks, TC-MASS predictably over-selected tools because its multi-tool count prior mismatched the new environment—a quirk easily fixed by locking the tool count to the upstream LLM's original size.

Key Results

  • Big gains at near-zero cost: On HSR-Bench, default TC-MASS (HGBT) lifts GPT-4o’s exact-match accuracy from 51.7% to 60.7% (+9.0 percentage points; Set-Transformer hits 62.0%). Training takes 3.6 CPU-seconds per fold, inference takes 19 milliseconds per task, and it uses zero extra LLM calls.
  • Do no harm: Out of 300 tasks, TC-MASS repaired 28 broken GPT-4o plans while accidentally breaking only 1 previously correct plan.
  • Cross-planner transfer: Applied to traces from an open-weight planner (Qwen-2.5-VL-32B), TC-MASS boosted exact match from 41.0% to 52.0%.
  • Judge-verified quality: On the 73 tasks where TC-MASS altered the API set, a majority vote of three independent LLM judges preferred TC-MASS's choices 91.8% of the time vs. 74.0% for raw GPT-4o.

Limitations and Future Work

  • Benchmark label noise: "Necessity" here means matching the benchmark's gold label. A human audit of 100 tasks revealed that 47% of gold sets contained an API that wasn't strictly indispensable, and 64% of TC-MASS's remaining "errors" were actually plausible alternative toolsets.
  • Set equality isn't execution: Matching a set of API names ignores call ordering, parameter binding, and runtime errors.
  • Bounded by retrieval: TC-MASS cannot invent APIs missing from its candidate menu (which capped maximum possible accuracy at 94.0%). When pools were rebuilt from scratch across all 1,129 APIs using standard retrievers, gains remained positive but shrank to +1–3%.
  • Future scope: Extending necessity-aware set selection to dynamic API libraries and multi-turn agent interactions remains open territory.

Summary updated

BibTeX
@inproceedings{wang2026relevance,
  author = {Chen Wang},
  title = {{Relevance Is Not Necessity: Selecting the Necessary API Set for Tool-Using LLMs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=pTmL4oUWre},
}
Figure