Developers building AI agents are hitting a paradoxical wall where adding more capabilities actually makes the agent less capable. As the tool catalog grows from a handful of functions to dozens or hundreds, the Large Language Model (LLM) begins to struggle with noise. The context window becomes cluttered with tool definitions, leading to a phenomenon where the model either selects the wrong tool due to similar descriptions or, more critically, forgets to call the prerequisite tools necessary to gather the input for a final action. This friction has turned tool-calling from a simple API exercise into a complex retrieval problem.

The Architecture of Selective Tool Retrieval

Plateer Labs has introduced graph-tool-call, a Python open-source library designed to decouple the tool catalog from the LLM's immediate context. Instead of feeding every available tool schema into the prompt, graph-tool-call manages the catalog externally and delivers only the minimum required schemas for each specific request. This approach treats tool selection as a graph traversal problem rather than a simple list-matching exercise.

Technically, the library constructs a relationship graph by aggregating tools from various sources, including OpenAI REST API standard specifications, the Model Context Protocol (MCP), and native Python functions. To identify the correct tools, the system employs a hybrid search strategy. It uses BM25, a ranking function based on word frequency, alongside vector embeddings to find the target tool that matches the user's intent. Once the target tool is identified, the library does not stop there; it traverses the relationship graph to identify and include all prerequisite tools required to generate the necessary input values for that target tool.

Integration is handled through a flexible gateway system. Depending on the environment, developers can utilize MCP server proxies, OpenAI or Swagger catalogs, or integrate directly with LangChain and LangGraph workflows. This allows the library to sit as a filtering layer immediately before a request is sent to providers like OpenAI or Anthropic, ensuring the model only sees a curated subset of the total toolset.

From Semantic Similarity to Execution Logic

The fundamental shift here is the move from semantic search to relational reasoning. Most current agentic frameworks rely on embedding-based retrieval, which finds tools that sound similar to the user's request. However, semantic similarity is often a trap in complex workflows. For example, if a user wants to refund an order, an embedding search will easily find a tool named refundOrder. But refundOrder cannot function without an order ID, which must first be retrieved via a tool like findOrdersByEmail. A standard embedding search often misses findOrdersByEmail because the user never mentioned searching for an email; they only mentioned a refund.

This gap is where graph-tool-call provides a measurable leap in reliability. In regression tests conducted on seven commerce-related use cases using version v0.36.0, the inclusion rate for essential prerequisite tools jumped from 14.3% to 100%. When the system relied solely on searching for the target tool, it failed to identify the necessary dependency chain nearly 86% of the time. By implementing the graph-based expansion, every single required prerequisite was successfully identified.

This precision directly impacts the efficiency of the LLM's context window. In the same tests, the ratio of executable candidate configurations rose from 47.6% to 100%. More importantly, the volume of data sent to the model plummeted. The expected schema size dropped from 1,476 tokens to just 160 tokens. By removing the noise of irrelevant tools, the model is less likely to hallucinate parameters or confuse two tools with similar naming conventions, while simultaneously reducing token costs and latency.

For developers looking to verify these dependency chains in their own environments, the library provides a dedicated demo command:

bash
uvx --from graph-tool-call==0.36.0 graph-tool-call demo dependency-chain

The transition from massive, static tool lists to dynamic, graph-based retrieval marks a necessary evolution for production-grade AI agents.