Manuscript Offprint

arXiv:2610.31840

SPECMEM: Accelerating Agentic Tool Calling via Live Memory Management

Zihe Song, Wenting Zhao, Ye Liu, Yuanjie Zhu, Ke Xu, Shanghao Li, Philip S. Yu

Abstract

Tool-calling agents are mostly optimized for accuracy; in deployment, however, their growing cost is latency: every tool call is decoded autoregressively. Speculative decoding accelerates this without changing the output, and retrieved past calls make strong drafts under real use, where each user's behavior tends to repeat. Yet existing systems keep no cross-session memory, or build the draft store once and never update it. We propose SPECMEM, a tool-call memory kept alive and managed throughout deployment: verified calls are written back online into bounded per-user stores with LRU eviction, and a side-effect gate defers irreversible calls until verification confirms. On multi-session, multi-user query streams served by three open-weight models, a frozen store steadily loses acceptance while SPECMEM holds it: a 27% gap in mean accepted tokens (+11% to +34% across benchmarks, tracking how much novel work arrives after the store is built) and up to 1.74× wall-clock speedup. Ablations attribute the gain almost entirely to keeping the store live; local per-user scoping adds no acceptance but closes a measured cross-user leakage channel, and gating on declared side effects, rather than on retrieval confidence, is what eliminates irreversible mistakes.

1 Introduction

LLM agents increasingly act through tool calls: querying APIs, searching, and operating software on a user's behalf (Qin et al., 2023; Yan et al., 2024). Most work on such agents targets accuracy: choosing the right tool with the right arguments (Li et al., 2023; Tang et al., 2023). In deployment, however, the cost that grows is latency: every call is decoded autoregressively, and an agent that pauses between steps is impractical for interactive use, however accurate it is. This paper is about making tool-calling agents faster without affecting what they output.

A growing line of work targets exactly this efficiency. Speculative decoding lets a cheap draft be verified by the target model, so the output is unchanged and the speedup rests on how often the draft is right (Leviathan et al., 2023; Chen et al., 2023). Moving from general decoding to agentic flows, speculation has been applied to the next tool call, its arguments, or the following observation (Sui et al., 2026; Saberi et al., 2026; Hooper et al., 2026; Chung et al., 2026), and to repeated output patterns cached across requests (Oliaro et al., 2025). Tool calls are highly templated, so among draft sources, a similar past call retrieved from memory is especially likely to be right.

The scenario that matters in practice is tool calling under real use: an agent serves many users over a long horizon, and each user's behavior tends to repeat, asking for the weather, checking the same stock, or re-running yesterday's query with today's date. Whether this recurrence can make agentic tool calling faster is the problem we focus on. The closest work is TOOLSPEC (Xia et al., 2026), which retrieves similar past calls from a datastore as drafts and reports large speedups. Its store, however, is built once and then frozen (never updating, never evicting, and shared globally across users), so the recurrence a returning user keeps supplying is never reused (Figure 1). A gap therefore remains between static stores and an agent that stays efficient in this evolving scenario.

To close this gap, we propose SPECMEM, a tool-call memory that is kept alive and managed throughout deployment. Managing such a memory raises three coupled problems. Because calls accumulate across sessions, the store must stay bounded yet fresh as the user behavior drifts (lifecycle). Because the agent serves many users, retrieval must draw either on one shared global store or on each user's own history, a choice that decides whose calls can appear in whose drafts (scope). And because tools act on the world, a draft executed

Figure

Figure 1: A frozen TOOLSPEC-style datastore vs. SPECMEM on a recurring call: user u checked Google’s stock the day before and now asks for Apple’s. Each arm drafts a candidate call for a draft-then-verify decoder over the fixed served model (acceptance = token longest-common-prefix). SPECMEM retrieves u’s own GOOG call, accepted up to the changed ticker (17 of 28 target tokens) with only the remainder decoded; the frozen TOOLSPEC-style store’s stale build-time entry accepts 9, the schema-only draft 7 (full-run MAT 19.96 vs. 15.70 and 5.92). Only the live store writes the verified target back, so its advantage grows across sessions.

before verification can commit an irreversible action, such as sending an email (side effects; safety here in the systems sense, not content moderation). SPECMEM answers all three with online write-back into bounded, locally scoped stores under LRU eviction, and a side-effect gate that defers execution of any call not declared safe until verification confirms (Figure 1). Overall, SPECMEM delivers up to 1.74×1.74\times wall-clock decode speedup over vanilla decoding and a +27% post-warmup acceptance gain over the frozen store, widening to +46% by the final session.

Our experiments yield three findings. First, liveness drives acceptance: on multi-session, multi-user query streams served by real open-weight models, the frozen store degrades across sessions while the live store holds, an ablation attributes essentially the entire gain to online write-back, and the gap scales with the share of novel calls arriving after the store is built (+11% to +27% across τ2\tau^{2}-bench domains (Barres et al., 2025), +34% on Seal-Tools (Wu et al., 2024)). Second, local scoping adds almost nothing to acceptance but closes a measured leakage channel: under a global store, 14–68% of a user's drafts came from other users' histories. Third, retrieval confidence cannot make speculative execution safe, since a stale draft's similarity can be indistinguishable from a correct one's, whereas gating on declared side effects removes irreversible mistakes by construction.

In sum, this paper (i) formulates persistent tool-call memory as a lifecycle problem (write-back, partitioning, eviction, execution gating), instantiated in SPECMEM (§3); (ii) shows that a frozen store degrades while a live one holds, quantifies how the gap scales with post-freeze novelty, and attributes the gain to liveness rather than to store scope, eviction, or the choice of retriever, while measuring the cross-user draft leakage a global store incurs (§4–§5); (iii) identifies speculative execution of side-effecting tools as a hazard that confidence thresholds do not remove, and proposes a schema-level side-effect gate that does, defined on declared side effects rather than idempotency (§5.2); and (iv) validates the findings across three model families and six benchmarks (BFCL, Seal-Tools, live multi-turn τ2\tau^{2}-bench traces, API-Bank, ToolAlpaca, and ToolBench), including real wall-clock measurement (§4.3–§5.4).

References (31)