context-degradation

Diagnose and mitigate context degradation patterns in long-context LLM agent workflows.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/scoots31/engineering-playbook --skill context-degradation-scoots31
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/scoots31/engineering-playbook/tree/main/references/context-degradation
Command: npx skills add https://github.com/scoots31/engineering-playbook --skill context-degradation-scoots31

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Long conversations and large contexts cause LLM agents to silently degrade — ignoring instructions, hallucinating, or mixing up tasks. This Skill provides a systematic framework for recognizing five distinct degradation patterns (lost-in-middle, poisoning, distraction, confusion, clash) and applying targeted mitigations before failures cascade. ## Core Features & Use Cases - Pattern Diagnosis: Identify which of the five degradation patterns is active using concrete detection signals like attention U-curve analysis, claim provenance tracking, and relevance scoring. - Four-Bucket Mitigation Framework: Apply Write, Select, Compress, or Isolate strategies matched to the active degradation pattern, with thresholds like the 70% context utilization trigger. - Technical Reference Implementations: Includes Python code for attention distribution measurement, hallucination tracking, error propagation analysis, and context health monitoring dashboards. - Use Case: An agent that performed well early in a session starts producing contradictory outputs at 60K tokens. Use this Skill to diagnose context poisoning from a bad tool output, truncate to before the poisoning point, and restart with verified-only context. ## Quick Start Ask the AI to diagnose why your agent's output quality dropped during a long conversation and recommend a mitigation strategy based on the degradation pattern detected.

Frequently Asked Questions about context-degradation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix lost-in-middle problems in LLM prompts?

Place critical information at the beginning or end of the context, never the middle, since attention follows a U-shaped curve with 10-40% reduced recall in middle positions. Add explicit section headers and prepend summaries of long documents to create attention anchors.

What is context poisoning and how do I detect it?

Context poisoning occurs when a hallucination, tool error, or incorrect retrieved fact enters context and compounds through self-reference. Detect it through degraded output on previously successful tasks, tool misalignment, and persistent hallucinations; recover by truncating to before the poisoning point.

At what context length does LLM performance degrade?

Degradation typically begins at 60-70% of the advertised context window, and the RULER benchmark found only 50% of models claiming 32K+ context maintain satisfactory performance at that length. The decline is non-linear with a cliff edge, so set compaction triggers around 70% of the known onset.

Why does my agent ignore instructions in long conversations?

Instructions placed in the middle of long contexts suffer reduced attention, and irrelevant documents create attention competition the model cannot skip. Move critical instructions to the start or end, filter irrelevant content before loading, and isolate different tasks into separate context windows.

Does a bigger context window solve degradation problems?

No. Larger windows delay but do not eliminate U-shaped degradation, and processing cost grows non-linearly with token count. For many models, meaningful degradation begins at 8K-16K tokens regardless of window size, so splitting tasks across sub-agents often works better.

How do I handle contradictory documents in RAG retrieval?

Establish source priority rules before conflicts arise, filter outdated versions before they enter context, and mark unavoidable contradictions with structured annotations stating what conflicts and which source takes precedence. Without explicit rules, models resolve contradictions unpredictably and silently.