Practical Online KV Cache Compaction for LLM Agents: An Empirical Study

Yujian Liu, Jiabao Ji, Li An, Rohit Jain, Gungor Polatkan, Siyu Zhu, Shiyu ChangarXiv 2026

TL;DR

LLM agents suffer from massive Key-Value (KV) cache overhead due to their long, multi-turn interaction histories. This paper explores online KV cache compaction—compressing history on-the-fly without knowing future queries—and demonstrates that delaying compaction by just a few turns to harvest real future queries as "proxies" reduces the KV cache footprint by 80% with minimal accuracy loss while significantly boosting serving throughput.

What Problem Does This Paper Address?

When LLM agents perform complex tasks, they generate long trajectories of reasoning steps, tool calls, and environment feedback. To generate each new token efficiently, the system maintains a Key-Value (KV) cache of the entire conversation history. As agent trajectories stretch across dozens of turns, this cache explodes in size, dominating GPU memory and creating a massive inference bottleneck.

While many "static" KV cache compaction methods exist, they typically assume a fixed context (like a long document) where future queries are either known or can be approximated offline. LLM agents, however, operate in an online fashion: they gradually construct their context through live interactions. Compressing this evolving history is challenging because the system must decide what information to discard before knowing how future turns will utilize it, all while staying within a strict runtime budget.

Methods

The authors systematically evaluate two sequence-level compaction families adapted for the online agent setting:

  1. Token Eviction (TE): A pure selection method that scores cached tokens based on their attention weights from "proxy queries" and retains only the highest-scoring original KV pairs.
  2. Attention Matching (AM): A more complex approach that selects tokens similarly to TE but goes a step further by optimizing an additive attention bias and reconstructing value vectors to closely match the full-cache attention outputs.

The core design choice is how to obtain the proxy queries that guide this compaction without introducing expensive computational overhead:

  • Current-turn proxies: Available immediately when a turn finishes. These include Boundary queries (using structural tokens like <|im_end|>) and Repeat-prefill queries (forcing the model to teacher-force/repeat the completed turn).
  • Future-turn proxies: The system deliberately delays compaction by $k$ turns, keeping the cache uncompressed while collecting actual future queries generated by the agent in subsequent steps.
Figure 1: Overview of the online KV compaction design space. Left: TE and AM both score cached tokens using proxy queries. TE stores the selected original keys and values, while AM keeps the selected keys and optimizes the attention bias and compacted values. Right: current-turn proxies are available when the turn finishes, whereas future-turn proxies delay compaction until k later turns provide additional queries.

Datasets

The methods were evaluated using Qwen3.5 and Gemma-4 models across two agentic-search benchmarks:

  • BROWSECOMP-PLUS: A fixed-corpus benchmark for deep-search agents requiring iterative evidence retrieval to answer difficult information-seeking questions.
  • WIDESEARCH: A broad information-seeking benchmark where the agent must discover atomic facts and organize them into a structured table.

Key Insights and Ideas

  • Immediate Compaction Hurts, Delaying Heals: Compacting a turn immediately after it finishes using current-turn proxies often degrades task performance. However, delaying compaction by just 1 to 5 turns to use actual future queries consistently recovers most of the performance gap.
  • Simplicity Wins in Robustness: Despite its simpler selection-only design, Token Eviction (TE) proved surprisingly robust to imperfect proxies and remained highly competitive with (or outperformed) the more complex Attention Matching (AM) technique.
  • Agents Adapt Behaviorally to Memory Loss: Interestingly, compaction changes how agents behave. Under aggressive compaction, models like Qwen3.5 tend to generate longer trajectories and issue more repeated search queries. The agent effectively uses the environment to re-fetch information that was weakened or discarded from its internal KV cache memory.

Key Results

  • 80% Cache Reduction: Across multiple model scales, delayed Token Eviction preserves the vast majority of no-compaction accuracy while reducing the KV cache size by 80% (a compaction ratio of 0.2).
  • Throughput Gains on Large Models: When tested on larger models (Qwen3.5-27B and Gemma-4-31B), delayed compaction reduced peak KV footprints by up to 3.5× and 2.7×, respectively.
  • Increased Concurrency: By freeing up memory, the system can handle larger serving batches, boosting overall serving throughput by up to 4.2× for Qwen3.5-27B and 1.7× for Gemma-4-31B, even when accounting for the slightly longer trajectories generated by the compacted models.

Limitations and Future Work

  • Task Variety: The study focuses exclusively on search and information-gathering agents. The structure of future relevance might differ significantly in other agent workloads like code editing, GUI control, or state-changing web tasks.
  • Heuristic Proxies: The authors restricted their study to low-overhead, cheap proxy sources. More expensive approaches (e.g., training separate lightweight compressors or running parallel rollouts) might yield better compression but at a higher latency cost.
  • Fixed Policies: The evaluation relies on fixed compaction ratios and delay windows. A promising future direction is developing adaptive controllers that dynamically adjust compaction aggressiveness based on real-time memory pressure or model uncertainty.

Summary updated

BibTeX
@misc{liu2026practical,
  author = {Yujian Liu and Jiabao Ji and Li An and Rohit Jain and Gungor Polatkan and Siyu Zhu and Shiyu Chang},
  title = {{Practical Online KV Cache Compaction for LLM Agents: An Empirical Study}},
  year = {2026},
  eprint = {2608.00902},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.00902},
}
Figure