r/ClaudeCode • u/DopBopDeeBeep • 4d ago
Tips & Workflows Curious what you lose when you /compact?
I was curious how much important information I was losing when I was compacting conversations or letting conversations get to the point of auto-compacting.
I had a big session on a project recently (~850k tokens) so I had some extra usage before my weekly refresh and I asked Claude to run an experiment on itself to see what was being lost. Basically it compacted the conversation at three different levels and then quizzed the new session on context from the previous session to see what was kept and what was lost. It asked 9 questions about decisions that were made and why, 17 questions about specific details, and 5 questions about what I had asked and the status of tasks remaining.
- At ~320k tokens the session after /compact answered 56% of the questions correctly
- At ~570k tokens 35%
- At ~840k tokens 26%
The thing it was worst at was when I asked it exact details. Only 2 of 17 were correct for the 840k token /compact.
This is just one session where I was working on an iOS app for a huge task. Not a comprehensive examination but I was a bit surprised how bad it was at finding things.
Do others feel like they are losing important information with every compact?
tldr; /compact doesn't do a great job at preserving specific details and gets worse as your context grows. It does a fine job at preserving general direction and decisions that were made, especially at <350k context size.
•
u/AutoModerator 4d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
6
u/Far_Reindeer8428 4d ago
26 percent at 840k is a useful number. we stopped treating compact as memory and use it to keep working while the real notes live in files, the difference showed up immediately
3
u/Inner_Storage_3374 4d ago
the exact details part matches what id expect, a summary keeps the why and drops the numbers and names. what id try is having claude write decisions and open tasks into a file in the repo before compacting, so the next session reads that instead of the summary. curious if it holds up better if you compact earlier, like around 150k.
3
u/Heyn_Studio 4d ago
the exact numbers and names going missing is the part I'd plan around. I run a scheduled job where every run starts cold, and anything that has to be exact (post ids, timestamps, what's already done) goes into a small state file it reads first. the summary can be fuzzy about the why, it just can't be where the ids live
2
u/ainexfinder 4d ago
Useful that you actually measured it. Even at 320k you lost almost half, so compacting earlier helps but doesn't fix it. Exact details were never going to survive a summary, so the categories that matter more are decisions and task status, because those are what quietly break the next step. It would be interesting to rerun the same quiz with a short decisions and open-tasks file written to the repo right before compacting, and see whether those two categories recover while details stay low. That would show whether the fix is a better summary or keeping that state outside the context entirely.
2
u/Plastic_Koala2044 Senior Developer 3d ago
The summary keeps the shape of the work and drops the exact tool output, so the next turn rebuilds what it needs from scratch. Write the plan and the file list to a short doc before you compact, then point the agent at it after.
2
u/Findletrijoick 3d ago
How did you create this visualisation?
1
u/muhuhaha 3d ago
One thing I'd add to your experiment: /compact takes instructions after it, so you can tell it what to keep (something like "keep exact file names, error messages, and the open task list"). I'd rerun your 840k quiz with that and see how much of the 2/17 on details comes back, since the default summary is written to keep intent more than specifics.
u/ultrafastmov's point means a second run is worth doing too: tell the new session to read the transcript path before answering, and score it against the same questions.
Disclosure, I build Counterparts, a memory plugin for Claude Code. After a compaction a hook puts back a note Claude wrote itself, and what was said before the compaction is still written up.
1
u/ccalo 3d ago
"Be sure to look at the on-disc, pre-compaction logs" – done, works every time.
1
u/GnistAI 3d ago
Do you guys like delete the transcript or something after compaction? If mine needs any more context, it just goes get it.
1
u/texbardcana 3d ago
So this is an ad for context carwash? Where can I download it Mr Corporate?
1
u/DopBopDeeBeep 4d ago
Like everyone else and their mother ... I asked Claude to solve this problem for me. It made a better version of /compact that uses grep against the body of the previous conversation all stored in temporary memory so it doesn't add to file bloat.
Try it out if you'd like: https://github.com/Spobi/context-carwash
2
u/TorbenKoehn 4d ago
If you decide things and the only thing where that decision resides in is your session, this is the problem.
You don't need compacting solutions. In fact, if you're doing it right, "Sessions" or "Session state" doesn't matter, compactions don't matter, clears don't matter.
Just store things in files or databases...
Your decision example, normally it should be a bunch of ADRs. Regardless of compaction, it can and should know all of them.
If this is a problem for you, your solution should not some more context to manage compactions. It should be learning context management. It should be to think about where your "decision" lives and when it lives solely in an LLM session, it is already lost to begin with.
I work in single sessions over months, I have a "main" session where I do 90% of my work in. It always knows everything. It compacts randomly, I don't even see it. Because it doesn't know anything of worth.
Everything I give it, it stores away. Epics, Stories, Tasks, ADRs, Design Documents, Architecture Documents, Documentation Files etc.
Coupled with progressive disclosure and your LLM will always know everything...
2
u/Layers3d 3d ago
I have it write verison and build log as we go along so have reference what we've done
2
u/thewormbird 🔆 Max 5x 3d ago
#nevercompact1
u/Ethan 4d ago
I made a local ML classifier to decide when compact should happen. Calibrated it by testing compact vs. not compact in forked conversations. It appeared that, basically, earlier is almost always better, and the classifier became unnecessary. So now I have a hook that starts suggesting compaction to the agent at 150k tokens, then starts insisting harder at 200k tokens.
1
u/AgentYurt 4d ago
Your numbers match what I've seen — the why survives, the exact strings don't. What made the difference for me was giving up on the summary as the source of truth. I keep a short state file in the repo that the agent rewrites whenever it finishes a chunk of work: the current goal in one line, the decisions already made and why, what's still open, and the exact values that matter (ports, paths, error strings). Before I /compact, I have the agent update that file first, and the next session reads the file instead of relying on the summary.
What survived a restart: decisions and open tasks, almost always. What didn't: exact error messages and file paths — those had to be re-derived from the code every time until I started writing them down verbatim.
One thing I'm still unsure about: you found the quizzed session never opened the old transcript. Did you try pointing a fresh session at the raw .jsonl for just the exact-detail questions, to see if the details were actually retrievable, or if the summary is the only thing a resumed session will ever use in practice?
1
u/eXperience79 4d ago
My learning: don’t use compacting together with handoffs chains, that won’t work out well.
1
u/AppealSame4367 3d ago
Yeah, well. Other companies like OAI, Google etc provide 1M context so this problem doesn't get too heavy. Now look at Anthropic.
But whenever you criticize _anything_ in this sub you get downvoted to hell and spammed by gaslighting bots. So fuck it, I hope Google destroys Ant with it's new releases
1
u/RasenMeow 3d ago
Have a hook forcing it to read a dynamically updated pointer to recent decisions etc. works fine most of the cases.
1
u/Lumpy_Tough5165 13h ago
I've fixed this exact issue at least with Claude Code, when it comes to accuracy by implementing a virtual context window that can be queued, and i also made compaction itself much cheaper by offloading it to code that prunes it as well as a cheap model to distill a digest. You can read the readme on my public repo how i do it and the numbers as well. It is a Claude mod and is 100% open source so you can audit the code. Gladly would take any feedback
https://github.com/landtml/recontext
0
u/io-x 4d ago
What the heck is wash, is this an ad?
30
u/[deleted] 4d ago
[removed] — view removed comment