cs.CLApr 15, 2026

ToolSpec: Accelerating Tool Calling via Schema-Aware and Retrieval-Augmented Speculative Decoding

Authors: Heming Xia, Yongqi Li, Cunxiao Du, Mingbo Song, Wenjie Li

Organizations: Department of Computing, The Hong Kong Polytechnic University · Peking University

Abstract

Tool calling has greatly expanded the practical utility of large language models (LLMs) by enabling them to interact with external applications. As LLM capabilities advance, effective tool use increasingly involves multi-step, multi-turn interactions to solve complex tasks. However, the resulting growth in tool interactions incurs substantial latency, posing a key challenge for real-time LLM serving. Through empirical analysis, we find that tool-calling traces are highly structured, conform to constrained schemas, and often exhibit recurring invocation patterns. Motivated by this, we propose ToolSpec, a schema-aware, retrieval-augmented speculative decoding method for accelerating tool calling. ToolSpec exploits predefined tool schemas to generate accurate drafts, using a finite-state machine to alternate between deterministic schema token filling and speculative generation for variable fields. In addition, ToolSpec retrieves similar historical tool invocations and reuses them as drafts to further improve efficiency. ToolSpec presents a plug-and-play solution that can be seamlessly integrated into existing LLM workflows. Experiments across multiple benchmarks demonstrate that ToolSpec achieves up to a 4.2x speedup, substantially outperforming existing training-free speculative decoding methods.

Figures & tables

Appendix figures & tables7 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. SchemaFill: Efficient LLM Tool Calling via Slot-Parallel Speculative Decoding

    Oct 5, 2026Zhi-Kai Chen, Song-Yan Li, De-Chuan Zhan +1Speculative DecodingLLM Inference Acceleration

  2. OoO-Spec: Out-of-Order Semantic Speculation for Fast Tool Calling

    Aug 1, 2026Zhiheng Zhang, Mujie Xu, Feiyu Sun +1Speculative DecodingLLM Inference Acceleration

  3. Try, Check and Retry: A Divide-and-Conquer Framework for Boosting Long-context Tool-Calling Performance of LLMs

    Mar 12, 2026Kunfeng Chen, Qihuang Zhong, Juhua Liu +2LLM Tool Use