NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TokenPilot: Cache-Efficient Context Management for LLM Agents

Buqiang Xu, Zirui Xue, Dianmou Chen, Chenyang Fu, Chiyu Wu, Caiying Huang, Chen Jiang, Jizhan Fang, Xinle Deng, Yijun Chen, Yunzhi Yao, Xuehai Wang, Jin Shang, Gong Yu, Ningyu ZhangarXiv 2026

Here is a concise, engaging summary of the paper "TokenPilot: Cache-Efficient Context Management for LLM Agents".

TL;DR

TokenPilot is a novel context management framework for long-horizon LLM agents that reconciles text compression with hardware KV cache efficiency. By stabilizing prompt layouts globally and deferring memory eviction based on task utility locally, it slashes LLM inference costs by up to 87% while maintaining competitive agent performance.

What Problem Does This Paper Address?

When LLM agents operate over long sessions—executing multi-turn workflows, calling tools, and reading files—their context windows quickly fill up with verbose execution traces. This accumulation drives up inference costs dramatically.

To fix this, existing approaches aggressively prune text or dynamically evict old memories. However, the authors identify a critical flaw: unconstrained text mutation shatters prompt cache continuity. When you slice out sentences or shift text boundaries, you alter the token layout. This causes prefix mismatches that invalidate the backend Key-Value (KV) prompt cache, forcing the system to pay full price for expensive "pre-fill" operations on cache misses.

Figure 1: Comparison of cache alignment behaviors. While the Original Agent Loop maintains continuous layouts to achieve cumulative cache hits, previous man- agement systems execute text truncation or compaction that mutates input boundaries, inadvertently triggering severe backend KV cache misses.

Methods

TokenPilot introduces a dual-granularity architecture to balance text sparsity with hardware cache alignment:

Figure 2: The system architecture of TokenPilot, featuring Ingestion-Aware Compaction at the global framework harness level and Lifecycle-Aware Eviction at the local context sequence level.
  1. Global Level: Ingestion-Aware Compaction
  2. Prefix Stabilization: It intercepts incoming prompts and replaces volatile runtime variables (like timestamps, directory paths, and transient IDs) with static placeholders. It also moves dynamic tool definitions downstream. This ensures a byte-identical prompt prefix from the very first turn, maximizing cache reuse across tasks.
  3. Observation Reduction: It strips structural noise from environmental feedback (e.g., slimming down raw HTML or truncating massive terminal logs) before it enters the history. A lightweight recovery tool acts as a fallback loop to fetch full payloads if the agent needs them later.
  4. Local Level: Lifecycle-Aware Eviction
  5. Instead of immediately purging text when a sub-task finishes, TokenPilot tracks context segments through three states: active, completed, and evictable.
  6. A small, zero-shot model estimator (Qwen3.5-35B-A3B) evaluates the ongoing residual utility of completed segments. Content is only marked as evictable when its relevance to future tasks has thoroughly expired.
  7. Evictions are executed conservatively in stable batches (e.g., every 3 turns) rather than turn-by-turn, preventing disruptive layout jitter.

Datasets

The authors evaluated TokenPilot across two realistic agent benchmarks under both isolated mode (context reset at task boundaries) and continuous mode (histories persist across tasks):

  • PinchBench: A real-world coding agent benchmark consisting of 123 tasks across 11 distinct categories (Productivity, Coding, Analysis, etc.).
  • Claw-Eval: A containerized agent evaluation platform. The authors tested the General task group, which includes 161 multi-step service orchestration and standalone analytical tasks.

Key Insights and Ideas

  • The Cache-Sparsity Paradox: Aggressively reducing token counts can ironically increase monetary costs if it triggers backend KV cache misses. Because providers discount cache hits heavily, maintaining layout continuity is often more economically viable than extreme text pruning.
  • Turning Cold Starts into Warm Starts: By canonicalizing volatile fields at the ingestion gate, TokenPilot successfully migrates the vast majority of tasks from minimal baseline token allocations to high-capacity warm starts.
  • The "Lazy Eviction" Valve: Keeping completed task data in the cache acts as a buffer. If a downstream task needs to reference a previously read file, it can access it directly via cache hits rather than triggering a chain of redundant, cold file re-reads.

Key Results

TokenPilot consistently achieved the lowest total inference costs while maintaining task accuracy on par with uncompressed baselines:

  • Cost Reductions: On PinchBench, TokenPilot reduced costs by 61% in isolated mode and 61% in continuous mode. On Claw-Eval, it cut costs by 56% (isolated) and a massive 87% (continuous).
  • Cache Hit Rates: Prefix stabilization caused average cache hit rates to skyrocket—rising from 38.7% to 79.2% on PinchBench, and from 67.2% to 83.1% on Claw-Eval.
  • Footprint Control: As shown in Figure 3, while a vanilla agent's context window climbs rapidly and stays high, TokenPilot tightly caps the active memory footprint through its periodic batch-eviction schedule.
Figure 3: Per-call context token volume across a contin- uous Meeting Analysis session.

Limitations and Future Work

  • Estimator Misclassification: The model-based utility estimator might misclassify context segments if the agent's interaction patterns are highly ambiguous or sparse.
  • Provider Dependency: The framework relies entirely on the LLM provider supporting backend prefix caching; it offers no financial benefit on platforms without this feature.
  • Task Shuffling Jitter: The continuous evaluation grouped similar tasks together. In highly heterogeneous, heavily shuffled task streams, frequent tool-schema mutations could still shorten reusable prefixes, a challenge the authors leave for future investigation.

Summary updated

BibTeX
@misc{xu2026tokenpilot,
  author = {Buqiang Xu and Zirui Xue and Dianmou Chen and Chenyang Fu and Chiyu Wu and Caiying Huang and Chen Jiang and Jizhan Fang and Xinle Deng and Yijun Chen and Yunzhi Yao and Xuehai Wang and Jin Shang and Gong Yu and Ningyu Zhang},
  title = {{TokenPilot: Cache-Efficient Context Management for LLM Agents}},
  year = {2026},
  eprint = {2606.17016},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.17016},
}
Figure