context-degradation

Diagnose and mitigate context degradation patterns in long-running agent systems.

9|2|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/AbdullahMalik17/Hacathan_5 --skill context-degradation-abdullahmalik17
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/AbdullahMalik17/Hacathan_5/tree/main/.claude/skills/context-degradation
Command: npx skills add https://github.com/AbdullahMalik17/Hacathan_5 --skill context-degradation-abdullahmalik17

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? AI agents degrade unpredictably as conversation context grows, producing wrong answers, hallucinations, and tool misuse that are hard to diagnose. This Skill provides a systematic framework for recognizing, measuring, and mitigating the five core degradation patterns: lost-in-middle, context poisoning, distraction, confusion, and clash. ## Core Features & Use Cases - Degradation Pattern Diagnosis: Identify lost-in-middle effects, context poisoning, distraction, confusion, and clash using documented symptoms and empirical benchmarks. - Context Health Scoring: Run the included Python analyzer to compute a composite health score from token utilization, attention distribution, and poisoning indicators. - Mitigation Architecture Guidance: Apply the Write/Select/Compress/Isolate strategies with concrete patterns like compaction, observation masking, and sub-agent isolation. - Use Case: When a long-running support agent starts giving contradictory answers after 50 turns, use this Skill to detect context poisoning, score context health, and apply truncation or compaction before quality collapses. ## Quick Start Ask the agent to analyze the current conversation context for degradation risks and recommend mitigation strategies using the context-degradation skill.

Frequently Asked Questions about context-degradation

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

FAQPage Schema
How do I detect context degradation in an AI agent?▼

Use the ContextHealthAnalyzer class to compute a composite health score from token utilization, lost-in-middle degradation, and poisoning indicators. Scores above 0.8 are healthy, while scores below 0.4 indicate critical degradation requiring intervention.

What is the lost-in-middle phenomenon in LLMs?▼

The lost-in-middle phenomenon is a U-shaped attention pattern where information in the center of context receives 10-40% lower recall accuracy than information at the beginning or end. Mitigate it by placing critical information at context edges.

How do I fix context poisoning in an agent conversation?▼

Context poisoning recovery requires removing or replacing the erroneous content. Truncate context to before the poisoning point, explicitly flag the error for re-evaluation, or restart with clean context preserving only verified information.

At what context length does LLM performance degrade?▼

Degradation onset varies by model, with many models showing meaningful decline around 8,000-16,000 tokens despite larger advertised windows. The RULER benchmark found only 50% of models claiming 32K+ context maintain satisfactory performance at that length.

What are the limitations of the degradation detection scripts?▼

The scripts simulate U-shaped attention curves and use pattern matching as proxies rather than real model internals. Production systems should extract actual attention weights, use model-specific tokenizers, and consider fine-tuned classifiers for poisoning detection.