Skip to content
Mastering Claude

Home / When things go wrong

When things go wrong10 minApplication

Loops, polluted context and restarting

The sign of a loop is the same failure message repeating, a saturated context is handled by a targeted compaction or a full clear, and starting over with a hand written summary of the decisions already made beats insisting inside a degraded conversation.

Claude Code interrupts an automatic compaction cycle by itself when it starts repeating endlessly: when the context fills up again right after a compaction, the tool shows the message Autocompact is thrashing: the context refilled to the limit... and stops retrying, rather than continuing to spend API calls for nothing. This is the only loop signal formally documented by Anthropic. The widespread reflex of counting the same failure message repeating remains a matter of common sense, not a named feature of the product.

Reducing context before starting over

Faced with this message, or with any sense of going in circles on the same file, the official documentation offers several options before a full restart. Asking for the file at issue to be read in slices avoids saturating the context all at once. Running a targeted compaction with a focus instruction keeps what matters and discards the rest.

/compact keep only the plan and the diff

Delegating work on a large file to a sub-agent also limits what enters the main context of the current conversation.

Two commands for starting over, and they do not do the same thing

/clear erases everything, conversation and context, keeping nothing. The checkpoint menu, opened with /rewind or a double press of Escape when the input line is empty, instead restores the conversation, the code, or both, to an earlier point in the same session, without losing everything. This system keeps one limit worth knowing: it tracks edits made by Claude's file editing tools, not a change made by a bash command such as rm, mv or cp.

When the conversation is too degraded for a rewind to be enough, /clear remains the right choice, provided it comes with a hand written summary: the decisions already made, what failed and why, the file to resume from. A fresh context without this summary forces everything to be rediscovered. This same checkpoint mechanism comes back, applied to a code fix rather than an entire conversation, in undoing and recovering a change.

Figure 1

From the loop signal to restarting

01
Same message twice
The same failure message appears twice in a row on the same request, the first signal not to ignore.
02
Compaction that loops
The context fills up again right after a compaction, Claude Code announces it with the Autocompact is thrashing message and stops retrying.
03
Reduced context
Reading in slices or a targeted compaction focused on the plan and the diff limit what stays in context.
04
Return to an earlier point
The checkpoint menu restores the conversation, the code, or both, to an earlier point in the same session.
05
Full restart
When none of this is enough, /clear and a hand written summary replace persisting inside a degraded context.
The sequence starts with the failure message repeating, moves through reducing context and returning to an earlier point, and ends with a full restart when nothing else is enough.
Calibrate it yourself

A developer sees Claude Code display, three times in a row, a message starting with Autocompact is thrashing while he tries to have a large configuration file reread. He presses Escape twice, opens the menu that appears, and chooses to restore the conversation to a point before the file was read.

Write, in one sentence, what this situation establishes, and in one sentence what it does not establish.

What to remember
  • The Autocompact is thrashing message is the only loop signal officially documented by Claude Code, produced when the context fills up again right after a compaction.
  • Reading in slices, a targeted compaction with a focus instruction, or delegating to a sub-agent reduce context before considering a full restart.
  • The /clear command erases everything with nothing kept, while the checkpoint menu, opened by /rewind or a double Escape, restores the conversation, the code, or both, to an earlier point in the same session.
  • The checkpoint system tracks edits made by Claude's file editing tools, not changes made by a bash command such as rm, mv or cp.
  • A full restart benefits from being accompanied by a hand written summary of the decisions already made, to avoid rediscovering everything in an empty context.
Do this now

As soon as you see the same failure message twice, stop the strategy that is failing: press Escape twice to open the checkpoint menu, or run /clear and reopen with a hand written summary of the decisions already made.

Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.