AI记忆压缩时安全规则易丢失,新方法可大幅提高保留率。
The Compaction Cliff in Long-Running AI Agent Memory

- 按知识类型分类管理,分策略保留关键信息
- 五轮压缩后仍保有10%安全规则,远超旧方法
- 适合需要长期合规的生产级AI系统使用
AI代理的上下文空间中,安全规则与事件日志争夺有限令牌。当预算溢出时,两者以相同速率被压缩,但只有安全规则需精确保留以维持效力。在20个生产配置中,Claude Code的/compact提示在Sonnet 4.6上经过一轮压缩后保留53%安全规则,五轮后降至10%,此现象称为“压缩悬崖”。为此提出Knowledge Triage框架:根据知识类型分类,每类采用独立保留策略。三个确定性操作实现该机制:TypeCompact在类型内保持高保真度重写;TypeDecompose将过大主题安全拆分,复制跨分区的安全规则;TypeRetrieve从外部存储检索,提前锁定相关规则。在五个公开语料库上,TypeCompact在所有压缩比下均比最强单次压缩模型多保留2–4倍安全规则,五轮后召回率达96%。TypeDecompose将局部违规率降至0%(对比均匀分割的93%)。TypeRetrieve在前50项召回率达100%(对比最优单次检索器的73%)。在三个下游行为基准测试中,优于生产级Sonnet压缩器(医疗合规性,配对McNemar检验,p < 10^-8,N=200)、全策略与层级基线(零售任务通过率,p < 0.01,N=115),以及层级压缩方法(航空领域,p=0.024)。研究发布AgentArtifactCorpus(来自54,628个GitHub仓库的396,934个代理配置)、分类器及参考实现。
原文摘要 · Abstract (English)
A safety rule and an episodic log compete for the same tokens in an AI agent's context. When the budget overflows, both are summarized at the same rate; only the rule needs exact wording to remain enforceable. On 20 production agent configurations, Claude Code's /compact prompt on Sonnet 4.6 preserves 53\% of safety rules after one compaction round and 10\% after five. We name this the Compaction Cliff. We address it with Knowledge Triage, a framework that classifies each line of an agent's knowledge base by type and routes each type through its own retention policy. Three deterministic operators implement this triage across the three context-management operations: TypeCompact rewrites items in place under per-type fidelity, TypeDecompose partitions a topic too large to compact safely, replicating in-scope safety rules across partitions, and TypeRetrieve fetches items from external storage with in-scope rules pinned ahead of relevance. On five public corpora, TypeCompact preserves 2--4$\times$ more safety rules than the strongest single-shot LLM compactor at every ratio, with 96\% recall over five rounds. TypeDecompose reaches 0\% locality violations against 93\% under uniform partitioning. TypeRetrieve reaches 100\% recall@50 against 73\% for the best single-shot LLM retriever. On three downstream behavioral benchmarks, we outperform the production Sonnet compactor on medical compliance (paired McNemar $p < 10^{-8}$ on preservation, $N = 200$), the full-policy and hierarchical baselines on retail task pass rate ($p < 0.01$, $N = 115$), and the hierarchical compaction on the airline domain ($p = 0.024$). We release AgentArtifactCorpus (396{,}934 agent configurations from 54{,}628 public GitHub repositories), the classifier, and the reference implementation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。