Submit a toolSubmit

Claude Code says Autocompact is thrashing. Stop the refill loop

Autocompact thrashing means compaction succeeded, then a file or tool output refilled the context. Claude Code stops retrying so it does not burn API calls. Short answer: 5 steps. 1) Recognize thrashing vs a normal compact; 2) Read oversized files in chunks; 3) Run a focused /compact or move work to a subagent; 4) If it returns after /clear, inspect /context; 5) Prevent the next thrash.

Last updated: · This page is the decision checklist; the tools list for “Fix Claude Code autocompact thrashing” is a separate URL.

The problem: Autocompact thrashing means compaction succeeded, then a file or tool output refilled the context. Claude Code stops retrying so it does not burn API calls.

How do I stop a Claude Code Autocompact refill loop?

  1. Recognize thrashing vs a normal compact

    If you see `Autocompact is thrashing: the context refilled to the limit...`, automatic compaction worked but something immediately filled the window again. Waiting will not help—Claude Code intentionally stops the retry loop. Docs: https://code.claude.com/docs/en/troubleshooting

  2. Read oversized files in chunks

    Ask Claude to open a specific line range, function, or section instead of the whole file. Large single reads and huge tool outputs are the usual refill source right after a compact.

  3. Run a focused /compact or move work to a subagent

    Use `/compact` with an explicit focus such as `/compact keep only the plan and the diff` so the large payload is dropped. For exploration of big files, move that work to a subagent so it runs in a separate context window.

  4. If it returns after /clear, inspect /context

    Run `/clear` when the earlier conversation is disposable, then `/context`. If the Messages row is the largest, a new file or tool output is refilling the window—chunk reads again. If the rows above Messages dominate, trim what loads at session start (rules, MCP, large CLAUDE.md).

  5. Prevent the next thrash

    Prefer targeted `@` paths, smaller tool results, and `/compact` between major tasks. For chronic high memory after heavy sessions, restart Claude Code and use `claude --continue` so the conversation resumes in a fresh process without carrying the bloated heap.

Which tools are best to fix Claude Code autocompact thrashing?

Claude Code troubleshooting

Official Autocompact is thrashing recovery steps and /context guidance.

Manage Claude’s memory

How CLAUDE.md and memory load into context at session start.

Claude Code costs

Why burning tokens on a compact retry loop matters on plan and API billing.

Claude Code overview

Product docs after you stabilize context size.

All tools for “Fix Claude Code autocompact thrashing” →

Related fixes

See also AI tools launched today on the daily board.