让大模型自主压缩记忆,省钱提速还不丢精度。
Active Context Compression: Autonomous Memory Management in LLM Agents
- 设计自适应记忆管理机制,按需合并关键知识并主动删减冗余历史。
- 在SWE-bench Lite上实现平均6次自动压缩,最多省57%上下文 token。
- 适合需要长期任务的大模型应用,尤其关注成本与效率的开发者。
大型语言模型代理在长周期软件工程任务中受限于‘上下文膨胀’问题。随着交互历史增长,计算开销剧增、延迟上升,且因过往无关错误干扰导致推理能力下降。现有方案多依赖代理无法控制的被动外部摘要机制。本文提出 Focus,一种受粘菌(Physarum polycephalum)生物探索策略启发的代理中心架构。Focus 能自主决定何时将关键学习内容存入持久化‘知识块’,并主动删除原始交互历史。采用优化的支架(符合工业最佳实践:持久 bash + 字符串替换编辑器),在 SWE-bench Lite 的 5 个上下文密集型实例上,使用 Claude Haiku 4.5 进行评估。在强压缩提示下,Focus 实现 22.7% 的 token 减少(1490万 → 1150万),准确率保持不变(均为 3/5 = 60%)。每任务平均执行 6.0 次自主压缩,单任务最高节省达 57%。结果表明,具备适当工具和提示的大模型可自主调控上下文,为低成本、高性能的智能体系统开辟新路径。
原文摘要 · Abstract (English)
Large Language Model (LLM) agents struggle with long-horizon software engineering tasks due to "Context Bloat." As interaction history grows, computational costs explode, latency increases, and reasoning capabilities degrade due to distraction by irrelevant past errors. Existing solutions often rely on passive, external summarization mechanisms that the agent cannot control. This paper proposes Focus, an agent-centric architecture inspired by the biological exploration strategies of Physarum polycephalum (slime mold). The Focus Agent autonomously decides when to consolidate key learnings into a persistent "Knowledge" block and actively withdraws (prunes) the raw interaction history. Using an optimized scaffold matching industry best practices (persistent bash + string-replacement editor), we evaluated Focus on N=5 context-intensive instances from SWE-bench Lite using Claude Haiku 4.5. With aggressive prompting that encourages frequent compression, Focus achieves 22.7% token reduction (14.9M -> 11.5M tokens) while maintaining identical accuracy (3/5 = 60% for both agents). Focus performed 6.0 autonomous compressions per task on average, with token savings up to 57% on individual instances. We demonstrate that capable models can autonomously self-regulate their context when given appropriate tools and prompting, opening pathways for cost-aware agentic systems without sacrificing task performance.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。