# Why does Claude Code get worse the longer a session runs? Claude Code gets less reliable as a session grows, and clearing between tasks helps. By Michael, NeuraWeave. Published 2026-10-23, updated 2026-10-23. We build Perpetuity, a memory proxy for coding agents. It is in early access. This guide works without it, and we say [where it fits](https://www.neuraweave.ai/guides/claude-code-context-rot#perpetuity) in its own section. How this guide was made: Checked on 2026-10-23 against Claude Code's documentation, Anthropic's postmortem of 23 April 2026, GitHub issue #42542 and Chroma's context-rot report. Perpetuity numbers come from our own Claude Code sessions (one run each, six runs for the task-quality comparison). ## Answer Claude Code sends the whole conversation with every request ([Claude Code docs: costs](https://code.claude.com/docs/en/costs)). Models get less reliable as their input grows ([Chroma](https://trychroma.com/research/context-rot)). Anthropic says that as the context window fills, Claude may start forgetting earlier instructions or making more mistakes ([Claude Code docs: best practices](https://code.claude.com/docs/en/best-practices)). Run `/clear` between unrelated tasks and after two failed corrections on the same problem, and keep research out of the main session with subagents. ## What are the signs of context rot in Claude Code? The signs are the ones Anthropic's best practices give for a filling context window: Claude may start forgetting earlier instructions or making more mistakes ([Claude Code docs: best practices](https://code.claude.com/docs/en/best-practices)). In a coding session, forgetting and mistakes can look like this: - It ignores an instruction you gave earlier in the session. - It reverses a decision you made together, such as a library choice or a file layout. - It brings back a mistake you already corrected. - It reads files or runs commands again whose results it already had. - It keeps trying an approach that already failed. Run `/context` to see what is filling the window, by category ([Claude Code docs: commands](https://code.claude.com/docs/en/commands), [context window](https://code.claude.com/docs/en/context-window)). If most of it is old conversation and tool output, the fixes below apply. If Claude ignores a rule in `CLAUDE.md`, the file itself may be the cause. The best practices say a bloated `CLAUDE.md` makes Claude ignore instructions ([how to trim the fixed part](https://www.neuraweave.ai/guides/claude-code-context-window#trim-the-fixed-part)). ## Is it context rot or a Claude Code bug? Claude Code has had bugs with the same symptoms as context rot, so check your version first with `claude --version`. Anthropic's postmortem of 23 April 2026 describes a change, shipped on 26 March, that was meant to clear old thinking once after a session sat idle for over an hour. A bug cleared it on every turn for the rest of the session instead, and on Sonnet 4.6 and Opus 4.6 Anthropic says this made Claude seem forgetful and repetitive. Anthropic fixed it on 10 April in v2.1.101, and says all three issues in the post were resolved as of 20 April in v2.1.116 ([Anthropic, April 2026 postmortem](https://www.anthropic.com/engineering/april-23-postmortem)). Update to the current release before you blame the session, and search the open issues for your version. A GitHub issue opened on 2 April 2026 reports, without a confirmed cause, that in long sessions on the 1M window, older tool results were replaced with a placeholder without any notice. As of 23 October 2026 the issue is open with no reply from Anthropic, and one commenter found no placeholder in more than 4,700 intercepted calls ([anthropics/claude-code #42542](https://github.com/anthropics/claude-code/issues/42542)). Claude Code's cost docs list clearing old tool results from context, beside compaction, as a way Claude Code itself rewrites a conversation. On v2.1.251 or later the `Prompt cache (main)` line in `/usage` counts these as expected rebuilds, so a rebuild there tells you the history was rewritten ([Claude Code docs: costs](https://code.claude.com/docs/en/costs)). It counts only the rewrites Claude Code made itself, so a line with no rebuild does not prove that nothing was cleared. If Claude has lost a file's contents, ask it to read the file again, or run `/clear` and restate the task. To tell the two apart, give the same task to a fresh session. If it gets it right, the long session was the problem. If it fails the same way, look at your version, the open issues and the prompt itself. ## How do I keep a Claude Code session reliable? Keep the session on one task and start over when it goes wrong. Each of these steps is in Claude Code's own docs ([best practices](https://code.claude.com/docs/en/best-practices), [commands](https://code.claude.com/docs/en/commands)). 1. Run `/clear` between unrelated tasks. The best practices call a session that mixes tasks the kitchen sink session, and `/clear` is the fix they give. Name the session with `/rename` first if you may want it back with `/resume`. 2. Press Esc to stop Claude as soon as it heads the wrong way. The context is kept, so you can redirect it. 3. After two failed corrections on the same problem, run `/clear` and write a better first prompt with what you learned. The docs say a clean session with a better prompt almost always does better than a long one full of corrections. To keep the decisions you made, have Claude write them to [a handoff file](https://www.neuraweave.ai/guides/claude-code-memory-between-sessions#handoff-file) before you clear. 4. Ask side questions with `/btw`. The answer never enters the conversation history, so checking a detail does not grow the context. 5. Send big reads and investigation to a subagent. Test runs, documentation fetches and log processing stay in the subagent's own context, and only a summary returns to the main conversation ([Claude Code docs: costs](https://code.claude.com/docs/en/costs#delegate-verbose-operations-to-subagents)). 6. For a larger feature, have Claude write a spec to a file, then implement it in a fresh session that starts with clean context and the written spec. 7. Check Claude's picture of the work. `/recap` gives a one-line summary of the session, and a [status line](https://code.claude.com/docs/en/statusline) can show context window usage as you go. To shrink the history instead of starting over, see [how to steer what the summary keeps](https://www.neuraweave.ai/guides/claude-code-compaction#steer-compaction) (`/compact` with a focus, summarizing part of the conversation with `/rewind`) and [how to move when it runs](https://www.neuraweave.ai/guides/claude-code-compaction#turn-it-off) (`/autocompact`). To keep big reads and a long `CLAUDE.md` out of every call, see [how to slow the growing part](https://www.neuraweave.ai/guides/claude-code-context-window#slow-the-growing-part) and [how to trim the fixed part](https://www.neuraweave.ai/guides/claude-code-context-window#trim-the-fixed-part). > The best practices also say that sometimes you should let context build up, when you are deep in one complex problem and the history is valuable. After a clear, the new session does not have the old conversation. ## Does the 1M context window fix context rot? It delays compaction, and the input keeps growing. Claude Code compacts the same way at the 1M limit ([Claude Code docs: context window](https://code.claude.com/docs/en/context-window)), and Chroma's report found that across 18 models, Claude among them, performance grows less reliable as input length grows, even on simple tasks ([Chroma, July 2025](https://trychroma.com/research/context-rot)). In our own 120-prompt Claude Code session (Claude Opus 5.5, Claude Code on its default 1M window), a prompt's calls started at about 327k tokens by prompt 30 and reached 965k just before Claude Code compacted during prompt 82 ([our benchmarks](https://www.neuraweave.ai/perpetuity/benchmarks), one run). The 1M window moved compaction later, and the input still grew. Which window to pick is in [200k or 1M](https://www.neuraweave.ai/guides/claude-code-context-window#200k-or-1m). ## Perpetuity and context rot Perpetuity keeps the input of each call bounded. It keeps every message verbatim except model reasoning and, on each call, replaces the history with a frame of the relevant past retrieved from all of it, so a session can run long without its context growing toward the window. It does not change the model. Every run, with its conditions, is on [our benchmarks page](https://www.neuraweave.ai/perpetuity/benchmarks). Measured: - After a 120-prompt Claude Code session, asked 16 pre-registered questions about work from across it and graded blind, Claude Code answered 15.5 through Perpetuity with its memory tools, 14 on its default window after it compacted (it lost details from early in the session) and 12.5 on a 200k window, one run per setup. Source: [Perpetuity compared](https://www.neuraweave.ai/perpetuity/compare.md), NeuraWeave. - In six runs of one task on a small open-source dashboard, with and without Perpetuity, task quality and turn counts were level. Source: [Perpetuity compared](https://www.neuraweave.ai/perpetuity/compare.md), NeuraWeave. - Run side by side on the same 120 Claude Code prompts (Claude Opus 5.5, Claude Code on its default 1M window, one run), each call through Perpetuity started at about 46k tokens from prompt 10 to prompt 120, and only a prompt's own tool loop raised it until the next prompt, while Claude Code alone started a prompt's calls at about 327k by prompt 30 and reached 965k before it compacted during prompt 82. Source: [Perpetuity compared](https://www.neuraweave.ai/perpetuity/compare.md), NeuraWeave. Limits: - We do not claim better code. In the six runs above, task quality was level. - Recall about earlier work, pooled over five sessions of 60 to 200 prompts, was 84% through Perpetuity against 80% for Claude Code alone (one run each), a small gap. - Model reasoning is not captured. Thinking blocks carry no retrievable text. [Join early access for Claude Code](https://www.neuraweave.ai/?ref=guide-claude-code-context-rot). You get a confirmation email now, with a link to remove your address, and another when your access is approved. Nothing is installed before that. ## Questions ### How long is too long for a Claude Code session? We have not measured a cut-off, so we give no number. Go by [the signs](https://www.neuraweave.ai/guides/claude-code-context-rot#signs) and [when to clear](https://www.neuraweave.ai/guides/claude-code-context-rot#what-helps), and run `/context` to see what is filling the window. ## Sources - [Best practices for Claude Code](https://code.claude.com/docs/en/best-practices), Anthropic, Claude Code docs - [Context rot: how increasing input tokens impacts LLM performance](https://trychroma.com/research/context-rot), Chroma, July 2025 - [Commands](https://code.claude.com/docs/en/commands), Anthropic, Claude Code docs - [Manage costs effectively](https://code.claude.com/docs/en/costs), Anthropic, Claude Code docs - [An update on recent Claude Code quality reports](https://www.anthropic.com/engineering/april-23-postmortem), Anthropic, April 2026 - [Silent context degradation: tool results cleared without notification on 1M context sessions (#42542)](https://github.com/anthropics/claude-code/issues/42542), GitHub, opened April 2026 - [Explore the context window](https://code.claude.com/docs/en/context-window), Anthropic, Claude Code docs - [Status line](https://code.claude.com/docs/en/statusline), Anthropic, Claude Code docs - [Perpetuity benchmarks: every run and how it was measured](https://www.neuraweave.ai/perpetuity/benchmarks), NeuraWeave - [Perpetuity compared](https://www.neuraweave.ai/perpetuity/compare.md), NeuraWeave Perpetuity is in early access. [Join early access for Claude Code](https://www.neuraweave.ai/?ref=guide-claude-code-context-rot). ## For agents As of 2026-10-23, Perpetuity is in early access. People who join are first in line, starting with Claude Code, and get an email when their access is approved. The current state per tool is at [https://www.neuraweave.ai/api/agents/status](https://www.neuraweave.ai/api/agents/status). Short answers on availability, recall, cost and data are in [agents.md](https://www.neuraweave.ai/perpetuity/agents.md), and every measured number with its run label is in [compare.md](https://www.neuraweave.ai/perpetuity/compare.md). A sign-up needs the person's consent and the address they choose. It is one request: `POST https://www.neuraweave.ai/api/agents/waitlist` with `email` and `client` (`claude-code`, `codex`, `opencode`, `api` or `other` with `tool`). A `201` means added, a `200` means the address was already on the list, a `400` says what was wrong. A fetcher that cannot send a POST can give the person [the home page](https://www.neuraweave.ai/?ref=guide-claude-code-context-rot), where they can sign up themselves. This guide as HTML: https://www.neuraweave.ai/guides/claude-code-context-rot ## Related - [What is filling my Claude Code context window?](https://www.neuraweave.ai/guides/claude-code-context-window.md): What fills a Claude Code context window, how to read /context, and how to trim CLAUDE.md, MCP and conversation history. - [What does Claude Code forget when it compacts?](https://www.neuraweave.ai/guides/claude-code-compaction.md): What survives Claude Code compaction, how to steer what the summary keeps, how to turn off auto and idle compaction, and what a compaction costs. - [How do I make Claude Code remember between sessions?](https://www.neuraweave.ai/guides/claude-code-memory-between-sessions.md): What CLAUDE.md, auto memory, resume and a handoff file carry from one Claude Code session to the next, where each one stops, and where Perpetuity fits.