One email each morning — yesterday's AI, sortedGet it in your inbox

METAL LAB

ReCache: Efficient KV Cache Reuse and Compression for Tool-Augmented LLM Agents

arXiv:2608.196622026-08-21

Making AI agents stop re-reading the same tool manuals every time, for a 3x-plus speed-up

AI agents that call external tools have to re-encode tool and skill descriptions ('resources') from scratch whenever they show up in a new combination or order, which breaks standard KV-cache reuse. ReCache fixes this by letting each resource be cached independently and by trimming down what gets stored to only the parts that actually matter for making the right call. The result is up to 3.655x faster first-token response and 92.43% less cache memory, with accuracy nearly unchanged from the uncompressed baseline.

What they did

  1. Problem: tool/skill descriptions ('resources') recur across requests in different combinations and orders, so standard prefix caching, which only reuses identical starting text, can't reuse their computed key-value (KV) states
  2. Fix 1 - Resource-wise attention: removes cross-talk between different resources and resets each resource's internal position numbering from zero, producing KV blocks that stay valid regardless of order or combination
  3. Fix 2 - Structural pruning: measures which transformer layers and KV head groups actually contribute to correct tool invocation, then only lets those selected 'routes' access resource information, blocking the rest
  4. Fix 3 - Semantic pruning: keeps only the invocation-critical text, resource name, argument names, argument descriptions, and a final summary token, discarding the rest
  5. Results on a benchmark built from seven public tool/skill-use datasets: resource-wise attention alone nearly matches full dense-attention accuracy (82.3% vs 82.4% Inv-F1) while giving a 3.655x speed-up in time-to-first-token; the full ReCache framework cuts allocated KV-cache memory by 92.43% and speeds up attention computation by 1.423x
Figure 1: Cross-resource attention on Qwen3-4B.
Figure 1: Cross-resource attention on Qwen3-4B.
Table 1: Selected structural budgets. CC and ρ are percentages; ΔInv-F1 is measured relative to Ωfull after full-data training.
ModelKL/LKG/GCCLCCGρΔInv-F1 (%)
Ql20/363/897.747.379.2−0.2
Qs20/287/899.899.337.5−0.7
(b) Attention from subsequent conversation tokens onto resources, normalized and aligned by relative position.
(b) Attention from subsequent conversation tokens onto resources, normalized and aligned by relative position.
Table 2: Resource-wise attention ablation.
MethodInv-F1ID-F1Halluc.TTFT (ms)
Dense82.496.00.026.319
Block82.295.80.1
Ωfull82.396.00.27.200
Figure 2: ReCache constructs reusable KV blocks for each Ri and progressively reduces their subsequent cache retention and access. (a) Resource-wise attention removes inter-resource attention and resets positions from zero within each Ri. (b) Structural pruning exposes resource KV states (using Mresource) only through selected layer (Li)–KV-head-group (Gi) routes Ω⋆ (highlighted in blue). The remaining routes use Mcontext. (c) Semantic pruning retains resource names, argument (arg) names and descriptions (desc.), and the final suffix token. The final mask combines these decisions, ensuring that Y attends exclusively to retained semantic fields within assigned routes during decoding.
Figure 2: ReCache constructs reusable KV blocks for each Ri and progressively reduces their subsequent cache retention and access. (a) Resource-wise attention removes inter-resource attention and resets positions from zero within each Ri. (b) Structural pruning exposes resource KV states (using Mresource) only through selected layer (Li)–KV-head-group (Gi) routes Ω⋆ (highlighted in blue). The remaining routes use Mcontext. (c) Semantic pruning retains resource names, argument (arg) names and descriptions (desc.), and the final suffix token. The final mask combines these decisions, ensuring that Y attends exclusively to retained semantic fields within assigned routes during decoding.
Table 3: Results on 𝒯IND. Efficiency is reported relative to Dense. SMP denotes Semantic Pruning.
MethodAttn. ×Mem. ↓Inv-F1ID-F1Halluc.
Dense82.496.00.0
Ωfull1.001×0.47%82.396.00.2
Structural pruning
Ω20,G1.016×44.71%82.595.70.3
Ωfull + SPEED1.013×44.71%79.392.92.8
Ω20,31.314×79.27%82.195.60.2
Ωfull + SA20,31.302×79.27%79.193.71.0
Semantic pruning
Ωfull + Gist1.029×99.22%39.246.951.4
Ωfull + Beacon1.020×75.42%78.692.51.4
Ωfull + SMP1.021×63.57%81.695.20.2
ReCache1.423×92.43%80.394.90.2
Figure 3: Structural contribution coverage in Ql and Qs. Cumulative leave-one-in contributions of layers (top) and KV head groups (bottom); vertical lines mark the selected budgets.
Figure 3: Structural contribution coverage in Ql and Qs. Cumulative leave-one-in contributions of layers (top) and KV head groups (bottom); vertical lines mark the selected budgets.
Table 4: 𝒯OOD Results. SMP denotes Semantic Pruning.
MethodInv-F1ID-F1Halluc.
Dense66.395.60.0
Ωfull64.794.40.4
Structural pruning
Ω20,G64.394.30.5
Ωfull + SPEED54.381.613.4
Ω20,363.293.30.5
Ωfull + SA20,358.288.45.1
Semantic pruning
Ωfull + Gist9.717.879.9
Ωfull + Beacon58.589.74.2
Ωfull + SMP62.894.10.3
ReCache60.892.80.6
Figure 4: Efficiency on varying resource lengths Dℛ. Requests are grouped by average resource length into Small (0≤Dℛ<1​K), Medium (1​K≤Dℛ<5​K), Large (5​K≤Dℛ<10​K), and XL (Dℛ≥10​K). SMP denotes semantic pruning.
Figure 4: Efficiency on varying resource lengths Dℛ. Requests are grouped by average resource length into Small (0≤Dℛ<1​K), Medium (1​K≤Dℛ<5​K), Large (5​K≤Dℛ<10​K), and XL (Dℛ≥10​K). SMP denotes semantic pruning.
Table 5: Dataset composition and split statistics. Source rows report eligible examples before final selection; the Toucan aggregate is not double-counted in the summary row. Distinct names counts source-level unique declared tools or skills, Subset dup. counts records beyond the first occurrence of an identical candidate configuration, and Recurring names counts resources appearing in multiple records. The summary row corresponds to 18.8% duplicated candidate records and 77.3% recurring resource names. IND cand. and OOD cand. denote eligible in-distribution and out-of-distribution candidates, and dashes mark unavailable statistics.
GroupSourceTrain poolDistinct namesSubset dup.Recurring namesIND cand.OOD cand.
ToolToolACE8,40014,5661787,144200195
APIGEN10,0002,8067342,805500146
Toucan (all generators)13,0714,3556,9014,355600493
- Kimi-K23,3331,1031,7721,103200145
- GPT-OSS-120B4,1841,4122,1621,412200130
- Qwen3-32B5,5541,8402,9671,840200218
ToolRet1,1501,593235431100150
ToolMind20,00014,5041,85314,497500190
WildToolBench256
SkillSkillRouter87
Sources with frequency statistics52,62137,8249,90129,2321,9001,174
Candidate pool52,9641,9001,174
Final dataset49,4241,0001,000
(b) TPOT
(b) TPOT
Table 6: Structural budget ablation for Qs across training data regimes with comparable budgets.
ConfigInv-F1Resource IDHalluc.
ID-PID-RID-F1
Ωfull72.192.090.890.90.4
ΩL,549.674.573.573.44.8
ΩL,653.479.677.978.33.2
ΩL,757.383.481.882.12.9
Ω15,G69.389.288.388.31.1
Ω20,G70.590.689.589.61.1
(c) Attn.
(c) Attn.
Table 7: Structural budget ablation trained on 𝒟.
ConfigInv-F1Resource IDHalluc.
ID-PID-RID-F1
𝑸𝒔
Ωfull80.794.994.394.40.1
Ω20,578.894.193.593.60.5
Ω20,780.094.794.094.10.3
𝑸𝒍
Ωfull82.396.495.896.00.2
Ω20,281.995.394.794.70.3
Ω20,382.196.195.595.60.2
(d) Mem.
(d) Mem.
Table 8: Semantic pruning ablation trained on 𝒟subset. Arg stands for argument, Desc. stands for description. Ω20,3 denotes the routing configuration with KL=20,KG=3.
ConfigInv-F1Resource IDHalluc.
ID-PID-RID-F1
Ω20,376.193.192.892.50.9
Schema representation ablation
Suffix-only Schema14.822.823.022.976.0
+ Resource Name45.289.988.888.91.8
+ Arg Name67.792.191.191.21.3
+ Resource Desc.67.992.291.491.41.1
+ Arg Desc.72.892.891.992.01.0
+ Both Desc.73.493.092.292.21.2
Table 9: Individual contribution weights and cumulative contribution coverage of structural units. Within each panel, units are ranked independently by decreasing wi, and CC at rank k is the cumulative positive contribution weight through rank k. Bold entries fall within the empirical budgets KL=20,KG=3 for Ql and KL=20,KG=7 for Qs.
Layers
𝑸𝒍(Qwen3-4B)𝑸𝒔(Qwen3-1.7B)
rankunit𝒘𝒊 (%)CC (%)rankunit𝒘𝒊 (%)CC (%)
1L3415.5615.61L2220.0920.1
2L3510.5326.12L2512.9033.0
3L239.3735.53L2012.1445.1
4L258.3143.84L2610.9056.0
5L328.0151.85L2710.3966.4
6L306.9558.76L176.8273.2
7L336.8965.67L216.7079.9
8L275.1770.88L194.6584.6
9L214.8775.79L244.0088.6
10L284.6480.310L232.1390.7
11L244.0284.311L181.8992.6
12L223.7488.112L151.7394.3
13L172.3090.413L131.3995.7
14L311.9692.314L101.1396.9
15L181.2993.615L91.0397.9
16L141.2694.916L40.8898.8
17L200.7895.717L160.5699.3
18L360.6996.318L120.1899.5
19L190.6897.019L110.1599.7
20L160.6897.720L80.1499.8
21L100.6098.321L280.1199.9
22L50.3398.622L50.06100.0
23L110.2998.923L20.02100.0
24L90.2799.224L10.00100.0
25L120.2699.525L30.00100.0
26L150.2699.726L60.00100.0
27L130.1399.827L70.00100.0
28L80.0799.928L140.00100.0

Why it matters

Tool-using AI agents currently re-process bulky tool descriptions on every request, which slows responses and inflates serving costs; ReCache offers a concrete way to cut that redundant computation while keeping performance intact. Its code is publicly released, so developers building agentic systems can adopt it directly.

Terms in this paper

  • KV cache · stored key-value computations from previously processed tokens that a language model reuses instead of recomputing
  • prefix caching · a caching method that only reuses prior computation when the new input starts with an identical sequence of text
  • TTFT (time-to-first-token) · how long it takes the model to produce its very first output token after receiving a request, a key latency metric
  • structural / semantic pruning · compression methods that remove less-important parts either at the model's layer/head level or at the text/token level
  • resource (tool/skill schema) · the structured text description of a callable tool or skill, including its name, arguments, and descriptions

Original abstract (English)

Agentic language models repeatedly encode tool and skill schemas that recur across requests in different combinations and orders, preventing standard prefix caching from reusing their key--value (KV) states. We introduce \textbf{ReCache}, a framework for independently caching resource representations while reducing their inference-time computational and memory overhead. Resource-wise attention removes cross-resource interactions and assigns resource-local positions, producing composition-invariant KV blocks. ReCache then restricts resource visibility to contribution-selected layer--KV-head-group routes and retains only invocation-critical fields through structural and semantic pruning. We evaluate ReCache on a benchmark assembled from seven public tool- and skill-use datasets, including resource-disjoint tests. Resource-wise attention matches dense invocation performance (82.3\% versus 82.4\% Inv-F1) while providing a 3.655$\times$ time-to-first-token speedup. The complete framework reduces allocated KV-tensor memory by 92.43\% and accelerates attention by 1.423$\times$. These results show that separating reusable schema encoding from selective resource access substantially reduces agentic inference costs with limited effectiveness loss. The code is available at https://github.com/EIT-NLP/ReCache.

Authors · Yichu Fang, Sitong Wei, Haozhe Hu, Xiaoyu Shen

Read on arXiv

Latest papers

All papers →

Latest from METAL LAB

Figures: Yichu Fang et al., arXiv:2608.19662, arxiv-nonexclusive