面向 LLM 智能体的 Contextual Memory Virtualisation:基于 DAG 的状态管理与结构无损裁剪
Contextual Memory Virtualisation: DAG-Based State Management and Structurally Lossless Trimming for LLM Agents
AI 导读
研究者提出 Contextual Memory Virtualisation(CMV),借鉴操作系统虚拟内存,把 LLM 会话累积的理解建模为有向无环图(DAG)上的可版本控制状态,支持快照、分支、裁剪与跨并行会话的上下文复用。
正文 · 原文
Abstract:As large language models engage in extended reasoning tasks, they accumulate significant state -- architectural mappings, trade-off decisions, codebase conventions -- within the context window. This understanding is lost when sessions reach context limits and undergo lossy compaction. We propose Contextual Memory Virtualisation (CMV), a system that treats accumulated LLM understanding as version-controlled state. Borrowing from operating system virtual memory, CMV models session history as a Directed Acyclic Graph (DAG) with formally defined snapshot, branch, and trim primitives that enable context reuse across independent parallel sessions. We introduce a three-pass structurally lossless trimming algorithm that preserves every user message and assistant response verbatim while reducing token counts by a mean of 20% and up to 86% for sessions with significant overhead by stripping mechanical bloat such as raw tool outputs, base64 images, and metadata. A single-user case-study evaluation across 76 real-world coding sessions demonstrates that trimming remains economically viable under prompt caching, with the strongest gains in mixed tool-use sessions, which average 39% reduction and reach break-even within 10 turns. A reference implementation is available at this https URL.
| Comments: | 11 pages. 6 figures. Introduces a DAG-based state management system for LLM agents. Evaluation on 76 coding sessions shows up to 86% token reduction (mean 20%) while remaining economically viable under prompt caching. Includes reference implementation for Claude Code |
| Subjects: | Software Engineering (cs.SE); Artificial Intelligence (cs.AI); Human-Computer Interaction (cs.HC); Operating Systems (cs.OS) |
| Cite as: | arXiv:2602.22402 [cs.SE] |
| (or arXiv:2602.22402v2 [cs.SE] for this version) | |
| https://doi.org/10.48550/arXiv.2602.22402 arXiv-issued DOI via DataCite |
Submission history
From: Cosmo Santoni [view email]
[v1]
Wed, 25 Feb 2026 20:52:52 UTC (682 KB)
[v2]
Thu, 22 Oct 2026 22:21:54 UTC (682 KB)
来源:arXiv cs.AI · arxiv.org