Skills

Context Degradation

Should be used for diagnosing and mitigating context degradation: lost-in-middle...

Install

npx skills add muratcankoylan/Agent-Skills-for-Context-Engineering --skill context-degradation -g -a claude-code -y
Category
AI and agents
Updated
24d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
Yes, review before use

What it does

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

Context Degradation Patterns

Diagnose and fix context failures before they cascade. Context degradation is not binary, it is a continuum that manifests through five distinct, predictable patterns: lost-in-middle, poisoning, distraction, confusion, and clash. Each pattern has specific detection signals and mitigation strategies. Treat degradation as an engineering problem with measurable thresholds, not an unpredictable failure mode.

When to Activate

Activate this skill when:

  • Agent performance degrades unexpectedly during long conversations
  • Debugging cases where agents produce incorrect or irrelevant outputs
  • Designing systems that must handle large contexts reliably
  • Evaluating context engineering choices for production systems
  • Investigating "lost in middle" phenomena in agent outputs
  • Analyzing context-related failures in agent behavior

Do not activate this skill for adjacent work owned by other skills:

  • Explaining foundational context mechanics without an active failure: context-fundamentals.
  • Applying token-efficiency tactics after the failure pattern is known: context-optimization.
  • Designing a compression or handoff summary strategy: context-compression.
  • Persisting large outputs, logs, or scratch state outside the prompt: filesystem-context.

Core Concepts

Structure context placement around the attention U-curve: beginning and end positions receive reliable attention, while middle positions suffer materially reduced recall accuracy in long-context experiments (claim-context-degradation-lost-middle-ruler). This is not a model bug but a consequence of attention mechanics, the first token (often BOS) acts as an "attention sink" that absorbs disproportionate attention budget, leaving middle tokens under-attended as context grows.

Read the whole SKILL.md on GitHub

More in AI and agents