SuperAPI AI Directory

context-degradation

Agents & models

View repository

Updated 10-16 06:02

About this skill

📉 Context Degradation Patterns

This skill enables diagnosing and mitigating predictable failures in LLM performance as context length increases. Degradation is not a binary state, but a continuum that affects the model's attention and accuracy.

Mental Model: Context is not a perfect mirror; it is a leaky bucket. Degradation occurs when noise exceeds the signal or when the model's attention is stretched too thin.

🚩 Fragility and Autonomy

  • Fragility: Medium. Identifying the exact point of degradation requires empirical testing.
  • Freedom: High in the implementation of recovery strategies (Truncation vs. Summarization).

🚀 When to Activate

  • When agent performance unexpectedly decreases in long conversations.
  • When debugging incorrect or irrelevant outputs ("Lost-in-Middle").
  • When designing systems that must handle massive contexts (1M+ tokens).
  • To evaluate context engineering architecture decisions.

🧠 Core Concepts

1. The "Lost-in-Middle" Phenomenon

Models show U-shaped attention curves. Information at the beginning and end is recalled accurately, while information buried in the middle suffers a 10-40% recall drop.

2. Types of Degradation

Pattern Cause Symptom
Context Poisoning Previous errors or hallucinations. Feedback loops of false beliefs.
Context Distraction Excess irrelevant information. The model ignores its base training.
Context Confusion Multiplicity of tasks in one window. Mixing of requirements from different sources.
Context Clash Contradictory information. Derailment of logical reasoning.

3. Thresholds by Model (Reference)

Model Degradation Start Severe Degradation
Gemini 3 Pro ~500K tokens ~800K tokens
Gemini 3 Flash ~300K tokens ~600K tokens
GPT-5.2 ~64K tokens ~200K tokens

🛠️ Implementation in Gemini Elite Core

The "Four-Bucket" Approach

  1. Write: Saves context outside the window (files, scratchpads).
  2. Select: Selective retrieval (RAG, filtering) to exclude noise.
  3. Compress: Summarization and masking of observations (Observation Masking).
  4. Isolate: Divide tasks among sub-agents with clean context windows.

Pattern: Lost-in-Middle Mitigation

Move critical information to the edges of the context.

[INFORMACIÓN CRÍTICA / TAREA ACTUAL] # Inicio (Alta Atención)
...
[DATOS DE APOYO / HISTORIAL LARGO]    # Medio (Baja Atención)
...
[REGLAS FINALES / FORMATO DE SALIDA]  # Final (Alta Atención)

🔗 Integrations

  • context-fundamentals: Foundation for understanding the hierarchy.
  • context-optimization: Specific mitigation techniques.
  • evaluation: Measurement of context health using probes.

📚 Internal References

  • references/patterns.md: Technical reference on attention distribution and retrieval.