Problem
Auto-compaction only fires when the session hits the context limit (~200K tokens). By that point:
- Responses are already 5–10x slower than at session start (sending 180K+ tokens per request)
- The compaction itself may fail if the session contains thinking blocks
- The user experience is: things get progressively slower with no warning, then freeze
There is no config option to trigger compaction earlier (e.g. at 60% or 70% of the context window).
Real-world impact
Running claude-sonnet-4-6 (200K context). Sessions become noticeably slow at ~120–130K tokens and unusable at ~150K+. Auto-compaction at 200K is too late — by then responses take 5–10 minutes on a Telegram session.
Today: 3 separate manual interventions needed across the same session (12:43pm, 3:18pm, 11:17pm) because the session kept re-bloating between compactions. No way to prevent this without constant manual monitoring.
Proposed fix
Add a config option to trigger auto-compaction at a percentage or absolute token threshold:
{
"agents": {
"defaults": {
"compaction": {
"autoCompactThreshold": 0.70
}
}
}
}
When totalTokens crosses contextTokens * autoCompactThreshold, OpenClaw automatically compacts before the next response — not after hitting the wall.
Why this matters more than it seems
The current UX is: session gets slow → user notices something is wrong → user has to know to type /compact → if the session has thinking blocks, /compact silently fails → user is stuck.
With early auto-compaction: sessions stay fast indefinitely, no manual intervention required, thinking-block sessions get reset before they become unrecoverable.
Related
Problem
Auto-compaction only fires when the session hits the context limit (~200K tokens). By that point:
There is no config option to trigger compaction earlier (e.g. at 60% or 70% of the context window).
Real-world impact
Running claude-sonnet-4-6 (200K context). Sessions become noticeably slow at ~120–130K tokens and unusable at ~150K+. Auto-compaction at 200K is too late — by then responses take 5–10 minutes on a Telegram session.
Today: 3 separate manual interventions needed across the same session (12:43pm, 3:18pm, 11:17pm) because the session kept re-bloating between compactions. No way to prevent this without constant manual monitoring.
Proposed fix
Add a config option to trigger auto-compaction at a percentage or absolute token threshold:
{ "agents": { "defaults": { "compaction": { "autoCompactThreshold": 0.70 } } } }When
totalTokenscrossescontextTokens * autoCompactThreshold, OpenClaw automatically compacts before the next response — not after hitting the wall.Why this matters more than it seems
The current UX is: session gets slow → user notices something is wrong → user has to know to type
/compact→ if the session has thinking blocks,/compactsilently fails → user is stuck.With early auto-compaction: sessions stay fast indefinitely, no manual intervention required, thinking-block sessions get reset before they become unrecoverable.
Related