# Compaction (/academy/compaction)



Picture your whole hackathon plate. The stack picked in the [builder](/builder). The CORS fix. The todo schema. The Polar webhook tangent. The error paste from line 47. Now dump all of it in a blender and hit go.

Technically it is still your project. Same ingredients, all in there. But it is very much not the same thing, and you cannot un-blend it.

That is **compaction**.

The model thinks inside a [context window](/academy/context-window) — one room, measured in [tokens](/academy/token). Everything you have said this [session](/academy/session) is stacked in that room. When the room fills up, the host cannot keep cramming. To stay alive, it takes the early part of the conversation, crushes it into a short summary, and carries on with that recap instead of the full history.

**The gist survives. The detail turns to mush.**

**The tell is a personality change.** The [agent](/academy/agent) was sharp — locked on Hono, remembered the env var name, knew which file you meant. Then it compacts and goes vaguer. Slightly off. Reaching for the right answer and grabbing a close-enough one. It did not get dumber. It is working off the blended version now.

When compaction runs, the model decides what is worth keeping. Not you. It scans hours of back-and-forth, writes its own recap of "what we were doing," and the one detail you actually cared about can quietly disappear into the blender.

I try never to let a session compact on its own.

The second I see the room filling up, I stop. I do not wait for the blender to kick on. Instead I:

1. Start a fresh [session](/academy/session) so I get a clean, empty room.
2. Write a quick handoff of what actually matters: what we are building, what is decided, what is left to do.
3. Paste that into the new chat and pick up exactly where I was — detail intact, because *I* chose what to keep.

A few things worth knowing so this does not catch you out:

* **It often happens silently.** Some tools announce "compacting now." Many just do it. If a long chat suddenly feels foggy, compaction is your first suspect.
* **Bigger rooms delay it; they do not cancel it.** A mansion fills slower than a studio apartment, but a long enough conversation fills anything.
* **A handoff beats a summary every time**, because you decide what survives instead of letting the model guess.

Put facts in files the agent can reopen — not in a joke from Tuesday. [Prompt caching](/academy/prompt-caching) keeps stable prep warm; compaction throws early turns into a smoothie. Different tools, same lesson: the room has limits.

**When the model compacts, it holds the pen. When you start fresh with a handoff, you hold it.**
