Diagnose and Mitigate Context Degradation
A context-degradation skill naming lost-in-middle, poisoning, distraction, confusion, and clash failure patterns in long agent contexts.
Why it matters
Understand and address predictable performance degradation in language models as context length increases. This skill helps diagnose failures and design more resilient AI systems.
Outcomes
What it gets done
Identify context degradation patterns like lost-in-middle, poisoning, distraction, confusion, and clash.
Debug unexpected agent performance drops during long conversations.
Evaluate context engineering choices for production systems.
Mitigate degradation through architectural patterns like compaction and partitioning.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-context-degradation | bash Overview
Context Degradation Patterns
A context-degradation skill naming five failure patterns - lost-in-middle, poisoning, distraction, confusion, and clash - with empirical thresholds and mitigation strategies. Use it when agent output quality drops unexpectedly in long conversations or when designing systems that must stay reliable as context grows.
What it does
Context Degradation Patterns is a skill for diagnosing why language models get worse as context length grows, treating degradation as a continuum rather than a binary state. It names five distinct failure modes. Lost-in-middle causes information in the center of context to receive less attention because models allocate a large attention budget to the first token as an "attention sink" to stabilize internal state, leaving middle tokens under-attended - research shows relevant information placed in the middle experiences 10-40% lower recall accuracy than the same information at the start or end. Context poisoning occurs when hallucinations or tool-output errors enter context and compound through repeated reference, entering via bad tool outputs, incorrect retrieved documents, or hallucinated intermediate summaries; once a goals section is poisoned, it drives strategies that take substantial effort to undo. Context distraction happens when models over-focus on everything provided at the expense of training knowledge - even a single irrelevant document measurably reduces performance, and multiple distractors compound the effect, because models have no mechanism to skip irrelevant context. Context confusion arises when irrelevant information influences responses inappropriately, especially when a session mixes multiple task types. Context clash develops when multiple individually-correct pieces of information directly contradict each other, commonly from multi-source retrieval, version conflicts, or incompatible perspectives.
When to use - and when NOT to
Activate this skill when agent performance degrades unexpectedly during long conversations, when debugging agents that produce incorrect or irrelevant outputs, when designing systems that must handle large contexts reliably, when evaluating context-engineering choices for production systems, or when investigating "lost in middle" phenomena. It is diagnostic rather than a fix-it-yourself tool: it identifies which of the five patterns is occurring so the right architectural mitigation (compaction, masking, partitioning, or isolation) can be applied, rather than assuming more context capacity alone solves the problem - the RULER benchmark found only 50% of models claiming 32K+ context maintain satisfactory performance at 32K tokens, and for many models meaningful degradation begins around 8,000-16,000 tokens regardless of the advertised window.
Inputs and outputs
Input is an agent session or evaluation exhibiting unexplained quality loss as context grows; output is a diagnosis of which degradation pattern applies plus a mitigation strategy from the four-bucket approach: Write (save context outside the window via scratchpads or external storage), Select (pull only relevant context in through retrieval and filtering), Compress (reduce tokens while preserving information via summarization or observation masking), and Isolate (split context across sub-agents so no single context grows large enough to degrade - the most aggressive but often most effective strategy). Recovery from poisoning specifically means truncating context to before the poisoning point, explicitly flagging the poisoned content and requesting re-evaluation, or restarting with only verified information. It also documents model-specific degradation thresholds - GPT-5.2 shows onset around 64K tokens and severe degradation around 200K with its thinking mode; Claude Opus 4.5 shows onset around 100K and severe degradation around 180K within its 200K window; Claude Sonnet 4.5 shows onset around 80K and severe degradation around 150K; Gemini 3 Pro's 1M window shows onset around 500K and severe degradation around 800K - alongside counterintuitive findings such as shuffled (incoherent) haystacks outperforming logically coherent ones, since coherence can create false associations that confuse retrieval.
Who it's for
Agent and context engineers debugging degraded output quality in long-running sessions, or designing production systems that must stay reliable as context grows, who need named failure patterns and empirical thresholds rather than a vague "context got too long" diagnosis. Processing cost is also a factor in the guidance: cost to process a 400K token context is not double that of 200K, it grows exponentially in both time and compute, which the skill treats as a further reason to isolate and compress rather than simply extend context.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.