The underlying issue is that there is no reliable way to know what will be important later. A file path mentioned in passing early on might be critical for the final step. Compaction is lossy compression on a signal whose importance distribution you do not know ahead of time.
Practical workaround: persist critical state to disk files as you go. Write decisions, file paths, and intermediate results to a "memory" file that survives compaction. The agent can re-read it after compaction restores context. It is clunky but it works.
aciccarelli2•1h ago
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.
martinald•7m ago
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.
antinomicus•4m ago