context-degradation

Diagnose and mitigate context degradation patterns in LLM agent systems.

2|Updated May 30, 2026
One-click install
npx skills add https://github.com/virahitvin8/crafty-gis --skill context-degradation-virahitvin8
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/virahitvin8/crafty-gis/tree/main/GIT_STAR/assignment-generator/antigravity-skills-main/antigravity-skills-main/skills/context-degradation
Command: npx skills add https://github.com/virahitvin8/crafty-gis --skill context-degradation-virahitvin8

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 claims poison downstream reasoning, and contradictory retrieved documents cause unpredictable outputs. This Skill provides a systematic framework to detect, diagnose, and fix these failures before they cascade. ## Core Features & Use Cases - Five-Pattern Diagnosis: Identify lost-in-middle, context poisoning, distraction, confusion, and clash failures with specific detection signals for each. - Health Analysis Toolkit: Run composite context health checks combining attention distribution, poisoning indicators, and utilization metrics via the included Python scripts. - Mitigation Framework: Apply the Write/Select/Compress/Isolate strategies matched to the active degradation pattern, with recovery procedures like truncation and context resets. - Use Case: An agent that worked well for 10 turns starts citing an incorrect retrieved fact at turn 30. Use this Skill to trace the poisoning entry point, truncate context to before that point, and reload only verified sources. ## Quick Start Ask the AI to analyze your agent's conversation context for degradation symptoms and recommend which mitigation strategy to apply.

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 checking whether critical information sits in the middle 80% of your context, where attention is degraded. Place key instructions and findings at the beginning or end, and watch for symptoms like the model ignoring provided data or forgetting earlier instructions.

What is context poisoning in AI agents?

Context poisoning occurs when a hallucination, tool error, or incorrect retrieved fact enters the 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.

Does a bigger context window fix long-context performance issues?

No. Larger windows delay but do not eliminate U-shaped attention degradation, and processing cost grows faster than linearly. Splitting tasks across sub-agents with isolated contexts is often more effective than expanding a single context.

Why does my RAG agent give contradictory answers?

Contradictory retrieved documents cause context clash, where the model silently picks one source unpredictably. Implement contradiction detection in the retrieval layer, mark conflicts explicitly, and establish source precedence rules before documents enter context.