Goal: cut input tokens to the minimum that preserves task quality.
Principle: diagnose → apply the single highest-impact fix → re-measure → repeat.
Use the bundled script to audit and apply defaults quickly:
bash
python scripts/context_optimizer.py
python scripts/context_optimizer.py --apply
python scripts/context_optimizer.py --apply --aggressive
The script auto-detects config path, validates after writing, and rolls back on failure. Use --config <path> for a specific file.
After running, verify with /status and /usage tokens.
If script use is not enough or unavailable, run:
text
/status
/context detail
/usage tokens
Identify the dominant sink: bootstrap, tool output, memory retrieval, or long-session buildup.
Work top-down and stop when usage is acceptable.
Trim AGENTS.md, SOUL.md, TOOLS.md, USER.md, MEMORY.md, and heavy skill files. Remove filler and move rarely-needed detail into references read on demand.
Set smaller bootstrap/image limits and related defaults. See references/configs.md for full config examples.
Reduce web search/fetch payloads and prefer targeted reads (line ranges/excerpts) over full dumps.
See references/configs.md for full config examples.
Enable context pruning so older, large tool payloads expire automatically while recent turns stay intact.
See references/configs.md for full config examples.
Lower recall volume and raise relevance thresholds; keep deduplication and recency bias enabled. Narrow memorySearch.extraPaths if too broad.
See references/configs.md for full config examples.
Use /compact mid-session, /new for topic shifts, /reset when recovery is unlikely. Enable automatic compaction for sessions that routinely run long.
See references/configs.md for full config examples.
After each change:
openclaw config validate./status and /usage tokens.SymptomGo toEvery turn is expensive, even simple onesFix 1 (bootstrap)Cost spikes after searches or file readsFix 2 (tool output)Long sessions get slow/truncatedFix 3 (pruning) + Fix 5 (session hygiene)Memory results feel noisy or irrelevantFix 4 (memory retrieval)Screenshots are costlyFix 1, set imageMaxDimensionPx: 512"Context too large" / truncation errorsFix 5 ( /compact or /new), then Fix 3
See references/aggressive-config.md for the full aggressive all-in-one config.
See references/commands.md for the full commands cheat sheet.