Live data from Hacker News

Claude Code's compaction discards data that's still on disk

github.com

1–10 of 26 posts

Re: Claude Code's compaction discards data that's still on disk

#2
I hit this while pasting ~8K of DOM markup into Claude Code and iterating on selectors for a Chrome extension. About 40 minutes in, compaction fired and the summary said "user provided DOM markup" but the actual content was gone. Claude started guessing at selectors it had seen 20 minutes earlier.

The transcript with the original markup is still sitting at ~/.claude/projects/ as a .jsonl file — the compaction summary just has no pointer back to it.

I found 8+ open issues on the repo describing different symptoms of this same root cause. The proposal is to add line-range annotations to compaction summaries so Claude can surgically recover just the chunk it needs from the transcript on demand. Zero standing token overhead.

Curious if others have hit this in different scenarios or found workarounds that actually stick.

Re: Claude Code's compaction discards data that's still on disk

#3

I hit this while pasting ~8K of DOM markup into Claude Code and iterating on selectors for a Chrome extension. About 40 minutes in, compaction fired and the summary said "user provided DOM markup" but the actual content was gone. Claude started guessing at selectors it had seen 20 minutes earlier. The transcript with the original markup is still sitting at ~/.claude/projects/ as a .jsonl file — the compaction summary…

I'm fairly sure that Claude adds a note where it can find the original transcript after compactation (somewhat recently).

Fwiw I built a little CLI that could help with this, https://github.com/martinalderson/claude-log-cli. It allows Claude to search its own logs very efficiently. So I'm sure you could add something like "if the session is continued from a previous one, use claude-log cli to find users original prompt with claude-log" which would pull it out very efficiently. I built it to enable self improving claude.md files (link to the blog in the GitHub) but it's so useful for many tasks.

Re: Claude Code's compaction discards data that's still on disk

#4

I hit this while pasting ~8K of DOM markup into Claude Code and iterating on selectors for a Chrome extension. About 40 minutes in, compaction fired and the summary said "user provided DOM markup" but the actual content was gone. Claude started guessing at selectors it had seen 20 minutes earlier. The transcript with the original markup is still sitting at ~/.claude/projects/ as a .jsonl file — the compaction summary…

I'm fairly sure that Claude adds a note where it can find the original transcript after compactation (somewhat recently). Fwiw I built a little CLI that could help with this, https://github.com/martinalderson/claude-log-cli . It allows Claude to search its own logs very efficiently. So I'm sure you could add something like "if the session is continued from a previous one, use claude-log cli to find users original pro…

My Claude code started doing the compaction summary link thing but then stopped pretty soon after.

Re: Claude Code's compaction discards data that's still on disk

#6

I hit this while pasting ~8K of DOM markup into Claude Code and iterating on selectors for a Chrome extension. About 40 minutes in, compaction fired and the summary said "user provided DOM markup" but the actual content was gone. Claude started guessing at selectors it had seen 20 minutes earlier. The transcript with the original markup is still sitting at ~/.claude/projects/ as a .jsonl file — the compaction summary…

May I suggest pasting those 8k lines into a file instead of into the prompt?

Re: Claude Code's compaction discards data that's still on disk

#7
I honestly still don't see the point of compaction. I mean it would be great if it did work, but I do my best do minimize any potential for hallucination and a lossy summary is the most counterproductive thing for that.

If you have it write down every important information and finding along a plan that it keeps updated, why would you even want compaction and not just start a blank sessions by reading that md?

I'm kind of suprised that anyone even thinks that compaction is currently in any way useful at all. I'm working on something which tries to achieve lossless compaction but that is incredibly expensive and the process needs around 5 to 10 times as many tokens to compact as the conversation it is compacting.

Re: Claude Code's compaction discards data that's still on disk

#9

I hit this while pasting ~8K of DOM markup into Claude Code and iterating on selectors for a Chrome extension. About 40 minutes in, compaction fired and the summary said "user provided DOM markup" but the actual content was gone. Claude started guessing at selectors it had seen 20 minutes earlier. The transcript with the original markup is still sitting at ~/.claude/projects/ as a .jsonl file — the compaction summary…

Don't treat chat as anything other than ephemeral. That's the only workaround.

Re: Claude Code's compaction discards data that's still on disk

#10
post #7

I honestly still don't see the point of compaction. I mean it would be great if it did work, but I do my best do minimize any potential for hallucination and a lossy summary is the most counterproductive thing for that. If you have it write down every important information and finding along a plan that it keeps updated, why would you even want compaction and not just start a blank sessions by reading that md? I'm kin…

Well a few things.

Firstly, it's very useful to have your (or at least some) previous messages in. There's often a lot of nuance it can pick up. This is probably the main benefit - there's often tiny tidbits in your prompts that don't get written to plans.

Secondly, it can keep eg long running background bash commands "going" and know what they are. This is very useful when diagnosing problems with a lot of tedious log prepping/debugging (no real reason these couldn't be moved to a new session tho).

I think with better models they are much better at joining the dots after compactation. I'd agree with you a few months ago that compactation is nearly always useless but lately I've actually found it pretty good (I'm sure harness changes have helped as well).

Obviously if you have a total fresh task to do then start a new session. But I do find it helpful to use on a task that is just about finished but ran out of space, OR it's preferable to a new task if you've got some hellish bug to find and it requires a bunch of detective work.

Post reply on HN