Automatic context summarization for long-running sessions. Use when context is approaching limits, summarizing completed work, preserving critical information, or managing token budgets.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
npx agent-skills-cli listSkill Instructions
name: context-compactor description: Automatic context summarization for long-running sessions. Use when context is approaching limits, summarizing completed work, preserving critical information, or managing token budgets. version: 1.0.0 category: autonomous-coding layer: context-engineering
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
More by adaptationio
View allTerra API troubleshooting and debugging. Use when experiencing connection issues, data sync problems, webhook failures, SDK errors, or provider-specific issues.
Systematic research workflow orchestrating multi-source research operations for comprehensive domain investigation. Sequential workflow from web search through GitHub exploration and documentation analysis to research synthesis. Use when researching new domains, gathering patterns, investigating technologies, or conducting comprehensive multi-source research for skill development.
Session lifecycle management for autonomous coding. Use when starting sessions, resuming work, detecting session type (init vs continue), or managing auto-continuation between sessions.
Amazon Bedrock Runtime API for model inference including Claude, Nova, Titan, and third-party models. Covers invoke-model, converse API, streaming responses, token counting, async invocation, and guardrails. Use when invoking foundation models, building conversational AI, streaming model responses, optimizing token usage, or implementing runtime guardrails.
