§05 · Handoffs

Autocompact

Also called Auto-compaction · Automatic compaction

Compaction the harness triggers on its own when the context window nears its limit, without asking you first.

Autocompact is compaction that the harness performs automatically when the context window gets close to full. You do not ask for it; the harness notices the session is near the limit, summarizes the history, and carries on. Claude Code shows a warning as the threshold approaches and a notice when it happens. The point is to keep a long session running instead of stopping it with an error.

Because it fires on a size threshold rather than a task boundary, it tends to land at the worst moment: halfway through a multi-file change, with the plan half in the agent's head. The agent continues from a summary it did not choose the timing of, and the drop in quality can look like the model suddenly getting worse. People often blame the model when the real event was an autocompact three turns ago.

Do not let it be a surprise. Watch the context indicator and compact or clear on your own terms before the harness does it for you. Keep state on disk, in commits, notes, and a handoff artifact, so a summary is never the only copy of anything. If your sessions autocompact regularly, the tasks are too big for one session; split them into tickets.

In the tools
  • Claude CodeAutocompact is on by default and warns as context fills; you can turn it off in /config and run /compact by hand.
  • CodexThe CLI compacts long threads automatically as well; a new task is often the cleaner move.
In conversation

It was doing great and then suddenly started renaming things it had already renamed.

Check the transcript. Did the context get compacted a few turns back?

Yes, there's a notice I didn't see.

That's your culprit. Next time compact yourself before it hits the threshold, and write the file list down first.

Related terms
Learn it in the school
Words are the easy part

Course 01 puts every one of these terms to work: you install Claude Code, run the loop, and ship a real project — permission modes, compaction, hooks and all.

Start Course 01 →