Loading lesson…
Long agent sessions degrade in predictable ways. Learn what context rot looks like, why it happens even with million-token windows, and the compaction discipline that keeps quality high.
Claude 4.7 has a million-token window. GPT-5 has 400k. You can hand them an entire codebase. They will read it. They will also forget half of it by the time they finish writing the answer. Long context is necessary, not sufficient — and it actively degrades reasoning quality past a point.
| Context used | Typical behavior | Quality |
|---|---|---|
| 0-30k tokens | Sharp, follows instructions, recalls everything | Best work |
| 30k-100k | Slight blurring of details from early turns | Still strong |
| 100k-300k | Mistakes earlier file contents, makes up function names | Mixed |
| 300k-1M | Confidently wrong about half of what you fed in | Roll the dice |
Attention costs scale roughly quadratically with context length. To stay tractable, models use various sparse attention tricks. These work great in benchmarks ("find the needle in the haystack") but degrade in real reasoning where you need to combine ten facts spread across the haystack. The model can still find each one. Combining them is harder.
# Mid-session compaction prompt for Claude Code, Cursor, Codex "Pause. Summarize this session into a working brief: 1. What is the goal? (one sentence) 2. What constraints have we agreed on? (bullets) 3. What files have we touched and how? (file -> change) 4. What is the current bug or open question? 5. What should NOT be touched? Return only the brief. I'll start a fresh session with it."The model writes its own handoff note. Then you start fresh and paste it in.A 200-line CLAUDE.md, AGENTS.md, or `.cursor/rules` file at the project root is read on every session. It survives compaction. It survives session resets. Anything you find yourself repeating to the agent — conventions, scripts, gotchas — belongs in that file, not in the context window.
# Session hygiene checklist (run mentally, every 30 min) 1. Has the agent forgotten any earlier constraint? -> compact + re-state it. 2. Are we still on the original goal? -> re-state goal, drop tangents. 3. Has the file state diverged from what the agent thinks it is? -> show `git status`, force re-read. 4. Is the agent repeating itself? -> compact and reset. 5. Have we been at this >1 hour with no commit? -> hard reset.A 30-second check that prevents most multi-hour disasters.Long context is a runway, not a destination. Land before you crash.
— An agentic systems engineer
The big idea: bigger context windows are a tool, not a free pass. Treat every session as a perishable resource. Compact aggressively, persist conventions in project-memory files, and start fresh when the agent's recall starts to slip. The work you save is your own.
8 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-debug-context-rot-creators
What is the main idea of "Context Rot — Why Long Sessions Get Stupid"?
Which concept is most central to "Context Rot — Why Long Sessions Get Stupid"?
Which use of AI fits this topic best?
What should a careful learner remember about "Recency bias is real"?
You want to use AI after this lesson. What is the safest next step?
How should AI output about context rot be treated?
Name one way to verify an AI answer about context rot.
Which action would help you apply "Context Rot — Why Long Sessions Get Stupid" responsibly?