Your personal memory, across sessions, agents, and devices.

What Is AI Context Drift? Why Long Agent Runs Degrade

memU Team memU Team

AI context drift is an agent's slow loss of its goal over a long session. As the session grows, it forgets constraints it was given early and starts acting on its own wrong guesses. No study gives a single failure rate for it. The causes are better documented. Studies show models get less reliable as input grows and as instructions spread over many turns. The fixes that work keep context short and write decisions to files outside the context window.

What is AI context drift, in one sentence?

AI context drift is the gradual loss of an agent's grip on its original instructions and settled facts as a session grows longer.

"Context drift" is an informal term. Researchers use narrower names for the parts of it. A 2025 Chroma report calls the length effect context rot. Anthropic's context engineering guide uses the same phrase and says context should be treated as a finite resource with diminishing returns. The guide, published in September 2025, is engineering advice. The measurements come from research.

How does context drift differ from running out of context?

A full context window fails loudly: the request errors or the tool compacts. Drift fails quietly while the window still has room.

Context window overflow Context drift Lost state between sessions
When it happens Input exceeds the model's limit Inside the limit, as input and turns grow When a session ends
What you see An error, or automatic compaction Ignored constraints, repeated mistakes, wrong assumptions The agent asks again what it already learned
Cause Hard token limit Uneven attention over long input, early wrong turns Nothing was written outside the session
Bigger window helps? Yes Not by itself. Longer input hurt in Chroma's tests No
Typical fix Compaction Shorter, focused context and notes Persistent memory files

Sources: Chroma's Context Rot report and Anthropic's context engineering guide.

What causes context drift?

Four things feed it, and length is the best measured. Chroma's Context Rot report, published July 14, 2025, tested 18 models from four model families. The authors found performance "grows increasingly unreliable as input length grows," even on simple tasks. On LongMemEval, models answered far better from focused prompts of about 300 tokens than from full prompts averaging about 113,000 tokens. Adding a single distractor also lowered accuracy. Oddly, models did worse when the filler text was in logical order than when it was shuffled.

Position matters too. The 2023 paper Lost in the Middle found a U-shaped curve. Models used information best when it sat at the start or end of the input, and worse when it sat in the middle. By that logic, an instruction from turn 3 of a 60-turn session ends up in the weak middle.

Spreading instructions over turns hurts as well. LLMs Get Lost In Multi-Turn Conversation ran over 200,000 simulated conversations. When instructions arrived over several turns, performance fell by an average of 39% across six tasks compared with a single full prompt. The authors trace most of it to unreliability. Models commit to early assumptions and, after a wrong turn, rarely get back on track.

The fourth is compaction, because long agent sessions eventually summarize themselves. OpenClaw's compaction docs are candid about it. When a summary degrades, they warn that older details and pending requests may leave the model's context. The docs add that facts which left the context after a failed summary are not restored by later compactions.

Does a bigger context window fix it?

Usually not. A bigger window only delays overflow, and the model still attends unevenly to what is in it. Chroma's LongMemEval result points the other way: the same models did better with less, well-chosen context.

Anthropic makes the same argument from engineering practice. Its guide describes an "attention budget" that every added token draws down. The goal it sets is the smallest set of high-signal tokens that does the job.

How do you reduce context drift in long-running agents?

Anthropic's guide lists three techniques for long tasks.

  1. Compaction. Summarize the conversation as it nears the limit and continue from the summary. Tune it for recall first, then precision. Clearing old tool results is the cheapest version.
  2. Structured note-taking. The agent writes notes to files outside the context window and reads them back later. A to-do list or a NOTES.md file is enough to start. Notes survive compaction because they live in files, outside the conversation.
  3. Sub-agents. A lead agent hands focused work to sub-agents with clean context windows. Each returns a condensed summary, often 1,000 to 2,000 tokens by Anthropic's estimate.

Two habits help on top of these. Restate the goal and hard constraints at the end of a long prompt, where position research says models attend well. Start a fresh session when the task changes, so new work begins with a clean history.

What does context drift mean for enterprise agent workflows?

Enterprise tasks rarely fit in one session: a contract review runs for days, and a migration spans many pull requests. Each session starts with what the agent can find on disk, plus whatever a person pastes in.

Within a session, the fix is short context and decisions written down as they happen. Across sessions, those written notes are the only state that carries over.

The bottom line

Expect context drift in any long session. Keep prompts focused and start a new session for each task. Have the agent write decisions to files as it works. A bigger window will not fix drift, since Chroma's models got worse as input grew.

How do you keep agent context from drifting across sessions?

Only what the agent wrote outside the context window survives compaction and the end of a session. Most hosts now support some form of note file, such as CLAUDE.md or AGENTS.md. Each host reads its own file by default, so Codex does not see what Claude Code wrote.

memU is built around structured note-taking. A scheduled background task slices new session logs from each host into jobs. The agent decides what is worth keeping and writes it as memory or skill Markdown. memU itself makes no LLM or chat calls. It stores and retrieves what the agent prepared.

A standing instruction in CLAUDE.md or AGENTS.md tells the agent to retrieve before answering. Each new session then starts from a short set of relevant notes. All hosts share one backend, so a decision recorded from Claude Code can be retrieved in Codex. Because the notes are readable Markdown, you can fix a wrong one before it spreads.

To try the hosted version, which is free and syncs across devices, get an API key from memu.so and send your agent one message:

Read https://memu.pro/SKILL.md, follow its instructions to install and configure memU, API Key is YOUR_MEMU_API_KEY.

The self-hosted setup is in the memU GitHub repository. For why memU leaves the judgment to the agent, see memU gives memory back to the agent.

FAQ

What is context rot in LLMs?

Context rot is the drop in reliability as a model's input grows longer, even when the task stays simple. Chroma measured it across 18 models in a July 2025 report.

Is context drift the same as hallucination?

No. Hallucination is one possible result of drift. A drifting agent can also ignore an early instruction or repeat a mistake it was already corrected on.

Does compaction stop context drift?

It extends a session and loses some detail with each summary. Notes written to files outside the conversation survive it.

How much does accuracy drop in long conversations?

In one study of over 200,000 simulated conversations, models scored 39% lower on average when instructions were spread across turns. The size of the effect depends on the task and model.

What is the best fix for context drift?

Keep context short and focused, and have the agent write decisions to persistent notes it reads back later. Anthropic calls this structured note-taking.