Context compressor

From sundial-org/awesome-openclaw-skills · View interactive version

Context compressor is an AI agent skill from the GitHub repository sundial-org/awesome-openclaw-skills. Automated context management for long-running Clawdbot sessions. Detects when context limits approach, compresses old conversation history, and seamlessly transfers to a fresh session.

How to use this skill

Skill file

Context Compressor Skill

Automated context management for long-running Clawdbot sessions. Detects when context limits approach, compresses old conversation history, and seamlessly transfers to a fresh session.

When to Use

How It Works

  1. Monitoring: Continuously tracks context usage via session metadata
  2. Compression: When threshold reached (configurable, default 80%), summarizes old messages
  3. Preservation: Extracts key decisions, code changes, file states, and action items
  4. Handoff: Initiates new session with compressed context as foundation
  5. Continuity: User experiences seamless transition with all important context preserved

Key Features

Core Concepts

Context Degradation Patterns

As sessions grow long, watch for these signs:

Compression Strategy

  1. Extract Core Intelligence:
  1. Condense History:
  1. Format for Efficiency:

Usage

Automatic Mode (Recommended)

The skill runs automatically during heartbeats and idle periods. Configure threshold:

# Set compression to trigger at 75% context usage
context-compressor set-threshold 75

# Check current status
context-compressor status

Manual Trigger

# Force compression and session reset
context-compressor compress --force

Configuration

# View all settings
context-compressor config

# Adjust summarization depth
context-compressor set-depth brief|detailed|comprehensive

# Set quiet hours (compression won't run)
context-compressor set-quiet-hours 23:00-07:00

Output

When compression occurs, the skill produces:

  1. Summary File: memory/compressed-{session-id}.md
  1. Session Handoff: Automatic new session with:

Best Practices

  1. Regular Compression: Don't wait for limits. Compress proactively every few hours
  2. Preserve Code: Always keep actual code snippets, not just references
  3. Track Decisions: Explicitly note WHY decisions were made, not just WHAT
  4. Keep TODOs: Mark incomplete work clearly for continuity
  5. Reference Files: Point to files rather than embedding full contents

Integration Points

Technical Details

Compression Algorithm

  1. Parse session transcript into atomic turns
  2. Score each turn for importance (decisions = high, chat = low)
  3. Keep top N% of turns by importance score
  4. Summarize remaining turns into executive summary
  5. Extract and preserve code blocks separately
  6. Generate session transfer package

Thresholds

File References

The compressor tracks:

Troubleshooting

Compression Too Frequent

# Increase threshold
context-compressor set-threshold 85

Context Lost After Handoff

Check that:

  1. Compressed summary was generated (memory/compressed-*.md)
  2. New session loaded memory files
  3. Critical files weren't in the "chaff" that got dropped

Performance Impact

Compression runs in background and should complete in <30s for typical sessions. If slower:

Examples

Typical Workflow

User: Working on notes app sidebar
[Session runs 2 hours, many iterations]

Heartbeat triggers → Context at 78% → Auto-compress → New session
User: (no interruption, seamless continuation)
New session has: executive summary, key decisions, file states, TODOs

Manual Recovery

User notices Claude repeating itself
User: "context-compressor compress --force"
Compressor summarizes → New session starts → User continues seamlessly

Related Skills

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.