←新闻详情

Larsen Cundric更新于 10月30日 14:28

Larsen Cundric 转发观点称压缩不如上下文检索

It’s time to find something better than compaction.

AI 导读

Larsen Cundric 转发 Alexander Yue 的观点,认为智能体上下文填满后做压缩是错误做法,应改为保留完整会话记录、让模型按需检索。Alexander Yue 称在约 400k token 的 Opus 5.5 会话上实测,缓存过期时压缩耗时 38 秒、花费 1.99 美元,未过期时 29 秒、0.17 美元,且摘要会丢失错误信息、文件路径等细节;他为此开发的 Mainplane 采用上下文检索,同样会话和模型下恢复工作耗时 15 秒、花费 0.10 美元,不依赖缓存命中且不做改写,项目以 MIT 协议开源。

引用

Alexander Yue

@Alezander9

压缩是个错误。 当智能体的上下文填满时,Codex 和 Claude Code 这类工具会对其进行压缩: 1. 模型会重新预填充整个会话 2. 它会写一份到目前为止所有内容的摘要 3. 新会话从这份摘要开始 我在一个真实的约 400k token 的 Opus 5.5 会话上测量了这一点: → 当提示缓存已过期时,耗时 38 秒,花费 1.99 美元 → 当提示缓存未过期时,耗时 29 秒,花费 0.17 美元 而且摘要是有损的。确切的错误信息、文件路径、你需要的那个数字,往往都丢失了。 所以我为 Mainplane 做了一件新事情 上下文检索的工作方式正好相反。Mainplane 会把每个会话的完整记录保存为一个文件。当上下文填满时,新会话会立即启动,并附带一条指令:“你正在继续会话 X。在需要时从中检索关键上下文。” 智能体会搜索旧会话,并在需要时复制它所需的确切行。 同样的会话、同样的模型:恢复工作只需 15 秒,花费 0.10 美元。它不依赖缓存命中,也没有任何内容被改写。 这就是把苦涩的教训应用到智能体记忆上。不要手工设计模型应该记住什么。给它完整记录和好用的工具,让它自己决定。 Mainplane 是开源的(MIT)。链接在第一条评论中。

查看原文

Compaction is a mistake. When an agent's context fills up, tools like Codex and Claude Code compact it: 1. The model prefills the entire session again 2. It writes a summary of everything so far 3. A new session starts from that summary I measured this on a real ~400k-token session with Opus 5.5: → 38 s and $1.99 when the prompt cache has expired → 29 s and $0.17 when it hasn't And the summary is lossy. The exact error message, the file path, the one number you needed is often gone. So I do something new for Mainplane Context retrieval works the other way around. Mainplane keeps the full record of every session as a file. When the context fills up, a new session starts right away with one instruction: "You are continuing session X. Retrieve key context from it as you go." The agent searches the old session and copies the exact lines it needs, when it needs them. Same session, same model: 15 s and $0.10 to get back to work. It does not depend on a cache hit, and nothing is paraphrased. This is the bitter lesson applied to agent memory. Don't hand-design what the model should remember. Give it the full record and good tools, and let it decide. Mainplane is open source (MIT). Link in the first comment.

查看原帖

正文 · AI 翻译

是时候寻找比压缩更好的方法了。

来源

Larsen Cundric