How to Fix OpenClaw Compaction Cost Issues
Long conversations in OpenClaw trigger automatic compaction โ a process that summarizes older messages to free up context window space. By default, OpenClaw uses your primary model (often Opus) for compaction, resulting in expensive summarization calls that can cost more than the actual conversation. This guide shows you how to switch compaction to Claude Haiku and tune settings to reduce compaction costs by 85%.
Why This Is Hard to Do Yourself
These are the common pitfalls that trip people up.
Invisible compaction calls
Compaction happens automatically in the background. You see the API charges but don't realize they're from summarization, not your actual requests
Opus for summarization
Default config uses your primary model for compaction. Summarizing with Opus costs 50x more than using Haiku
Aggressive trigger threshold
Default triggers at 60% context window usage, causing frequent compaction even when there's plenty of room left
Over-aggressive summarization
Compaction discards too much context, causing the model to lose track of earlier conversation details
Step-by-Step Guide
Understand how compaction works
Check current compaction behavior.
Check current compaction settings
See what model is being used.
Switch compaction model to Haiku
Use the cheapest model for summarization.
Warning: Haiku is 98% as good as Opus at summarization but costs 50x less. For compaction specifically, the quality difference is imperceptible.
Adjust trigger threshold
Reduce compaction frequency.
Warning: Setting threshold above 0.9 risks hitting hard context limits, which causes errors. 0.8-0.85 is the sweet spot for most use cases.
Reduce context window usage
Prevent compaction from being needed.
Verify compaction savings
Measure before and after costs.
Optimize Your Entire OpenClaw Cost Structure
Compaction is just one source of hidden costs. Our experts audit your entire OpenClaw setup โ routing, budgets, compaction, automations โ and implement optimizations that typically save $500-2000/month.
Get matched with a specialist who can help.
Sign Up for Expert Help โ