Engineering
context-degradation avatar

context-degradation

Diagnose, isolate, and mitigate LLM context failures like lost-in-middle, poisoning, distraction, and context clash to improve agent reliability.

Introduction

This skill provides a structured engineering framework for identifying and resolving performance degradation in AI agent systems. Context engineering is the discipline of optimizing the information landscape within a model's context window. This skill is specifically designed for developers and AI engineers who observe unpredictable agent behaviors, such as hallucinations, tool misuse, or failure to follow instructions in long-running sessions. By treating context as a finite, load-sensitive resource governed by attention mechanics, it helps practitioners shift from trial-and-error prompting to rigorous, systemic failure mitigation.

  • Detection and diagnosis of the 'lost-in-middle' phenomenon where critical information is ignored if placed in the center of long contexts.

  • Strategies to prevent 'context poisoning' by validating tool outputs and retrieved documents before they enter the model's reasoning window.

  • Techniques for aggressive relevance filtering and curation to prevent 'context distraction' caused by irrelevant background data.

  • Implementation of task isolation patterns to prevent 'context confusion' where constraints from different objectives bleed into one another.

  • Methods for resolving 'context clash' when multiple contradictory sources exist within the prompt window.

  • Users should activate this skill when investigating agent performance drops, debugging incorrect tool calls, or evaluating system design for production-scale context management.

  • The skill expects input regarding the agent's behavior, current context length, and symptoms like contradiction or ignored instructions; it outputs specific architectural adjustments, placement strategies, and filtering rules.

  • Practical tips include utilizing the U-curve attention principle by placing core instructions at the very beginning or end of the prompt and using structural anchors like markers or headers.

  • Constraints: The skill operates on fundamental LLM attention architecture; therefore, effectiveness is contingent on the specific model's attention span and recall capabilities. It prioritizes a 'curation over accumulation' approach, suggesting that developers move non-essential context behind tool calls rather than flooding the primary window.

Repository Stats

Stars
15,338
Forks
1,203
Open Issues
25
Language
Python
Default Branch
main
Sync Status
Idle
Last Synced
Apr 29, 2026, 05:53 AM
View on GitHub