clawpressor

Compress OpenClaw session context to reduce token usage and extend session lifetime. Uses NLP summarization (Sumy) to intelligently compact conversation history while preserving essential context. Triggers on mentions of session compression, token reduction, context cleanup, or when session size exceeds safe thresholds (~300KB). Use when (1) OpenClaw approaches 50% context limit, (2) Sessions are slowing down due to large context, (3) Reducing API costs from excessive token consumption, (4) Extending session lifetime without forced reboots.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "clawpressor" with this command: npx skills add beboxos/clawpressor

ClawPressor - Session Context Compressor

Intelligently compress OpenClaw session files to reduce token usage by 85-96%.

Author: JARVIS (AI Coder) | Managed by: BeBoX License: MIT | Version: 1.0.0

Quick Start

# Preview compression without changes
python3 scripts/compress.py --dry-run

# Apply compression
python3 scripts/compress.py --apply

# Restore from backup
python3 scripts/compress.py --restore

When to Use

SituationAction
Context at 30-40%Plan compression soon
Context at 50%URGENT — OpenClaw will force compact
Session > 300KBCompress to restore performance
Slow responsesLarge context likely the cause
High API costsCompress regularly to save tokens

How It Works

  1. Preserves recent context — Keeps last 5 messages intact for immediate context
  2. Summarizes old messages — Uses LexRank algorithm to extract key information
  3. Replaces with compact block — Single system message containing summary
  4. Creates backup — Original preserved as .backup file

Prerequisites

pip install sumy
python -c "import nltk; nltk.download('punkt_tab'); nltk.download('stopwords')"

Command Reference

# Find and compress latest session (dry-run)
python3 scripts/compress.py

# Compress specific session
python3 scripts/compress.py --session /path/to/session.jsonl --apply

# Keep more recent messages (default: 5)
python3 scripts/compress.py --keep 10 --apply

# Restore if something went wrong
python3 scripts/compress.py --restore

# View compression statistics
python3 scripts/compress.py --stats

Typical Results

MetricBeforeAfterGain
Messages1686-96%
Size347 KB12 KB-96%
Context tokens~50k~8k-84%
Session duration~30 min~2-3h+400%

Integration with Workflows

In HEARTBEAT.md:

## Context Maintenance (1x/jour)
- Check session size: `ls -lh ~/.openclaw/agents/main/sessions/*.jsonl`
- If > 200KB: `python3 skills/clawpressor/scripts/compress.py --apply`

Manual check:

# See current session stats
ls -lh ~/.openclaw/agents/main/sessions/*.jsonl | head -1

Safety

  • Always creates .backup before compressing
  • --restore recovers original session
  • Recent messages always preserved intact
  • Summary stored as system message (visible to model)

Troubleshooting

IssueSolution
"Sumy not installed"Run pip install sumy and NLTK downloads
No session foundCheck ~/.openclaw/agents/main/sessions/ exists
Backup not foundFile may have been overwritten; no recovery
Poor summariesIncrease --keep to preserve more context

Credits

  • Coding: JARVIS (AI Assistant)
  • Project Management: BeBoX
  • Technique: NLP summarization via Sumy (LexRank algorithm)

Related

  • See memory/openclaw-context-optimization.md for full strategy
  • Combine with SOUL_MIN/USER_MIN files for maximum efficiency

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Context Slim

See exactly what's eating your context window. Analyzes prompts, conversations, and system instructions to show where every token goes. Actionable compressio...

Registry SourceRecently Updated
0119
Profile unavailable
General

Memory Organizer

Organize, compress, and curate OpenClaw memory without polluting permanent memory. Use when the user wants to compress memory files, clean dated memory notes...

Registry SourceRecently Updated
1320
Profile unavailable
General

Memory Compression

Prevent context overflow with automatic session truncation and memory preservation. Never lose important conversations again. Features: token-based trimming,...

Registry SourceRecently Updated
2591
Profile unavailable