openclaw - 💡(How to fix) Fix [Bug]: Preflight compaction required but failed: Already compacted (infinite loop)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

After upgrading OpenClaw from 2026.5.20 to 2026.5.22, every agent session message fails with Error: Preflight compaction required but failed: Already compacted. The compaction fires on every message (triggered by as little as 61 tokens over an internal ~45K budget), but then immediately fails with reason=already_compacted_recently. This creates an infinite retry loop. Downgrading to 2026.5.20 resolves the issue immediately — confirmed as a regression in 5.22.

Error Message

fails with Error: Preflight compaction required but failed: Already compacted. The 5. Wait 40-100 seconds → message fails with compaction error

Root Cause

After upgrading OpenClaw from 2026.5.20 to 2026.5.22, every agent session message fails with Error: Preflight compaction required but failed: Already compacted. The compaction fires on every message (triggered by as little as 61 tokens over an internal ~45K budget), but then immediately fails with reason=already_compacted_recently. This creates an infinite retry loop. Downgrading to 2026.5.20 resolves the issue immediately — confirmed as a regression in 5.22.

Fix Action

Fix / Workaround

  1. Install or upgrade to OpenClaw 2026.5.22 (a374c3a) 2. Start gateway: openclaw gateway run --auth none --port 18789 3. Configure agent with provider deepseek/deepseek-chat 4. Open dashboard and send any message to the agent 5. Wait 40-100 seconds → message fails with compaction error 6. Check gateway logs for already_compacted_recently

Impact and severity: High — Agent is completely unable to process any messages. The only workaround is downgrading to 2026.5.20. Impacts all users on 5.22+ with large system prompts (our system prompt is ~38K).


High — Agent is completely unable to process any messages. The only workaround is
     downgrading to 2026.5.20. Impacts all users on 5.22+ with large system prompts (our
     system prompt is ~38K).

Code Example

[agent/embedded] [context-overflow-precheck] sessionKey=agent:xiaoqi:main
       provider=deepseek/deepseek-chat route=compact_then_truncate
       estimatedPromptTokens=47439 promptBudgetBeforeReserve=45536
       overflowTokens=172 toolResultReducibleChars=244
       reserveTokens=20000 effectiveReserveTokens=20000

     [compaction-diag] end sessionKey=agent:xiaoqi:main
       trigger=overflow provider=deepseek/deepseek-chat attempt=1 maxAttempts=3
       outcome=failed reason=already_compacted_recently durationMs=2345

     [context-overflow-recovery] Tool result truncation did not help:
       no oversized or aggregate tool results
     Auto-compaction failed. Preserving existing session mapping.

     Impact and severity:
     HighAgent is completely unable to process any messages. The only workaround is
     downgrading to 2026.5.20. Impacts all users on 5.22+ with large system prompts (our
     system prompt is ~38K).
RAW_BUFFERClick to expand / collapse

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

After upgrading OpenClaw from 2026.5.20 to 2026.5.22, every agent session message fails with Error: Preflight compaction required but failed: Already compacted. The compaction fires on every message (triggered by as little as 61 tokens over an internal ~45K budget), but then immediately fails with reason=already_compacted_recently. This creates an infinite retry loop. Downgrading to 2026.5.20 resolves the issue immediately — confirmed as a regression in 5.22.

Steps to reproduce

  1. Install or upgrade to OpenClaw 2026.5.22 (a374c3a) 2. Start gateway: openclaw gateway run --auth none --port 18789 3. Configure agent with provider deepseek/deepseek-chat 4. Open dashboard and send any message to the agent 5. Wait 40-100 seconds → message fails with compaction error 6. Check gateway logs for already_compacted_recently

Expected behavior

Messages should be processed normally. Compaction should only trigger when the session approaches the actual context window limit (1M tokens for deepseek-chat), not when it exceeds an internal budget of ~45K by 61-172 tokens.

Actual behavior

Every message triggers this cycle: 1. Preflight check detects overflow (61-172 tokens over a ~45K internal budget) 2. Compaction fires but immediately fails: already_compacted_recently 3. Tool result truncation does not help 4. Message fails after 40-100 seconds 5. Agent becomes completely unusable

OpenClaw version

2026.5.22 (a374c3a)

Operating system

WSL 2 (Ubuntu 26.04) on Windows 11

Install method

npm (npm install -g openclaw)

Model

deepseek/deepseek-chat

Provider / routing chain

DeepSeek via openai-completions API (https://api.deepseek.com/v1)

Additional provider/model setup details

Model configured with contextWindow: 1000000 (1M tokens) in models.json and openclaw.json. Also tried setting agents.defaults.contextTokens=200000 and compaction.budgetMargin=50000 — neither helped.

Logs, screenshots, and evidence

[agent/embedded] [context-overflow-precheck] sessionKey=agent:xiaoqi:main
       provider=deepseek/deepseek-chat route=compact_then_truncate
       estimatedPromptTokens=47439 promptBudgetBeforeReserve=45536
       overflowTokens=172 toolResultReducibleChars=244
       reserveTokens=20000 effectiveReserveTokens=20000

     [compaction-diag] end sessionKey=agent:xiaoqi:main
       trigger=overflow provider=deepseek/deepseek-chat attempt=1 maxAttempts=3
       outcome=failed reason=already_compacted_recently durationMs=2345

     [context-overflow-recovery] Tool result truncation did not help:
       no oversized or aggregate tool results
     Auto-compaction failed. Preserving existing session mapping.

     Impact and severity:
     High — Agent is completely unable to process any messages. The only workaround is
     downgrading to 2026.5.20. Impacts all users on 5.22+ with large system prompts (our
     system prompt is ~38K).

Impact and severity

High — Agent is completely unable to process any messages. The only workaround is downgrading to 2026.5.20. Impacts all users on 5.22+ with large system prompts (our system prompt is ~38K).

Additional information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Messages should be processed normally. Compaction should only trigger when the session approaches the actual context window limit (1M tokens for deepseek-chat), not when it exceeds an internal budget of ~45K by 61-172 tokens.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING