context-degradation
What it does
This skill explains the common ways an AI's context goes wrong, such as information in the middle being ignored or wrong details spreading. It is for people debugging agents that get worse over long sessions.
When to use it
- ✓When an agent's answers get worse the longer a conversation runs.
- ✓When an agent ignores details placed in the middle of a long input.
- ✓When conflicting or wrong information in the context leads to bad outputs.
Skill link
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-degradation/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My AI agent gets confused after a long session and misses things I told it earlier. Help me figure out why.”
5 new skills a week. 1 minute to read.
How it works
The skill names five patterns, such as lost in the middle, poisoning and clash, and gives signs and fixes for each, so you can match the problem to a cure.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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.
Treat context poisoning as a circuit breaker problem. Once a hallucination, tool error, or incorrect retrieved fact enters context, it compounds through repeated self-reference. A poisoned goals section causes every downstream decision to reinforce incorrect assumptions. Detection requires tracking claim provenance; recovery requires truncating to before the poisoning point or restarting with verified-only context.
Filter aggressively before loading context — even a single irrelevant document measurably degrades performance on relevant tasks. Models cannot "skip" irrelevant context; they must attend to everything provided, creating attention competition between relevant and irrelevant content. Move information that might be needed but is not immediately relevant behind tool calls instead of pre-loading it.
Isolate task contexts to prevent confusion. When context contains multiple task types or switches between objectives, models incorporate constraints from the wrong task, call tools appropriate for a different context, or blend requirements from multiple sources. Explicit task segmentation with separate context windows eliminates cross-contamination.
Resolve context clash through priority rules, not accumulation. When multiple correct-but-contradictory sources appear in context (version conflicts, perspective conflicts, multi-source retrieval), models cannot determine which applies. Mark contradictions explicitly, establish source precedence, and filter outdated versions before they enter context.
Detailed Topics
Lost-in-Middle: Detection and Placement Strategy
Place critical information at the beginning and end of context, never in the middle. The U-shaped attention curve means middle-positioned information suffers 10-40% reduced recall accuracy. For contexts over 4K tokens, this effect becomes significant.
Use summary structures that surface key findings at attention-favored positions. Add explicit section headers and structural markers — these help models navigate long contexts by creating attention anchors. When a document must be included in full, prepend a summary of its key points and append the critical conclusions.
Monitor for lost-in-middle symptoms: correct information exists in context but the model ignores it, responses contradict provided data, or the model "forgets" instructions given earlier in a long prompt.
Context Poisoning: Prevention and Recovery
Validate all external inputs before they enter context. Tool outputs, retrieved documents, and model-generated summaries are the three primary poisoning vectors. Each introduces unverified claims that subsequent reasoning treats as ground truth.
Detect poisoning throu
FAQ
What does lost in the middle mean?
The model pays less attention to information placed in the center of a long input.
How is context poisoning different?
It happens when an error gets into the context and keeps being reused, making later answers worse.
Where should key instructions go?
The skill suggests placing key information near the beginning or the end, where attention is strongest.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 18k
- Ranking position
- #10638
- License
- MIT
- Updated
- 10/11/2026
Comments
- …
More skills from this repository
context-engineering-collection
18kHelps your agent manage what goes into an AI model's context window, from memory and tools to multi-agent setups and evaluation.
advanced-evaluation
18kTeaches your agent how to judge AI answers using another AI, with scoring, side-by-side comparison and bias checks.
bdi-mental-states
18kTeaches your agent to model beliefs, goals and plans using the BDI approach, so its decisions can be traced and explained.
context-compression
18kHelps your agent shorten long AI sessions into summaries that keep decisions, files, risks and next steps.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.