← Back
Towards Data Science

Speculative Decoding Makes Tool Calls Faster. Agents Need a Cache.

•
#agents#inference
Level:Advanced
For:AI Engineers
✦TL;DR

Benchmarks using Qwen3 and Llama on llama.cpp demonstrate that speculative decoding can accelerate code generation, JSON output, and tool‑call latency by up to 1.7×, but when agents run without a cache their loops become about 6% slower. The results highlight that speculative decoding alone isn’t enough for agents; a caching layer is required to reap performance gains. Engineers building AI agents should therefore pair speculative decoding with a cache to avoid the slowdown in iterative agent loops.

⚡ Key Takeaways

  • Draft model speculative decoding achieved up to 1.7× speed‑up for code, JSON, and tool calls.
  • The experiments were run on Qwen3 and Llama models using the llama.cpp runtime.
  • Uncached agent loops experienced a 6% slowdown despite the speculative decoding boost.
  • A cache is needed to preserve the speed benefits when agents perform repeated tool calls.

🔧 Tools & Libraries

llama.cpp
💡 Why It Matters

Adding a cache to speculative decoding pipelines lets production agents maintain higher throughput and lower latency, directly impacting real‑time AI services that rely on frequent tool invocations.

✅ Practical Steps

  1. Apply the concepts from this article to your own system design.

Want the full story? Read the original article.

Read on Towards Data Science ↗

More like this

Building a Multi-Agent Verification Loop in Python with Small Open Models

Machine Learning Mastery•#agents

Taking Trainium3 to the Track: Generating Videos with LTX-2.5

Hugging Face Blog•#compute

Agentic system personalizes physical controls to help users “DJ their art”

MIT News AI•#agents

Lazy gas, hot gas, and a thousand robots

Amazon Science•#agents

EXPLORE AI NEWS

Daily hand-picked stories on LLMs, RAG, agents and production AI — curated for engineers who ship.

BROWSE NEWS

GET THE WEEKLY DIGEST

Join engineers getting the Monday signal-over-noise AI breakdown. No spam, unsubscribe anytime.

LEARN AI ENGINEERING

Curated courses, research papers, repos and tutorials built for engineers leveling up in AI.

START LEARNING