SideQuest: Model-Driven KV Cache Management for Long-Horizon Agentic Reasoning

Sanjay Kariyappa, G. Edward SuharXiv 2026

TL;DR

LLM agents doing deep research quickly run out of memory due to massive context histories accumulated from web searches and documents. SideQuest solves this by letting the model act as its own "garbage collector," running a parallel thread to intelligently evict useless data from its Key-Value (KV) cache. This model-driven approach slashes peak token usage by up to 65% with almost no loss in accuracy, leaving traditional heuristic-based compression techniques in the dust.

What Problem Does This Paper Address?

As Large Language Models (LLMs) transition into autonomous agents performing long-horizon, multi-step reasoning (like deep research or complex workflow automation), their context windows explode. Every webpage visited or tool called appends thousands of tokens to the history.

The primary bottleneck for scaling these workloads is the Key-Value (KV) cache. It grows linearly with sequence length, devouring GPU memory and choking memory bandwidth during token generation.

Existing solutions rely on static heuristics to prune the cache—for instance, keeping only tokens with the highest cumulative attention scores (e.g., H2O or SnapKV). However, the authors demonstrate that in agentic workflows, token importance is non-monotonic. A search results page might seem useless right after a specific link is clicked, but that link's original context might become vital turns later for final citations. Static heuristics blindly prune these temporarily "low-importance" tokens, leading to reasoning failures and model collapse.

Methods

SideQuest introduces an intelligent, model-driven KV cache eviction mechanism. Instead of relying on rigid mathematical formulas, it leverages the semantic understanding of the Large Reasoning Model (LRM) itself to decide what to keep.

To avoid slowing down the agent or cluttering its memory with management tokens, SideQuest uses a shared-context parallel reasoning architecture:

  1. Parallel Forking: At regular intervals, SideQuest forks the generation process to spawn a transient auxiliary thread that shares the main thread's prefix context history.
  2. Staleness Reasoning: Triggered by a special phrase (** Memory management mode **), the model reflects on open tool outputs (indexed via unique "cursors") to determine which are obsolete.
  3. Eviction: The auxiliary thread outputs a structured deletion command (e.g., {del_cursors: [0]}), freeing up the corresponding KV cache entries.
  4. Training via Hindsight: The authors train the model using a clever data synthesis pipeline. They analyze successful agent traces in hindsight to find exactly when a tool output was last used, creating a dataset of 215 main traces (preserved via logit distillation to prevent forgetting) and 1,274 auxiliary traces.
Figure 1. Walkthrough example of SideQuest. (a) The main thread processes the user request by performing multi-turn reasoning and tool calling. (b) At regular intervals we spawn an auxiliary thread that runs in parallel with the shared context (c) The auxiliary thread reflects on the context and lists the cursors that can be deleted. (d) We clear the messages in the context by invoking a tool, reducing the context size for future turns.

Datasets

The authors evaluated SideQuest on two demanding long-context, multi-turn web browsing benchmarks:

  • FRAMES: Evaluates retrieval and multi-hop reasoning over a massive corpus of 6.4 million Wikipedia articles (tested on 424 queries).
  • BrowseComp: Tests web navigation capabilities to locate hard-to-find information across a fixed set of 100,000 documents (tested on 500 queries).

Key Insights and Ideas

  • The Failure of Fixed Token Budgets: Traditional compression forces the KV cache into a fixed window (e.g., 16k tokens). But agent tasks have massive variance; simple queries waste memory, while complex ones fail on the long tail. SideQuest dynamically scales the budget based on instantaneous task difficulty.
  • Isolating Management Logic: Running garbage collection inline within the main thread causes "context pollution" and adds latency. By isolating this logic into a transient parallel thread, the main agent's context remains pristine.
  • Heuristics Cause Syntactic Collapse: A fascinating finding was that heuristic pruning often removes tokens critical for syntactic coherence, causing the model to output unparsable gibberish. SideQuest maintains a near-zero failure rate because it understands the semantics of what it deletes.

Key Results

  • Massive Memory Savings: SideQuest reduces peak token utilization by 56% to 65% and cuts KV cache memory reads by 53% to 71% compared to an uncompressed baseline.
  • High Fidelity: This compression comes with minimal accuracy degradation—only a ~2% drop on FRAMES and a ~5% drop on BrowseComp, vastly outperforming heuristic baselines like H2O, SnapKV, and R-KV.
  • Real-World Serving Gains: When implemented in SGLang on an NVIDIA H100 GPU, SideQuest increased peak system throughput by 83.9% (by enabling larger batch sizes) and reduced total benchmark runtime by 36.8%.
Figure 3. Efficiency vs. Utility Trade-off. We evaluate Accuracy against Peak Token Usage and KV cache memory reads for gpt-oss-20b with Medium and High reasoning effort, on the FRAMES and BrowseComp benchmarks. The Uncompressed Baseline establishes the upper bound for accuracy but incurs the highest memory cost. SideQuest achieves substantial memory savings—reducing peak token usage by 56-65% compared to the baseline—while providing a better accuracy compared to heuristic based methods.

Limitations and Future Work

  • Data Scale: There is a slight performance gap on out-of-distribution data (BrowseComp), which the authors attribute to the small fine-tuning dataset (only 215 traces). Scaling up the training data should close this gap.
  • Scope of Eviction: SideQuest currently only prunes tool responses (webpages, search results). It does not yet compress the agent's own intermediate reasoning steps ("thought pruning").
  • Broader Applications: The parallel auxiliary thread architecture is domain-agnostic. Future directions include applying it to coding agents (to prune irrelevant codebase files) or using it for real-time safety, security, and platform policy guardrails without independent context reprocessing.

Summary updated

BibTeX
@misc{kariyappa2026sidequest,
  author = {Sanjay Kariyappa and G. Edward Suh},
  title = {{SideQuest: Model-Driven KV Cache Management for Long-Horizon Agentic Reasoning}},
  year = {2026},
  eprint = {2602.22603},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.22603},
}
Figure