TokenPilot: Cache-Efficient Context Management for LLM Agents

Buqiang Xu, Zirui Xue, Dianmou Chen, Chenyang Fu, Chiyu Wu +10 more
6/15/2026
cs.CLcs.AIcs.LG

Official code: zjunlp/LightMem2 (78 stars, MIT, last commit 2026-06-16).

Abstract

As LLM agents are deployed in long-horizon sessions, context accumulation drives up inference costs. Existing approaches utilize text pruning or dynamic memory eviction to minimize token footprints; however, their unconstrained sequence mutations alter layouts, introducing prefix mismatches and cache invalidation. This reveals a critical trade-off between text sparsity and prompt cache continuity. To address this, we present TokenPilot, a dual-granularity context management framework. Globally, Ingestion-Aware Compaction acts as a framework harness to stabilize prompt prefixes and eliminate open-world environmental noise at the ingestion gate. Locally, Lifecycle-Aware Eviction monitors the ongoing residual utility of context segments, enforcing a conservative batch-turn schedule to offload content segments only when task relevance expires. Experiments on PinchBench and Claw-Eval under both isolated and continuous modes demonstrate that TokenPilot reduces costs by 61% and 56% in isolated mode, and 61% and 87% in continuous mode, while maintaining competitive performance compared to prior systems. TokenPilot has been integrated into LightMem2 at https://github.com/zjunlp/LightMem2.

View on arXivView PDF

Code Implementations(1)

zjunlp/LightMem2Official100%
MIT

A Plug-and-Play, Cost-Efficient, and Lightweight Memory Plugin for Long-Horizon LLM Agents

7815HTML, ShellMay 21, 20264 months agoMIT
ai-agentclaude-codecodexcost-efficientlarge-language-models+8 more

Similar Papers

Cite this paper

@article{xu2026tokenpilot,
  title  = {TokenPilot: Cache-Efficient Context Management for LLM Agents},
  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},
  year   = {2026},
  eprint = {2606.17016},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2606.17016v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2606.17016.svg)](https://codeofpaper.com/paper/2606.17016)

Discussion