Compaction
When an AI agent's conversation gets too long, the tool shrinks it into a summary, and details can get lost.
What it is
An agent can only hold so much conversation at once. Every message, file it reads, and command it runs takes up space in that working memory. When it nears the limit, the tool does compaction: it summarizes the history and drops bulky details to make room.
The catch is that a summary is lossy. Early instructions, a careful plan, or a rule you gave an hour ago can quietly vanish, and the agent starts drifting. You can trigger it yourself (in Claude Code, the /compact command) or wipe the slate (/clear) when you start something new.
Put anything that must survive in a file the agent rereads, like a rules file or a spec, not just in chat. Keep one feature per session where you can.
Compaction is not a checkpoint. A checkpoint restores your code, while compaction shrinks the agent's memory of the conversation. Tokens are the unit of measure. Compaction is what happens when you run low.
How to ask for it
“The AI was following my plan an hour ago but now it keeps ignoring it. Why did it forget?”
“Before we continue, save the plan and the constraints we agreed on into a spec file in the repo. Then run compaction and reread that file, so the instructions survive the summary.”
"Why did it forget" is a mystery to chase; "compaction" names the cause, and the prompt moves the important instructions into a file the summary cannot erase.
You've seen this in
- CThe "Compacting conversation..." message in Claude Code
- CRunning /clear in Claude Code before starting a new feature
- CStarting a new chat in ChatGPT when a very long thread starts getting confused