Install
openclaw skills install token-saverReduce OpenClaw AI costs with model-aware optimization. Features dynamic compaction presets based on your model's context window, intelligent file compression, and robust model detection with fallback. Supports Claude, GPT-4, Gemini, DeepSeek, and more.
openclaw skills install token-saver💡 Did you know? Every API call sends your workspace files (SOUL.md, USER.md, MEMORY.md, AGENTS.md, etc.) along with your message. These files count toward your context window, slowing responses and costing real money on every message.
Token Saver v3 is model-aware — it knows your model's context window and adapts recommendations accordingly. Using Gemini's 1M context? Presets scale up. On GPT-4o's 128K? Presets adjust down.
| Feature | v2 | v3 |
|---|---|---|
| Compaction presets | Fixed (80K/120K/160K) | Dynamic (% of model's context) |
| Model detection | Fragile, env-only | Robust fallback chain |
| Context windows | Not tracked | Full registry (9 models) |
| Model info | Hardcoded pricing | JSON registry, easy updates |
| Already-optimized | Re-compressed | Smart bypass |
| Command | What it does |
|---|---|
/optimize | Full dashboard — files, models, context usage % |
/optimize tokens | Compress workspace files (auto-backup) |
/optimize compaction | Chat compaction control (model-aware) |
/optimize compaction balanced | Apply balanced preset (60% of context) |
/optimize compaction 120 | Custom threshold (compact at 120K) |
/optimize models | Detailed model audit with registry |
/optimize revert | Restore backups, disable persistent mode |
Shows current model, context window, and usage percentage:
🤖 Model: Claude Opus 4.5 (200K context)
Detected: openclaw.json
📊 Context Usage: [████████░░░░░░░░░░░░] 42% (84K/200K)
Scans all .md files, shows token count and potential savings. Smart bypass skips already-optimized files.
File-aware compression:
Presets adapt to your model's context window:
| Preset | % of Context | Claude 200K | GPT-4o 128K | Gemini 1M |
|---|---|---|---|---|
| Aggressive | 40% | 80K | 51K | 400K |
| Balanced | 60% | 120K | 77K | 600K |
| Conservative | 80% | 160K | 102K | 800K |
| Off | 95% | 190K | 122K | 950K |
24+ models with context windows, pricing, and aliases:
Detection priority:
--model=...)SKILL_MODEL, OPENCLAW_MODEL)~/.openclaw/openclaw.json)Unknown model handling:
opus-6.5 won't fuzzy-match to opus-4.5scripts/models.jsonAdds writing guidance to AGENTS.md for continued token efficiency:
| File | Writing Style |
|---|---|
| SOUL.md | Evocative, personality-shaping |
| AGENTS.md | Dense instructions, symbols OK |
| USER.md | Key:value facts |
| MEMORY.md | Ultra-dense data |
.backup extension/optimize revert restores everythingclawhub install token-saver --registry "https://www.clawhub.ai"