context-degradation

Diagnose and mitigate context degradation patterns in LLM agent systems.

Updated Aug 7, 2026
One-click install
npx skills add https://github.com/Sambhav242005/Major-Project --skill context-degradation-sambhav242005
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/Sambhav242005/Major-Project/tree/main/.agents/skills/context-degradation
Command: npx skills add https://github.com/Sambhav242005/Major-Project --skill context-degradation-sambhav242005

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Long-running LLM agents silently degrade as context grows: critical instructions get lost in the middle of the prompt, hallucinated or erroneous content poisons downstream reasoning, and contradictory retrieved documents cause unpredictable outputs. This Skill provides a systematic framework and detection tooling to identify which degradation pattern is active and apply the correct mitigation before failures cascade. ## Core Features & Use Cases - Pattern Diagnosis: Distinguish five degradation patterns — lost-in-middle, context poisoning, distraction, confusion, and clash — each with specific detection signals and recovery procedures. - Detection Scripts: Run Python utilities to measure attention distribution, flag critical information in low-attention regions, detect poisoning indicators, and compute a composite context health score. - Mitigation Framework: Apply the Write/Select/Compress/Isolate strategies matched to the active failure pattern, with empirical thresholds for when to trigger compaction. - Use Case: An agent that answered correctly at turn 5 starts citing a wrong API endpoint at turn 30. Use this Skill to trace the poisoning entry point, truncate context to before the bad claim, and reload only verified sources. ## Quick Start Ask the agent to analyze the current conversation context for degradation symptoms and recommend whether to compact, truncate, or restructure the context.

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?

Lost-in-middle detection checks whether critical information sits in the low-attention middle region of a long context. The detection script maps attention weight by position and flags critical items in degraded regions, recommending relocation to the beginning or end of the prompt.

What is context poisoning and how do I fix it?

Context poisoning occurs when a hallucination, tool error, or incorrect retrieved fact enters context and compounds through self-reference. Fix it by truncating context to before the poisoning point and reloading only verified information, rather than layering corrections on top.

At what context length does LLM performance start degrading?

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

Why does my agent give wrong answers even when the correct information is in the prompt?

This usually indicates lost-in-middle placement, context distraction from irrelevant documents, or silent contradiction between retrieved sources. Verify the prompt works at low context lengths first to rule out prompt quality problems before diagnosing degradation.

When should I split tasks across sub-agents instead of using a larger context window?

Split tasks when context confusion or clash symptoms appear, or when a single context would exceed its degradation threshold. Larger windows delay but do not eliminate U-shaped attention degradation, and cost grows non-linearly with context size.