Memory Compressor
Auto-compress, deduplicate, and archive OpenClaw agent memory files. Keeps memory/ lean while preserving important context.
Quick Start
# Analyze memory directory — show sizes, ages, duplication
python3 scripts/memory-compressor.py analyze
# Compress old daily files (>7 days) into weekly summaries
python3 scripts/memory-compressor.py compress --older-than 7
# Deduplicate entries across memory files
python3 scripts/memory-compressor.py dedup
# Archive old files to memory/archive/
python3 scripts/memory-compressor.py archive --older-than 30
# Show compression stats
python3 scripts/memory-compressor.py stats
# Dry run (show what would happen without changing anything)
python3 scripts/memory-compressor.py compress --older-than 7 --dry-run
Commands
| Command | Purpose |
|---------|---------|
| analyze | Show memory directory analysis (sizes, ages, duplication) |
| compress | Compress old daily files into weekly summaries |
| dedup | Find and remove duplicate content across files |
| archive | Move old files to memory/archive/ |
| stats | Show compression history and space savings |
| restore | Restore archived file back to memory/ |
Safety
- Dry run by default for destructive operations: Use
--dry-runto preview changes - Archive, don't delete: Old files moved to
memory/archive/, never deleted - Backup before compress: Creates timestamped backup before any modification
- Preserves recent files: Never touches files less than 3 days old
- Skip critical files: MEMORY.md, heartbeat-state.json, and config files are never modified