๐Ÿ“‰Cost Optimization

How to Fix OpenClaw Compaction Cost Issues

Intermediate30-60 minutesUpdated 2025-01-15

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

Step 1

Understand how compaction works

Check current compaction behavior.

Step 2

Check current compaction settings

See what model is being used.

Step 3

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.

Step 4

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.

Step 5

Reduce context window usage

Prevent compaction from being needed.

Step 6

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 โ†’

Frequently Asked Questions