Comparing Claude Code Compaction vs On-Demand Retrieval
Baoyu argues that Claude Code's context compaction mechanism is functionally similar to starting a new session and retrieving useful information from history on demand, with the main difference being minor token overhead from summaries. This counters Alexander Yue's claim that 'compaction is a mistake,' who advocates for keeping full records and letting agents autonomously retrieve exact lines to avoid information loss inherent in summarization.
Related Entities
Full Report
宝玉 (@dotey) · 2026-10-30 04
如果我理解的没错的话,当前 Claude Code 在压缩后继续任务,会按需从历史会话中查找有用的信息加载到上下文。
这和作者所说的新开一个会话再去从原来的会话加载有用信息不是一回事吗?唯一的差别就是多了一点摘要信息,但这多不了多少 Token。
而且就算你新开一个会话,任务继续同样会很快填满上下文。
↳ 引用 @Alezander9 (Alexander Yue): Compaction is a mistake.
When an agent's context fills up, tools like Codex and Claude Code compact it:
- The model prefills the entire session again
- It writes a summary of everything so far
- 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.