KognitaKognita.

Blog

After /compact, Claude Code Forgets the Corrections You Just Made

10 min read

You have hit it if you have run a long Claude Code session: things go well for a while, then the agent gets noticeably worse. It re-violates a rule you corrected, re-reads a file it already read, asks about something you settled an hour ago. As one user put it, "Claude Code is definitely dumber after the compaction — it doesn't know what files it was looking at and needs to re-read them." That moment is auto-compaction, and the corrections you made are among the first casualties.

What compaction actually does

When the context window approaches its limit, Claude Code does not just truncate — it clears old tool outputs and summarizes the conversation into a digest so work can continue:

A lossy digest, by design
What /compact does near the limit

  1. clears older tool outputs first (the files Claude read)
  2. then summarizes the conversation into a digest
  3. preserves "key code snippets"; drops "detailed instructions
     from early in the conversation"

  The summary is lossy on purpose. The casualties are exactly
  the things you said early and assumed were settled.

The docs are honest about the tradeoff: key code snippets are preserved, but detailed instructions from early in the conversation may be lost. That is the crux. The corrections you gave early — the ones you assumed had become permanent rules for the session — are precisely the "detailed instructions from early" that the summary is allowed to drop.

The casualties are the things you settled

The frustrating pattern is specific: the corrections that survive in your memory do not survive in the agent's:

Followed perfectly before, re-violated after
The corrections that don't survive

  Before compaction:
    -> "use async_session, not db_session"  (you said it twice)
    -> "the prod path is QueryService, ignore the legacy repo"
    -> Claude is following all of it

  After auto-compact at ~95%:
    -> re-violates the rule you corrected
    -> re-reads files it already read this session
    -> asks again about something you settled an hour ago

A user described it exactly: "The assistant follows these rules perfectly before compaction, then violates them 100% of the time after." The model is not being careless — the instruction it was following is simply no longer in its context. This is a sharp instance of an agent operating on the wrong recollection of state.

Re-explaining is not a fix

The workaround everyone converges on is to re-explain: paste the rules back, point at the files again, or stuff more into CLAUDE.md hoping it sticks. Re-explaining works for a few turns, then the window fills and compaction runs again, and you are back to re-explaining. You are using your own attention as the agent's long-term memory, on a loop. It does not scale past the first long task of the day.

Stuffing it into CLAUDE.md helps a little — the project-root file is re-injected after compaction — but that only covers the handful of global rules small enough to live there. The session-specific knowledge, the files in play, the reasoning so far, is gone.

Durable grounding survives compaction

The deeper issue is treating the conversation as the agent's memory. Anything that lives only in the thread is subject to the summarizer. Move codebase knowledge out of the thread and compaction can no longer erase it:

What lives in the thread is summarizable; what lives outside is not
Conversation memory vs. durable grounding

  Conversation-as-memory (today):
    -> facts live in the thread; compaction summarizes them away
    -> "settled" only until the window fills
    -> survival depends on what the summarizer kept

  Durable external grounding (Kognita):
    -> codebase truth lives outside the conversation
    -> re-retrievable after every compaction, intact
    -> compaction can't summarize away what isn't in the thread

When the facts about your code are retrievable from an external, always-current source, a post-compaction agent re-grounds itself in seconds instead of re-reading from scratch and re-asking you. The conversation can be lossy, because the conversation was never where the truth lived. This is the case for why a bigger context window does not solve this— the window always fills; what matters is what you can recover when it does.

Where Kognita fits

Kognita keeps your codebase representation in a continuously updated semantic index the agent queries through MCP, independent of the conversation window. When /compact summarizes the thread away, the codebase truth is still one retrieval away — the current file structure, the real conventions, the service boundaries — so the agent does not get "dumber" about the code just because the chat got long. Compaction stays a window-management detail instead of a knowledge-loss event.

Final take

/compact keeps a long session alive by throwing away detail, and the detail it throws away includes the corrections you thought were permanent. Re-explaining buys a few turns before the next compaction takes them again.

If the agent's only memory is the conversation, every compaction is amnesia. Keep the codebase truth outside the thread and the agent can re-ground itself instead of asking you to.