Engineering Guide

Context Rot: Why LLMs Degrade Long Before the Window Fills

A 1M-token window is not 1M tokens of usable attention. In July 2025 Chroma Research ran 18 frontier models through 194,480 calls and found the same thing in every one: reliability falls as input grows, long before the window is anywhere near full — and how information is arranged matters more than whether it is present. This is the phenomenon Chroma named "context rot." This guide explains the mechanism, the specific failure modes Chroma isolated, why the needle-in-a-haystack test gives you a false all-clear, and a matrix mapping each cause to the fix that removes it.

Context rot — model reliability falls as input tokens grow, long before the context window is full

The short answer

A context window is the maximum you can pass, not the amount the model uses well. In July 2025 Chroma Research published Context Rot: How Increasing Input Tokens Impacts LLM Performance, testing 18 models across 194,480 LLM calls, and found that every model degrades as input length grows — well before the window fills. The degradation is driven by input length, distractors, how closely the target fact matches the query, and how the surrounding text is structured. "Context rot" is Chroma's coined term for this, echoed by Anthropic, and it reframes long context from a capacity number into an engineering constraint.

How this is sourced. The primary source is Chroma Research's July 2025 study (research.trychroma.com/context-rot). The mechanism draws on Anthropic's Effective context engineering for AI agents and Liu et al.'s Lost in the Middle (Stanford, 2023-2024). Cost and safe-budget figures are directional practitioner estimates, flagged inline. The model list reflects the 18 models tested as of July 2025 and may be superseded by newer releases.

Why the window lies

The marketing number is capacity; the useful number is attention. Anthropic frames the cause plainly: a model has a finite attention budget, and "every new token introduced depletes this budget." Transformer attention requires every token to attend to every other token, which creates n-squared pairwise relationships — 1,000 tokens is a million pairs, 100,000 tokens is ten billion. As the context grows, that finite budget gets stretched thin. Anthropic explicitly acknowledges the effect: "as the number of tokens in the context window increases, the model's ability to accurately recall information from that context decreases." Part of the reason is that training data skews toward shorter sequences, so models see far fewer long-context examples in training.

Position compounds length. Liu et al.'s Lost in the Middle established a U-shaped curve: accuracy is highest when the key information sits at the very start or the very end of the input, and degrades by more than 30% when the same fact is buried in the middle — replicated across multiple model families. So two identical prompts carrying the same fact can score very differently based only on where the fact sits. That is the first hint that presence is not usability, and it is why anyone tempted to dump their whole knowledge base into a large Claude context window should treat the window size as a ceiling, not a promise.

What Chroma actually found

Chroma extended the classic needle-in-a-haystack setup along the axes that resemble real work, running 8 input lengths and 11 needle positions with over 99% agreement between LLM-based and human judgment. Four results stand out:

The through-line: models do not use their context uniformly, and how information is presented matters more than whether it is present. That single sentence is the whole finding.

How each factor amplifies degradation at long contextIllustrative shape of the effect — not Chroma's measured numbers; real curves are non-uniform and task-dependent.Clean single needlelowBuried in the middlehigherDistractors presenthighLow query similarityhighest
Chart: DataLLM Lab — an illustrative ranking of how much each condition Chroma isolated amplifies degradation as input grows. Bars show the shape of the effect, not Chroma's reported accuracy figures, which range from single digits to roughly 80% depending on task, model, distractors, and position.

Why NIAH is a false all-clear

The benchmark that reassures teams is the wrong test. A classic needle-in-a-haystack run hides one distinctive sentence in filler and asks the model to find it. Models pass this handily even at a million tokens, and vendors quote that as proof long context "works." It is the version of the problem models are best at: a single, verbatim, high-similarity needle with no competing candidates.

Chroma's contribution is showing how quickly that all-clear evaporates. Introduce distractors, weaken the wording match, require joining two or three facts, or bury the target mid-document, and accuracy falls — sometimes steeply. Real workloads are the hard version by default: support histories full of near-duplicate tickets, codebases where the relevant function looks like ten irrelevant ones, contracts where the operative clause is phrased nothing like your question. So a green NIAH result tells you the floor is fine and says almost nothing about the ceiling you actually operate at. This is the same trap behind unreliable recall in retrieval systems, and it feeds directly into hallucination — a model that silently grabs the wrong-but-similar passage will state it with full confidence.

Test the failure modes on your own data

Context rot is model-specific and task-specific. With 300+ models on one OpenAI-compatible key, run the same long-context eval — with distractors, at the length you actually use — across Claude, Gemini, Qwen and more, and keep whichever holds up.

Causes, symptoms, and fixes

Most write-ups either restate the headline ("performance drops with length") or list generic RAG tips. The useful move is to connect each cause Chroma isolated to the symptom you see and the specific fix that removes it. The fixes map cleanly onto Anthropic's context-engineering techniques:

CauseSymptom you seeFix that removes itMaps to
Raw input lengthRecall drops even below the window limitRetrieve, don't stuff; compact long historyJust-in-time retrieval
DistractorsModel returns the plausible-but-wrong passageRerank to strip near-duplicates pre-generationReranking
Low query similarityMisses loosely-worded matchesHybrid retrieval + query expansionRAG design
Position (mid-context)Buried facts and instructions ignoredPut key info at the start or endLost in the Middle
Haystack coherenceLong coherent docs distract moreChunk into focused, task-scoped contextSub-agents
Output / replication lengthInconsistency grows as output scalesCompact and reinitialize near the limitCompaction

Reranking earns the highlight because it targets the single nastiest failure — distractors — that raw retrieval and bigger windows both leave untouched. A cheap model such as DeepSeek V4 Flash makes a serviceable reranker so you narrow a pre-filtered top-k down to the passages that matter before your flagship ever sees them. For the retrieval side of this table, best LLM for RAG covers how grounding-heavy workloads reward different models than open-ended chat, and best LLM for summarization covers the closely related case where you must compress a long source without losing the middle.

Retrieve, stuff, or compact?

The decision rule falls out of the table. Retrieve when the task needs a handful of relevant passages out of a large corpus — which is most of the time. Retrieval keeps the working context short and focused, which is exactly the regime where models are reliable, and it is far cheaper: 2025-2026 RAG reviews put long-context stuffing at roughly 8-82x more expensive than retrieval for typical workloads. Treat that range as directional, not an exact benchmark. Stuff the whole document only when the task genuinely needs global coverage — a full-contract review, a single long transcript — and you have verified accuracy holds at that length on your own eval. Compact when a session or agent history keeps growing: summarize the older turns and reinitialize before you drift into the rotting zone, rather than letting the transcript balloon.

How much room do you actually have? Practitioners estimate the high-accuracy zone for 2M-window models at roughly 150K-400K tokens — well below the marketed limit. That figure comes from secondary practitioner blogs, not Chroma's paper, so use it as a rule of thumb to provoke your own measurement, not a hard line. The durable habit is to eval at the length you actually run at, with realistic distractors, because the number is model-specific and moves with every release. This is the same discipline that separates a real coding-cost benchmark from a vendor slide: measure on your data, not the marketing. A gateway makes that a config change — point the same long-context eval at Claude Opus 4.8, Qwen3 Coder Next, or GLM-5.2, and keep whichever resists rot best on your task, at your length.

FAQ

What is context rot?

The term Chroma Research coined in July 2025 for how models get less reliable as input grows — even far below the window limit. Across 18 models and 194,480 calls, every one degraded, and arrangement (position, distractors, query similarity) mattered more than mere presence.

Does a bigger context window fix it?

No. The window is the maximum you can pass, not the amount the model uses well. Degradation begins before the window fills. Practitioners peg the high-accuracy zone for 2M-window models at roughly 150K-400K tokens — a rule of thumb, not a Chroma measurement.

Why doesn't passing needle-in-a-haystack prove long context works?

NIAH hides one distinctive fact in filler — the easiest version. Add distractors, lower query similarity, or require multi-fact reasoning and accuracy drops sharply. Real workloads look like the hard version, so a green NIAH result overstates true long-context ability.

What actually causes the drop?

Chroma isolated input length, distractors, low needle-question similarity, and haystack structure. Liu et al. add a positional U-curve — over 30% worse when key info is mid-context. Anthropic ties it to a finite attention budget spread over n-squared token pairs.

Is retrieval better than stuffing long context?

For most workloads, yes. Retrieval keeps the working context short and focused — the reliable regime — and is far cheaper; 2025-2026 reviews cite roughly 8-82x savings, directionally. Stuff the whole document only when the task needs global coverage and you have verified accuracy at that length.

What can I do about it in my own app?

Retrieve instead of stuffing, rerank to strip near-duplicate distractors, put key instructions at the start or end, compact long histories near the limit, and split work across focused sub-agent contexts. These map onto the exact failure modes Chroma isolated.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.