This skill enables managing long-running agent sessions that generate millions of tokens. The goal is not only to reduce tokens per request, but to optimize the total task efficiency (Tokens-Per-Task), minimizing the loss of critical information.
Mental Model: Compression is a distillation, not a truncation. Structuring the summary forces the preservation of technical details that would otherwise be lost in generic summaries.
🚩 Fragility and Autonomy
- Fragility: Medium. Aggressive compression can cause the agent to "forget" previous decisions or file changes.
- Freedom: High in choosing the compression method according to the session state.
🚀 When to Activate
- When sessions exceed practical latency or cost limits.
- In massive codebases (5M+ tokens) where the relevant context must be selected surgically.
- When designing persistent memory systems for agents.
- To debug cases where the agent loses track of its own modifications (Artifact Trail).
🧠 Core Concepts
1. The Real Indicator: Tokens-Per-Task
Do not optimize for "tokens per request". A strategy that saves 1% of tokens but forces the agent to re-read 5 files wastes resources. Success is measured in total tokens until the task is completed.
2. Compression Strategies
| Method | Ratio | Quality | Ideal Use |
|---|---|---|---|
| Anchored Iterative | 98.6% | 3.70 | Long code sessions, file tracking. |
| Regenerative Summary | 98.7% | 3.44 | Clear phase changes in the project. |
| Opaque Compression | 99.3% | 3.35 | Maximum savings, low need for technical recall. |
3. The "Artifact Trail" Problem
It is the weakest dimension of compression. Agents often forget exactly which files they modified.
- Solution: Keep an explicit "Files Modified" section in the compressed summary.
🛠️ Implementation in Gemini Elite Core
Pattern: Anchored Iterative Summarization
Define rigid sections that act as "anchors" for the information.
## Session Intent
[Propósito original del usuario]
## Files Modified
- path/to/file.ts: [Cambio atómico]
## Decisions Made
- [Razón detrás de la arquitectura elegida]
## Current State & Next Steps
- [Tests pasando/fallando]
- [Siguiente acción inmediata]
Triggers
- Fixed Threshold: When reaching 70-80% of the useful context.
- Sliding Window: Keep the last N turns + Structured Summary.
🔗 Integrations
context-fundamentals: Basis for the information hierarchy.evaluation: Use of "Probe-Based Evaluation" to measure the quality of the summary.memory-systems: Persistence of summaries in long-term memory systems.
📚 Internal References
references/evaluation-framework.md: Complete evaluation framework (Recall, Artifact, Decision probes).