"Programmatically measure and trim memory file sizes without LLM calls. Use for memory hygiene, context budget management, and enforcing token limits on memory/*.md files."
Resources
1Install
npx skillscat add 0xjohmsmith/openclaw/context-management Install via the SkillsCat registry.
SKILL.md
Context Management
Quick Reference
All operations via scripts/context_manager.py. Pure string-length estimation (tokens = len(text) / 4).
Default max: 5000 tokens per file.
Check sizes
# Single file
python3 scripts/context_manager.py check memory/TraderMemory.md
# All files in directory
python3 scripts/context_manager.py check-all memory/Custom limit
python3 scripts/context_manager.py check memory/TraderMemory.md --max-tokens 3000Memory backup
bash skills/context-management/scripts/backup_memory.shCopies full workspace to /home/othmane/tmp/openclaw/memory-backups/<timestamp>/. Auto-prunes backups >7 days. Runs hourly via cron.
MemoryManager Workflow
- Run
check-all memory/+ individual checks onsecret-sauce/files - For any file over 5000 tokens → read the file, then use an LLM call to condense it
- The LLM prompt: "condense this memory file to under 5000 tokens (~20000 chars). preserve all alpha, actionable levels, lessons, and open positions. remove redundancy, stale info, and verbose phrasing."
- Write the condensed version back, then
checkagain to verify - Exception:
secret-sauce/files are immutable — flag to dev0xx, never modify.
Memory management is handled by the Auditor. See agents/auditor.md.
Agent Awareness
All agents (Analyst, Quant, Trader) must follow these constraints when writing to memory:
- Max 5000 tokens (~20000 chars) per memory file.
- Be terse. Numbers > sentences. Levels > narratives.
- Replace existing sections, don't append. Kill stale data.