context-compression
Optimize agent performance and token usage through advanced context compression, structured summarization, and task-oriented state management for long-running sessions.
Introduction
This skill is designed for developers and AI agents managing complex, long-running conversational sessions where context windows are stretched to their limits. In environments with large codebases—often exceeding 5 million tokens—naively truncating history leads to "agent amnesia," where critical information like file modifications, function signatures, and error logs are lost. This skill implements advanced context compression strategies, prioritizing the "tokens-per-task" metric over simple request-based token savings. By focusing on total task efficiency, it prevents the high cost of re-fetching information caused by poor compression choices.
-
Anchored Iterative Summarization: Maintains persistent, structured summaries that track session intent, specific file changes, design decisions, and unresolved tasks, ensuring critical project state is never lost.
-
Structured Artifact Tracking: Provides mechanisms to document which files were modified, read, or created, mitigating the "artifact trail" problem common in coding agents.
-
Compression Trigger Heuristics: Offers configurable strategies such as fixed threshold triggers, sliding windows, and importance-based reduction to determine the optimal moment to condense history.
-
Probe-Based Quality Evaluation: Integrates evaluation frameworks to measure compression success beyond simple lexical matching, testing factual recall, decision reasoning, and artifact integrity.
-
Tokens-Per-Task Optimization: Shifts the focus from minimizing input tokens to minimizing overall cost and latency by reducing the need for the agent to re-explore or hallucinate during complex coding sessions.
-
Activate this skill when encountering context window overflow or when agent performance degrades over long, multi-turn coding tasks.
-
Use the provided structured markdown sections to enforce preservation of technical details like JWT configurations, Redis connection pools, and error message history.
-
Implementation relies on logical segmentation of conversation history, preventing silent information drift across multiple compression cycles.
-
Suitable for systems using frameworks like XState or standard CLI-based agent scaffolding, where clear state and history are vital for high-accuracy outputs.
-
Users should ensure their evaluation protocols include specific "probe questions" to verify that essential file paths and system constraints survive the compression process.
Repository Stats
- Stars
- 0
- Forks
- 1
- Open Issues
- 1
- Language
- Python
- Default Branch
- main
- Sync Status
- Idle
- Last Synced
- May 3, 2026, 09:30 PM