Answers

Hour four. The agent has quietly stopped being good.

It repeats work you already did. It forgets the rule you gave at hour one. Nothing announced the change, so you assume it is you.

Last updated

The model did not get worse. The conversation got full, and the older parts of it were summarised to make room. What went into the summary is not what you would have chosen.

That summarising is called compaction. It runs automatically, it runs silently, and the first thing it costs you is the detail from early in the session, which is exactly where you put the instructions.

There is a table below of what survives it, from the documentation. Then the honest answer about what to do, which is mostly about restarting rather than about lasting longer.

It is not just you

"The agent's effectiveness visibly degrades as the window fills: It re-reads files it already read, and repeats earlier mistakes."

claude-code issue #68294, a request to let the agent notice its own degradation. Closed as not planned.

"Claude asks 'what are we working on?' after every compaction, sometimes multiple times per session."

claude-code issue #25999, titled "Persistent state across context compaction". Closed as not planned.

The same report puts the cost in one line: "Per-step cost rises while quality drops." You pay more for worse, and the change is invisible from inside the conversation.

Why it happens

A context window is finite. Everything competes for it: your conversation, the files that were read, the command output, the instruction files, the skills. When it gets close to full, the older conversation is compressed into a summary.

The vendor documents which way the loss goes:

"Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost."

code.claude.com, How Claude Code works

Early and detailed. That is the description of every rule you set up at the start of a long session.

From the official context-window documentation, read 2026-08-21.
What survives compaction, by the mechanism the instruction was loaded through
What you loadedAfter compaction
System prompt and output styleUnchanged
Project-root CLAUDE.md and unscoped rulesRe-injected from disk
Auto memoryRe-injected from disk
Rules scoped to file pathsLost until a matching file is read again
Nested CLAUDE.md in subdirectoriesLost until a file there is read again
Invoked skill bodiesRe-injected, capped, oldest dropped first
Your conversationSummarised

Read the table twice. A rule in your project-root instructions file comes back after compaction. The same rule in a subfolder, or scoped to a file pattern, does not come back until something re-triggers it.

And nothing on that table is your work. Not the decision you made at hour one, not the approach you rejected at hour two, not the task that is 80 per cent done. Those lived in the conversation, and the conversation is the thing being summarised.

The fix, with any tool

The habit that works is unpopular, because it sounds like giving up: stop trying to make the session last, and make restarting cheap.

1. Write the state down before you need it

Every half hour or so, put the current state somewhere outside the chat. What is decided, what is in flight, what is next. People do this with a SESSION.md they keep updating. It looks like overhead until the first time it saves you two hours.

2. Compact on purpose, with a focus

You do not have to wait for the automatic pass to guess what matters. Running compact with instructions, such as focusing on the auth work, keeps what you choose rather than what it guesses. Clearing between unrelated tasks is the same idea, applied earlier.

3. Put the rules where they come back

This one is free and most people do not know it. A rule in your project-root instructions file is re-injected after compaction. The same rule in a nested folder or behind a file pattern is not, until a matching file is read again. If a rule must survive, move it to the root file. That is straight from the table above.

4. Restart earlier than feels necessary

The moment you notice repetition is already late. A fresh session that opens with a written state beats a four-hour session running on a summary of itself.

What that looks like as machinery

Mission HQ makes step one and step four automatic. What it changes is the cost of restarting, and it changes it a lot.

The work state is never in the conversation

Tasks, the decisions behind them, the warnings and the next step are records on a server. Compaction summarises a conversation. It cannot reach a record, because the record was never in the window.

Restarting costs one call

A new session asks for the handoff and gets back the current state, the single next action, and the warnings. That is the whole restart. No archaeology through a summary, no re-explaining the architecture to a fresh window.

The rules arrive with the task, not at the top of the session

Conventions and past lessons are delivered when a task of that kind starts, which means they arrive fresh rather than sitting at the far end of a long conversation waiting to be summarised.

Nothing in flight depends on the session ending well

Checkpoints are posted on every prompt and at the end of every turn. The 80-per-cent-done task that compaction wipes from the conversation is still a task with a status.

Make restarting cheap enough to do often

14 days, no credit card. Connect the editor you already use and restart a session on purpose.

What this changes, exactly

Be clear about the shape of it, because it decides whether this is useful to you. What changes is the cost of a restart. A session that has been running for four hours still fills up, still compacts, still drifts. That is the context window doing what a context window does.

What changes is that a restart stops being expensive. When the state is a record instead of a memory of a conversation, ending a rotted session is a decision you can make in a second, several times a day, without losing anything. The reason people push a bad session to hour six is that starting over used to cost them the morning.

So the advice on this page is the same advice with the price removed: restart early, restart often, and pick up exactly where you were.

Questions people ask about this

Why does Claude Code get worse the longer a session runs?

+
Because the context window fills up and the older conversation is compressed into a summary. The documentation says your requests and key code snippets are preserved while detailed instructions from early in the conversation may be lost, which is where most people put their rules.

What is compaction and when does it happen?

+
Compaction is Claude Code summarising the conversation history so it fits the context window. It runs automatically as you approach the limit, and you can also run it yourself with a focus, such as compacting around the auth work, so it keeps what you choose instead of guessing.

What survives compaction and what is lost?

+
The system prompt is unchanged. Your project-root CLAUDE.md, unscoped rules and auto memory are re-injected from disk. Rules scoped to file paths and nested CLAUDE.md files are lost until a matching file is read again. The conversation itself is summarised, which includes your decisions and in-flight work.

How do I stop my agent forgetting rules in long sessions?

+
Move the rule to the project-root instructions file. The documentation says root-level instructions and unscoped rules are re-injected from disk after compaction, while path-scoped rules and nested files are not until their trigger file is read again. That single move is free and fixes the most common case.

Does Mission HQ stop the agent degrading in a long session?

+
No. A context window fills up and compacts whatever you use. What Mission HQ changes is the price of restarting: the work state lives on a server rather than in the conversation, so ending a drifting session and opening a fresh one costs one call instead of a morning of re-explaining.

Is it better to compact or to start a new session?

+
Start a new session, if starting one is cheap. Compaction keeps you in a window that is already crowded. A fresh session with the state written down somewhere durable gives the model room and gives you the same starting point.

Two things you can do now

Move one rule, free, right now

Find a rule your agent keeps dropping late in a session. Check where it lives. If it is in a nested instructions file or scoped to a file pattern, move it to the project-root file, where the documentation says it is re-injected after compaction. Then run a long session and see if it holds.

No account. One file move.

Or make the restart free

Start a 14-day trial, no credit card. Keep the state on a server, then end a drifting session whenever you want and open the next one on the same work.

Start free trial

Related answers