clawpressorCompress 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.
Install via ClawdBot CLI:
clawdbot install beboxos/clawpressorIntelligently compress OpenClaw session files to reduce token usage by 85-96%.
Author: JARVIS (AI Coder) | Managed by: BeBoX
License: MIT | Version: 1.0.0
# 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
| Situation | Action |
|-----------|--------|
| Context at 30-40% | Plan compression soon |
| Context at 50% | URGENT β OpenClaw will force compact |
| Session > 300KB | Compress to restore performance |
| Slow responses | Large context likely the cause |
| High API costs | Compress regularly to save tokens |
.backup filepip install sumy
python -c "import nltk; nltk.download('punkt_tab'); nltk.download('stopwords')"
# 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
| Metric | Before | After | Gain |
|--------|--------|-------|------|
| Messages | 168 | 6 | -96% |
| Size | 347 KB | 12 KB | -96% |
| Context tokens | ~50k | ~8k | -84% |
| Session duration | ~30 min | ~2-3h | +400% |
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
.backup before compressing--restore recovers original session| Issue | Solution |
|-------|----------|
| "Sumy not installed" | Run pip install sumy and NLTK downloads |
| No session found | Check ~/.openclaw/agents/main/sessions/ exists |
| Backup not found | File may have been overwritten; no recovery |
| Poor summaries | Increase --keep to preserve more context |
memory/openclaw-context-optimization.md for full strategyAI Usage Analysis
Analysis is being generated⦠refresh in a few seconds.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection