context-degradation

Diagnose and mitigate context degradation patterns in LLM agent systems.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/NT-boop-star/BRMV-tract --skill context-degradation-nt-boop-star
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-degradation
Source: https://github.com/NT-boop-star/BRMV-tract/tree/main/antigravity/skills/context-degradation
Command: npx skills add https://github.com/NT-boop-star/BRMV-tract --skill context-degradation-nt-boop-star

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 window, hallucinated facts poison downstream reasoning, and irrelevant documents dilute attention. This Skill provides detection patterns, mitigation frameworks, and Python tooling to identify and fix these failures before they cascade. ## Core Features & Use Cases - Five Degradation Patterns: Recognize and mitigate lost-in-middle, context poisoning, distraction, confusion, and clash with pattern-specific detection signals and recovery procedures. - Health Analysis Toolkit: Run composite context health checks combining attention distribution, poisoning detection, and utilization metrics via the included degradation_detector.py script. - Four-Bucket Mitigation Framework: Apply Write, Select, Compress, and Isolate strategies matched to the active degradation pattern. - Use Case: An agent's output quality drops after 40K tokens of conversation. Use this Skill to measure attention distribution, detect that key instructions sit in the degraded middle region, and restructure context so critical information sits at attention-favored positions. ## Quick Start Analyze my agent's conversation context for degradation symptoms 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?

Measure attention distribution across context positions and check whether critical information falls in the middle region, which suffers 10-40% reduced recall. The detect_lost_in_middle function flags at-risk positions and recommends moving key content to the beginning or end.

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 repeated self-reference. Recover by truncating to before the poisoning point or restarting with verified-only context rather than layering corrections on top.

At what context length does LLM performance degrade?

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

Does a bigger context window solve long-context problems?

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

Why does my agent ignore instructions given earlier in the conversation?

Instructions placed in the middle of a long context receive reduced attention due to the U-shaped attention curve. Move critical instructions to the beginning or end, add explicit section headers as attention anchors, and verify the prompt works at low token counts first.

How accurate is the degradation_detector.py attention measurement?

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.