Long sessions that jump between topics get worse over time: the model misses details, mixes old and new information and starts to make things up. The fix is simple: one task per session, and a fresh start when a session goes sideways. This applies to a chat and to a coding agent alike, but an agent hits the limit much sooner.
Why fresh sessions are cheap
Starting over does not mean losing what you learned. In Claude Code, CLAUDE.md and auto memory load into every new session. In the Claude chat apps, a project’s instructions, files and project memory carry into every new chat of that project. Rules that must hold go into CLAUDE.md or the project instructions; the summary you paste covers the rest.
When to use it
- You are about to start something unrelated to what the session has been doing.
- You have corrected the agent twice on the same issue and it is still wrong.
- The agent ignores an instruction you gave early in the session.
- Answers get vaguer, or the agent refers to code that is no longer there.
How to do it
- Scope the session to one task before you start: “fix the failing checkout test”, not “fix the test, then look at the logging, then the README”.
- Watch the context. In Claude Code, run
/contextto see how full the context window is and what is filling it. - Between unrelated tasks, clear. In Claude Code,
/clearstarts a new conversation with empty context. In a chat app, open a new chat. - When a session drifts, restart with a summary. Write (or ask the agent to write) a few lines: the goal, what was tried, what failed, what you learned. Start a new session and paste it in. A clean session with a better prompt usually beats a long one full of failed attempts.
- If you need to keep going on the same task, compact instead of clearing:
/compactsummarizes the conversation so far, and you can tell it what to keep (/compact focus on the API changes). - If the agent went the wrong way,
/rewindback to before the detour instead of correcting it turn after turn. More habits like this are in Managing context.
Example
You ask the agent to fix a flaky test. Halfway through, you ask it about an unrelated logging question, then go back to the test. Now the context holds two topics, and the agent starts suggesting logging changes in the test fix. Instead:
Goal: make checkout.test.ts pass reliably.
Tried: increasing the timeout (did not help).
Found: the test depends on the order of two async calls in createOrder().
Next: make the order deterministic, then run the test 20 times.Run /clear, paste this summary, and continue.
Common mistakes
- The kitchen sink session. Mixing several tasks in one session fills the context with irrelevant information.
- Correcting over and over. Each failed attempt stays in the context and pulls the next attempt toward it.
- Relying on early instructions. When the window fills, compaction can drop details from the start of the conversation. Put rules that must stick in CLAUDE.md.
Related
- Context window: why long sessions degrade.
- Agentic loop: why an agent session fills up faster than a chat.
- Coding agent vs chat assistant: the limits both share.
- Managing context: the everyday habits that go with this rule.
- Auto memory and Claude projects and memory: what carries over into a new session or chat.