Dynamic Tool Dependency Retrieval for Lightweight Function Calling
Problem Statement
On-device and resource-constrained LLM agents rely on retrieval modules to select a small relevant subset of tools, which improves accuracy and keeps context length manageable. Existing retrievers are static—conditioning only on the initial query—so they fail to capture how tool needs change as a multi-step plan unfolds, causing irrelevant tools to be injected into context, which confuses the agent and degrades both efficiency and downstream task accuracy.
Key Novelty
- Dynamic retrieval conditioning that updates tool selection based on the evolving tool-calling plan rather than just the initial query
- Explicit modeling of multi-step tool dependencies learned from function-calling demonstration data
- A lightweight design intended for on-device/resource-constrained agentic deployment
- Systematic exploration of strategies for integrating retrieved tools into LLM prompts
Evaluation Highlights
- 23%–104% improvement in function calling success rate compared to state-of-the-art static retrieval baselines
- Benchmarked across multiple datasets and LLM backbones on retrieval precision, downstream task accuracy, and computational efficiency
Signal Assessment
Methodology
- Learn tool dependency patterns (e.g., co-occurrence and ordering) from function-calling demonstration trajectories
- At each step, retrieve candidate tools conditioned jointly on the original user query and the current partial tool-calling plan
- Adaptively update the retrieved tool set as the plan evolves across multiple reasoning/action steps
- Apply prompt integration strategies to insert retrieved tools efficiently into the LLM context
- Evaluate against static retrieval baselines on retrieval precision, task success rate, and computational cost across datasets and LLM backbones
System Components
Learns relationships between tools (e.g., which tools tend to follow or co-occur with others) from historical function-calling demonstrations
Selects relevant tools by conditioning on both the initial query and the current state of the evolving multi-step plan
Determines how retrieved tools/definitions are formatted and inserted into the LLM's prompt context
Benchmarks retrieval precision, end-to-end function-calling accuracy, and computational efficiency across datasets and LLM backbones
Results
| Metric/Benchmark | Baseline (Static SOTA Retriever) | This Paper (DTDR) | Delta |
|---|---|---|---|
| Function calling success rate | Static retrieval performance | Dynamic, plan-conditioned retrieval | +23% to +104% |
| Retrieval precision | Lower due to query-only conditioning | Higher due to dependency-aware, evolving conditioning | Qualitative improvement reported |
| Computational efficiency | Reference cost of static retrievers | Comparable/lightweight overhead | Maintains lightweight profile suitable for on-device use |
Key Takeaways
- Static, query-only tool retrieval is a bottleneck for multi-step agentic tasks; retrieval should adapt as the tool-calling plan develops
- Modeling tool dependencies from demonstration data is a practical, lightweight way to reduce irrelevant tool injection without heavy added compute
- How retrieved tools are integrated into prompts matters and should be tuned alongside the retrieval method itself
- DTDR is particularly relevant for on-device/edge agent deployments where context length and compute budgets are tightly constrained
Abstract
Function calling agents powered by Large Language Models (LLMs) select external tools to automate complex tasks. On-device agents typically use a retrieval module to select relevant tools, improving performance and reducing context length. However, existing retrieval methods rely on static and limited inputs, failing to capture multi-step tool dependencies and evolving task context. This limitation often introduces irrelevant tools that mislead the agent, degrading efficiency and accuracy. We propose Dynamic Tool Dependency Retrieval (DTDR), a lightweight retrieval method that conditions on both the initial query and the evolving tool calling plan. DTDR models tool dependencies from function calling demonstrations, enabling adaptive retrieval as plans unfold. We benchmark DTDR against state-of-the-art retrieval methods across multiple datasets and LLM backbones, evaluating retrieval precision, downstream task accuracy, and computational efficiency. Additionally, we explore strategies to integrate retrieved tools into prompts. Our results show that DTDR improves function calling success rates between $23\%$ and $104\%$ compared to state-of-the-art static retrievers.