Optimizing Agentic Language Model Inference via Speculative Tool Calls

Daniel Nichols, Prajwal Singhania, Charles F. Jekel, Abhinav Bhatele, Harshitha MenonarXiv 2025 · OpenReview

Abstract

Language models (LMs) are becoming increasingly dependent on external tools to interact with their environment, search files, or run code. While these tools enhance capabilities, they introduce significant performance bottlenecks due to sequential dependencies and system overheads like KV-cache eviction. This paper introduces novel systems optimizations—Speculative Tool Calling—that use small "draft" models to predict and pre-execute tool calls. By forcing sequences to remain resident in the inference engine and masking tool latency, these optimizations achieve throughput improvements of up to 196 tokens per second and reduce end-to-end latency by up to 21%.

Introduction: The "Stop-and-Wait" Bottleneck

Modern AI agents operate in an "interrupt-driven" manner. When a model decides to call a tool, the inference engine typically stops, returns control to the user, and often evicts the model's current state (KV-cache) to free up GPU resources for other requests. Once the tool result is returned, the engine must "re-prefill" the entire conversation history to resume generation. This creates two primary bottlenecks: the sequential dependency (waiting for the tool to finish) and system overheads (cache management and redundant computation).

Speculative Tool Calling Strategies

To address these inefficiencies, the researchers propose two complementary strategies designed to mask delays and optimize resource utilization:

  1. Client-side Speculative Tool Calling: This approach operates without requiring changes to the underlying inference engine. A prompt is sent simultaneously to the main model ($M$) and a much smaller, faster speculative model ($S$). If $S$ predicts a tool call, the client executes it immediately in the background. If $M$ eventually makes the same call, the result is already cached and ready for use.
  2. Engine-side Speculative Tool Calling: This deeper optimization, implemented in a fork of vLLM, introduces a "tool cache" API. Instead of evicting a sequence during a tool call, the engine keeps it resident. If a speculated tool result is available before the main model finishes its reasoning phase, the engine can inject the output directly into the KV-cache, bypassing the expensive re-prefill phase.
Comparison of baseline inference vs. engine-side speculative tool calling, highlighting KV-cache residency and the elimination of overheads.

Experimental Setup and Methodology

The study utilized the Berkeley Function Calling Leaderboard (BFCL) to evaluate tool-calling accuracy and performance. The primary agent was powered by gpt-oss-120b, while the xLAM family (1B to 8B) served as speculative models. These smaller models proved remarkably effective, with even 1B versions achieving high accuracy in predicting tool calls. The researchers also validated the approach using commercial models like gpt-5 paired with gpt-5-nano as a speculator to assess real-world cost-benefit trade-offs.

Key Results and Performance Gains

The optimizations yielded substantial improvements across multiple metrics. In a multi-tenant environment hosting 32 concurrent agents, the speculative approach maintained high performance even as tool latency increased.

  • Throughput: The system achieved a gain of up to 196.4 tokens/second compared to vanilla inference.
  • Latency: Client-side speculation alone reduced end-to-end time by 6% to 21%. Engine-side optimizations added a further 2-3% saving by eliminating eviction overheads.
  • Cost-Efficiency: For a marginal 4% increase in API costs (to run the speculator), users realized a 10% reduction in total latency.
Throughput comparison between the proposed speculative approach and vanilla inference as average tool latency increases.

Discussion and Future Directions

Speculation is most effective in the "sweet spot" where tool execution time is roughly equivalent to the model's generation time. It is particularly beneficial for modern reasoning models that generate long chains of thought; the tool can run while the model is still "thinking," ensuring the result is ready the moment the reasoning phase concludes.

However, several challenges remain. The current technique is limited to stateless tools (e.g., web searches) because speculating on stateful actions (e.g., deleting a record) carries the risk of irreversible side effects. Future work will explore sandboxing or rollback mechanisms to allow speculation on stateful tools. Additionally, for expensive tools, a cost-aware scheduler will be necessary to determine when the potential speedup justifies the financial risk of an incorrect speculation.

Summary updated

BibTeX
@misc{nichols2025optimizing,
  author = {Daniel Nichols and Prajwal Singhania and Charles F. Jekel and Abhinav Bhatele and Harshitha Menon},
  title = {{Optimizing Agentic Language Model Inference via Speculative Tool Calls}},
  year = {2025},
  eprint = {2512.15834},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.15834},
}
Figure