context-degradation

Diagnose and mitigate context degradation patterns in LLM agent systems.

1|Updated May 16, 2026
One-click install
npx skills add https://github.com/ludotype/game-adventurertown --skill context-degradation-ludotype
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/ludotype/game-adventurertown/tree/main/.agent/skills/context-degradation
Command: npx skills add https://github.com/ludotype/game-adventurertown --skill context-degradation-ludotype

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? LLM agents degrade unpredictably in long conversations: they ignore information buried mid-context, compound errors from poisoned context, and mix constraints across tasks. This Skill provides detection signals, thresholds, and mitigation strategies for five degradation patterns: lost-in-middle, poisoning, distraction, confusion, and clash. ## Core Features & Use Cases - Degradation Detection: Measure attention distribution, detect lost-in-middle placement of critical information, and flag context poisoning indicators such as error accumulation and contradictions. - Composite Health Scoring: Run ContextHealthAnalyzer to combine utilization, degradation, and poisoning metrics into a single 0-1 health score with actionable recommendations. - Mitigation Frameworks: Apply the Write/Select/Compress/Isolate four-bucket strategy and architectural patterns like just-in-time loading and sub-agent isolation. - Use Case: An agent's output quality drops after 40K tokens of conversation. Use analyze_agent_context to get a health score, identify that critical instructions sit in the attention-degraded middle region, and restructure the context to place key information at the edges. ## 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 context?▼

Use measure_attention_distribution to map attention weight across context positions, then pass critical information positions to detect_lost_in_middle. It returns at-risk positions, a degradation score, and recommendations to move key content to the beginning or end of context.

What is context poisoning and how do I detect it?▼

Context poisoning occurs when hallucinations, tool errors, or incorrect retrieved facts enter context and compound through self-reference. The PoisoningDetector class flags error accumulation, contradictions, and hallucination markers, returning an overall risk level of low, medium, or high.

At what context length does LLM performance degrade?▼

Degradation typically begins at 60-70% of the advertised context window, often around 8K-16K tokens for complex tasks, and follows a cliff-edge pattern rather than gradual decline. Benchmark your specific workload since thresholds shift with model updates.

Does a larger context window fix agent performance issues?▼

No. Larger windows delay but do not eliminate U-shaped attention degradation, and cost grows non-linearly with token count. For multi-task workloads, splitting tasks across sub-agents with isolated contexts is more effective than expanding a single context.

Why does my agent ignore instructions given earlier in a long prompt?▼

Middle-positioned content suffers 10-40% reduced recall due to the U-shaped attention curve. Place critical instructions at the beginning or end of context, add explicit section headers as attention anchors, and verify the prompt works at low token counts before blaming degradation.

How accurate is the attention measurement in the detection script?▼

The script simulates U-shaped attention curves for demonstration purposes. Production systems should extract actual attention weights from model internals using tools like TransformerLens and use model-specific tokenizers instead of whitespace-split heuristics.