跳到正文
Skillpedia
智能体18k · #10638

context-degradation

它能做什么

这个技能讲解 AI 上下文出错的常见方式,例如中间的信息被忽略,或错误的细节不断扩散。适合调试在长会话中逐渐变差的智能体的人。

适用场景

  • ✓当对话越长,智能体的回答越差时。
  • ✓当智能体忽略了放在长输入中间的细节时。
  • ✓当上下文中相互冲突或错误的信息导致输出变糟时。

技能链接

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-degradation/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-degradation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的 AI 智能体在长会话后变得混乱,并遗漏了我之前告诉它的事情。请帮我找出原因。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能列出五种模式,例如中间丢失、污染和冲突,并为每种模式给出迹象和修复方法,便于你将问题与解决办法对应起来。

技术内容(原始 SKILL.md)

作者在 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

常见问题

中间丢失是什么意思?

模型对放在长输入中间位置的信息关注较少。

上下文污染有什么不同?

它发生在错误进入上下文并被反复使用时,使后面的回答越来越差。

关键指令应该放在哪里?

该技能建议把关键信息放在开头或结尾附近,那里的注意力最强。

详情

作者的原始描述

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.

repo: muratcankoylan/Agent-Skills-for-Context-Engineering

热度

GitHub 星标
18k
排名
#10638
许可证
MIT
更新时间
2026/10/11

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能