context-compactor
14
总安装量
9
周安装量
#24083
全站排名
安装命令
npx skills add https://github.com/adaptationio/skrillz --skill context-compactor
Agent 安装分布
github-copilot
7
opencode
6
claude-code
4
codex
4
gemini-cli
4
continue
3
Skill 文档
Context Compactor
Automatically summarizes and compacts context when approaching token limits while preserving critical information.
Quick Start
Check if Compaction Needed
from scripts.compactor import ContextCompactor
compactor = ContextCompactor()
if compactor.should_compact(context, limit=100000):
compacted = compactor.compact(context)
Compact Context
compacted = compactor.compact(context)
# Preserves: architectural decisions, bugs, current state
# Discards: stale tool outputs, redundant messages
Preservation Strategy
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â PRESERVATION PRIORITY â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â MUST PRESERVE (Never remove) â
â ââ Architectural decisions â
â ââ Unresolved bugs and blockers â
â ââ Current feature state â
â ââ Recent file changes (last 5) â
â ââ Error patterns and solutions â
â â
â CAN SUMMARIZE (Compress to summary) â
â ââ Completed features (list of IDs) â
â ââ Resolved errors (brief mention) â
â ââ Historical decisions (key points) â
â â
â CAN DISCARD (Remove entirely) â
â ââ Redundant tool outputs â
â ââ Stale search results â
â ââ Superseded messages â
â ââ Verbose logging â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Compaction Process
- Score Importance: Assign score to each message/content
- Identify Critical: Mark must-preserve content
- Summarize Middle: Compress can-summarize content
- Discard Stale: Remove can-discard content
- Validate: Ensure compacted context is coherent
Token Budgets
| Context Type | Limit | Action |
|---|---|---|
| < 50% | Normal | No action |
| 50-75% | Warning | Prepare for compaction |
| 75-90% | Compact | Trigger compaction |
| > 90% | Critical | Aggressive compaction |
Integration Points
- autonomous-session-manager: Triggers compaction check
- memory-manager: Stores compacted summaries
- handoff-coordinator: Uses compacted state for handoffs
References
references/COMPACTION-STRATEGY.md– Detailed strategyreferences/TOKEN-BUDGETS.md– Budget management
Scripts
scripts/compactor.py– Core ContextCompactorscripts/importance_scorer.py– Message scoringscripts/summarizer.py– Content summarizationscripts/token_estimator.py– Token counting