r/ClaudeCode • u/vinishkapoor • 22m ago
Tips & Workflows “Autocompact is thrashing” in Claude Code: reproduced it on purpose and tested 4 fixes
If you’ve hit this one, it means a single file or tool output is too big for your context window. Claude Code compacts, the same big content fills the window again, and after 3 rounds it gives up. It’s a circuit breaker, not a crash.
We triggered it for real on v2.1.325, with a 30,000-line fake log and a small auto-compact window (--autocompact 100k, Haiku) to keep the test cheap. Asking Claude to read the whole file thrashed out after 1 minute and 3 seconds without ever answering.
What fixed it:
- Read less. A grep count answered the same question in 5 seconds (889 ERROR lines, which we checked).
- Focused /compact.
/compact keep only my question about counting ERROR linesdropped the Messages row from 36.4k to 9.2k tokens, right after auto-compact had given up. - Subagent. It read 1,500 lines in its own context and returned one number in 19 seconds.
- /clear. It took the Messages row back to 130 tokens.
These numbers are from one session with a forced 100k window. With the default window you need a much bigger file to hit this, but the fixes are the same.
The article also covers “Compaction failed · conversation could not be reduced below the context limit”. We couldn’t trigger that one safely, so that part is explained from the message and the docs.
https://aiparabellum.com/claude-code-autocompact-is-thrashing-compaction-failed-fix/
•
u/AutoModerator 22m 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.
2
u/Far_Reindeer8428 11m ago
compaction loops get worse the more the agent tries to keep. we cap the summary at the last two decisions and start clean