Context Degradation Benchmark: The Long-Context Weakness of Leading LLMs

An open-source benchmark quantifies LLM long-context degradation, exposing the gap between advertised window sizes and real-world retrieval ability.
"Context degradation" describes how LLMs gradually lose the ability to retrieve and use earlier information as input length grows. The open-source project `context-degradation-benchmark` uses Jupyter Notebooks and paradigms like Needle in a Haystack and multi-hop reasoning to compare Claude Opus, GPT-Codex, and GPT-4o on long-context tasks. The article highlights the significant gap between vendors' advertised context windows and actual retrieval performance at the window's end, noting that most models are weakest in the middle—the "Lost in the Middle" effect. Developers building RAG systems or long-document apps are advised to run their own degradation tests and apply context compression, summarization, or chunked retrieval strategies.
What Is Context Degradation
Large language models don't always perform consistently when handling long contexts. As input accumulates—whether it's conversation history, a codebase, or a lengthy document—a model's ability to retrieve and utilize information from earlier in the context gradually declines. This phenomenon is known as "context degradation."
An open-source project on GitHub called context-degradation-benchmark (by author kyleaoconnell22) attempts to quantify this problem in a reproducible way. The project uses Jupyter Notebooks to compare several leading models in long-context scenarios, including Claude Opus, a Codex variant from the GPT family, and GPT-4o.

For real-world applications that depend on long-context capability—such as code assistants that need to understand an entire repository, or document Q&A systems that retrieve across tens of thousands of tokens—context degradation directly determines the ceiling of a product's usability. A vendor's advertised "million-token context window" is one thing; whether the model can still accurately recall information near the end of that window is quite another. This is precisely where benchmarks like this one reveal the gap between the two.
What the Benchmark Measures
Judging by the project's name and comparative design, the core goal of this type of benchmark is to measure the performance degradation curve as context length increases—not simply the static metric of "how long a context is supported."
Typical context degradation tests involve several paradigms: the "Needle in a Haystack" test, which embeds specific information within a long document and checks whether the model can accurately retrieve it at various positions; multi-hop reasoning, which requires the model to synthesize information scattered across multiple points in the context; and tracking whether early instructions are gradually forgotten or diluted as conversation turns accumulate.

Putting Claude Opus, GPT-Codex, and GPT-4o under the same testing framework helps developers determine which model delivers more reliable long-context performance for their specific use case. Differences in attention mechanisms, positional encoding, and training data distribution often cause models to show distinct strengths and weaknesses at different points along the long-context spectrum.
The "Needle in a Haystack" test was proposed and popularized by Greg Kamradt in late 2023. The approach involves inserting a context-irrelevant "target sentence" at random positions within a long document, then asking the model to recall its content. This produces a 2D heatmap of position × context length, visually showing retrieval success rates across different regions. Positional encoding is a key factor: schemes like RoPE and ALiBi differ significantly in their ability to extrapolate beyond training lengths, and some models experience positional encoding failures near the end of the context window, causing attention weight disruption. The length distribution of training data also matters—if a model's pretraining corpus rarely contains samples exceeding 32K tokens, performance in that range tends to be unstable even after window extension via positional encoding. This explains why two models that both claim to support 128K context can perform dramatically differently on real long-text tasks.
Why Open-Source Benchmarks Like This Matter
Official evaluations published by model vendors are inherently susceptible to selection bias in favor of their own products. Third-party, reproducible open-source benchmarks fill exactly that gap. The advantage of publishing as a Notebook is that anyone can clone the code, swap in a different model, adjust test parameters, and re-verify the conclusions on their own data—rather than having to take the author's word for it.
It's worth noting that this project is still in a very early stage—both Stars and Forks are at 0, and it remains an individual exploratory effort. It's better thought of as a useful testing scaffold than an authoritative leaderboard validated by a large community. The model version numbers referenced in the project (such as Opus 4.6 and GPT-5.2-Codex) should also be cross-checked by readers against the models actually available to them.
Practical Takeaways for Developers
Regardless of the specific numbers, context degradation itself is a well-documented and repeatedly confirmed problem. For teams building RAG (Retrieval-Augmented Generation) systems, code agents, or long-document processing applications, here are some practical recommendations:
Don't blindly trust marketing claims about "ultra-long context windows"—always run degradation tests on your own real data. For critical information, consider placing it at the beginning or end of the context rather than burying it in the middle (most models perform worst at retrieving information from the middle, a phenomenon known as "Lost in the Middle"). In long conversation or long-document scenarios, proactively apply context compression, summarization, or chunked retrieval to reduce the burden on the model.
The value of open-source benchmarks like this isn't in producing a definitive ranking—it's in providing a methodology you can run yourself. When you're facing a real model selection decision, a test script that runs in your own environment is far more convincing than any vendor's marketing chart.
The "Lost in the Middle" phenomenon was systematically validated in a 2023 paper of the same name by Nelson Liu et al. at Stanford. Their experiments showed that when critical information is positioned in the middle of a long context, the model's question-answering accuracy drops significantly compared to when it's placed at the beginning or end—and this effect grows stronger as context length increases. The underlying cause is the "recency and primacy bias" of the Transformer attention mechanism: models tend to assign higher attention weights to tokens at the start and end of a sequence, while middle-segment information receives sparser gradient signals during backpropagation, forming a structural retrieval blind spot after long-term pretraining. If RAG systems ignore this effect during the reranking stage, even correctly retrieved documents may lead to degraded final answers depending on how they're ordered in the assembled context. For this reason, placing the most critical constraints or reference content at the front of the prompt is currently the lowest-cost mitigation strategy at the prompt engineering level.
Related articles

Geopolitical Bias Compared Across Three AI Models: GPT-5.2, Claude, and Qwen Tested
An open-source project compares GPT-5.2, Claude Opus 4.6, and Qwen 3.5 Plus on sensitive Greek geopolitical topics. We break down its methodology, limitations, and why LLM neutrality audits matter.

Sam Altman: An IPO in the Near Term Would Be 'Ill-Advised' for OpenAI
OpenAI CEO Sam Altman tells Fortune that an IPO in the near term would be "ill-advised," while also addressing recursive self-improvement risks and the Hugging Face hack.

AI Coding Model Benchmark Tool: GPT-5.3 Codex vs. Claude Opus 4.6 — Which One Wins?
The open-source project ai-coding-benchmark-zyt benchmarks GPT-5.3 Codex vs. Claude Opus 4.6. This article explores its methodology, value, and developer guidance.