context-degradation

Diagnose and mitigate context degradation patterns in LLM agent systems.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill context-degradation-lgj-jonathan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills/tree/main/context-engineering/skills/context-degradation
Command: npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill context-degradation-lgj-jonathan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? LLM agents degrade unpredictably as context grows: critical information gets lost in the middle of long prompts, hallucinations poison downstream reasoning, irrelevant documents dilute attention, and contradictory sources cause silent failures. This Skill provides detection signals, thresholds, and mitigation strategies for each failure pattern. ## Core Features & Use Cases - Pattern Diagnosis: Identify five distinct degradation patterns (lost-in-middle, poisoning, distraction, confusion, clash) with specific detection signals for each. - Health Analysis Scripts: Run Python tools that measure attention distribution, detect poisoning indicators, and compute a composite context health score with recommendations. - Mitigation Framework: Apply the Write/Select/Compress/Isolate strategies matched to the active degradation pattern, with compaction triggers set before degradation cliffs. - Use Case: An agent's output quality drops after 40K tokens of conversation. Use this Skill to confirm lost-in-middle placement of critical instructions, then restructure context to move key constraints to attention-favored positions. ## Quick Start Analyze my agent's conversation context for degradation patterns and recommend whether to compact, truncate, or restructure it.

Frequently Asked Questions about context-degradation

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

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

Detect lost-in-middle issues by mapping which context positions hold critical information and checking whether they fall in the low-attention middle region. The degradation_detector.py script measures simulated attention distribution and flags critical content in degraded positions.

What is context poisoning in AI agents?

Context poisoning occurs when a hallucination, tool error, or incorrect retrieved fact enters context and compounds through repeated self-reference. Recovery requires truncating to before the poisoning point or restarting with verified-only context, not layering corrections on top.

At what context length does LLM performance degrade?

Degradation typically begins at 60-70% of the advertised context window for complex retrieval tasks, often around 8K-16K tokens for many models. The decline is non-linear with a cliff edge, so set compaction triggers near 70% of the known onset threshold.

Why does my agent ignore instructions in long conversations?

Instructions placed in the middle of long contexts suffer 10-40% reduced recall due to U-shaped attention curves. Move critical instructions to the beginning or end of context, and verify the prompt works at low token counts before blaming degradation.

Does a bigger context window fix agent performance issues?

Larger windows delay but do not eliminate degradation, since U-shaped attention curves persist at any size. Processing very large contexts also costs exponentially more, so splitting tasks across sub-agents often works better than expanding context.