LIBRA: Programmatic Induction of Executable Tool Libraries

Zekai Li, Zhenke Liu, Yonghao Li, Junhan Liu, Xulong Xiao, Jiapeng Zhang

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.
Overview of LIBRA's two-stage process: building the library through runtime verification and then using that library for graph-based retrieval.

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.
t-SNE projection showing how LIBRA recovers prerequisite tools (orange) that are semantically distant from the goal tools (blue) and the user query.
  • 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.
Figure 2: Agentic retrieval after 10 iterations. Each panel reports Recall and NDCG for one agent LLM and benchmark. Points show the mean over three random seeds, and error bars show standard error. LIBRA attains the highest Recall in 8 of the 9 settings and the highest NDCG on SciToolEval and BFCL for all three agent LLMs.

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

Abstract

Large language model agents increasingly retrieve tools from large catalogs, yet most retrievers rank each tool independently by request similarity. For multi tool tasks, this recovers the goal matching tool while omitting prerequisite tools required by the workflow.We introduce LIBRA, a framework for Library Induction by Runtime Assembly that turns a flat tool catalog into an executable tool library. An LLM proposes per tool contracts of candidate invocations, reusable outputs and state changes, and success conditions; LIBRA then tests these compositions in a sandbox and retains the relations supported at runtime. Constructed before user queries, the library requires no dependency annotations, tool use trajectories, or task specific training, and supports both one-shot and agentic retrieval. On AppWorld, BFCL, and SciToolEval, LIBRA improves one-shot Recall and NDCG over the same dense retriever by 7.9 and 3.7 percentage points on average. Within ToolReAGt, it yields corresponding gains of 4.5 and 2.9 points after ten retrieval iterations.
BibTeX
@misc{li2026libra,
  author = {Zekai Li and Zhenke Liu and Yonghao Li and Junhan Liu and Xulong Xiao and Jiapeng Zhang},
  title = {{LIBRA: Programmatic Induction of Executable Tool Libraries}},
  year = {2026},
  eprint = {2611.05445},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.05445},
}
Figure