TL;DR
LIBRA is a framework that automatically transforms a flat list of tools into a structured, executable library by "stress-testing" tool compositions in a sandbox environment. By identifying functional dependencies that semantic search misses—like needing to log in before you can send a message—LIBRA significantly improves the ability of LLM agents to retrieve the full set of prerequisite tools needed to complete complex tasks.
What Problem Does This Paper Address?
When we ask an LLM agent to "send a message to Alice," we rarely mention the necessary prerequisites: the agent first needs to authenticate (login) and then find Alice's ID (search_contacts). Standard tool retrievers rely on semantic similarity, ranking tools based on how well their descriptions match the user's query.
This creates a "semantic gap." While send_message is a great match for the query, login is semantically distant. Consequently, retrievers often omit the "boring" but essential upstream tools required for a valid workflow. Existing solutions to this problem usually require manual annotations, extensive training data, or historical usage logs—none of which are available when deploying a brand-new set of tools.
Methods
The authors introduce LIBRA (Library Induction by Runtime Assembly), which operates in two distinct stages:
1. Ahead-of-Time Library Construction
Before any user queries arrive, LIBRA builds a dependency graph by actually running the tools.
- Contract Generation: An LLM examines tool metadata to propose "contracts"—candidate ways to call the tool, what outputs it produces, and what a "success" looks like.
- Counterfactual Sandbox Testing: This is the core innovation. LIBRA doesn't just check if two tools can work together; it uses counterfactual tests to prove a dependency exists. It checks if Tool B succeeds when given Tool A’s output, but fails when that output is replaced by a random value or omitted. This filters out "plausible-looking" relations that don't actually function at runtime.
2. Retrieval with Graph Propagation
At query time, LIBRA uses a standard dense retriever to find "seed" tools that match the user's request. It then follows the edges in its induced dependency graph to pull in the necessary prerequisites. To avoid flooding the agent with irrelevant tools, it uses a pruning strategy that only retains the most likely providers for each required input.
Datasets
The researchers evaluated LIBRA across three benchmarks with varying characteristics:
- AppWorld: A complex environment simulating everyday app workflows (e.g., Spotify, Venmo). Tasks here are long, requiring an average of over 8 tools.
- BFCL (Berkeley Function Calling Leaderboard): Focuses on function calling for filesystem and utility APIs.
- SciToolEval: A benchmark for scientific computing pipelines.
Key Insights and Ideas
- Execution is the Ground Truth: Metadata (like parameter names and types) can be misleading. By requiring runtime validation, LIBRA ensures that the induced dependencies are functionally sound, not just semantically plausible.
- Bridging the Semantic Gap: Prerequisite tools often live in entirely different clusters in embedding space compared to the goal tools. Figure 3 illustrates how LIBRA's graph allows the retriever to "jump" between these clusters to find hidden dependencies.
- Trajectory-Free Learning: Unlike prior work, LIBRA doesn't need to see how humans have used the tools in the past. It "discovers" how tools compose simply by trying them out in a sandbox.
Key Results
LIBRA consistently outperformed both standard retrievers and other structure-aware baselines:
- One-Shot Retrieval: On average, LIBRA improved Recall and NDCG (a measure of ranking quality) by 7.9 and 3.7 percentage points, respectively, over a strong dense retriever. The gains were most dramatic on AppWorld, where Recall jumped by 12 points.
- Agentic Retrieval: When integrated into an iterative agent (ToolReAGt), LIBRA provided sustained benefits across multiple rounds of reasoning, achieving the highest Recall in 8 out of 9 experimental settings.
Limitations and Future Work
- Sandbox Requirement: LIBRA requires an environment where tools can be executed safely and reset to a clean state. This is difficult for "live" APIs with side effects in the real world.
- Upfront Cost: Building the library involves many LLM calls and executions. While this cost is amortized over thousands of future queries, it represents a significant initial investment.
- Coverage vs. Precision: The counterfactual test is great for precision (avoiding wrong edges), but it can't find a dependency if the LLM fails to propose a working contract in the first place. Future work might involve more sophisticated "fuzzing" to discover these elusive connections.
Summary updated