OpenClaw

OpenClaw "Auto-compaction timed out before the next model request. Try again or run /compact."

Last checked

The error

Auto-compaction timed out before the next model request. Try again or run /compact.

auto-compaction failed for ollama/qwen3:8b: <reason>
preflight compaction failed: <reason>
Compaction cancelled

The first line is the chat reply. The others are Gateway log lines; the provider, model and reason vary.

Before the next model call, OpenClaw tried to summarize older messages so the session fits the context window, and the summary request made no progress within its time window. This is common with slow local models or very large sessions. Point compaction at a faster model with agents.defaults.compaction.model, or raise agents.defaults.compaction.timeoutSeconds (default 180). Then run /compact by hand, or /new to start a fresh session.

Why it happens

Compaction is a model call. OpenClaw sends the older part of the transcript to a model and asks for a summary. If that model is slow, overloaded or rate limited, the summary times out or fails and the turn cannot continue.

  1. A slow summary model. By default compaction uses the session's primary model, so a local model on modest hardware has to summarize a huge transcript. A 905k-token session on 2026.9.7 timed out every turn after about 3 minutes (issue #164220).
  2. Thinking enabled for summaries. Reasoning tokens eat the time window; OpenClaw already prefers thinking off for native local Ollama.
  3. Provider errors during summarization: a 429 quota, overload, or auth failure. Before the fix for issue #166438, these surfaced only as a generic agent-runner-failure event.
  4. Compaction cancelled: a safeguard hook or a stop cancelled the compaction. Usually the log line next to it gives the reason.

The fix

  1. 1 Find the real reason: openclaw logs --follow, then look for auto-compaction failed for, preflight compaction failed, or [compaction-diag] lines.
  2. 2 Use a faster summary model: openclaw config set agents.defaults.compaction.model "<provider/model>".
  3. 3 Give slow models more time: openclaw config set agents.defaults.compaction.timeoutSeconds 600. The window resets on every streamed token, and a whole compaction is capped at 10 windows.
  4. 4 Turn summary thinking down: set agents.defaults.compaction.thinkingLevel to off or low.
  5. 5 Restart the Gateway, then run /compact in the chat. If it still fails, /new starts a clean session; the old transcript stays on disk.
openclaw config set agents.defaults.compaction.timeoutSeconds 600

Why the log only said agent-runner-failure

Issue #166438 reported that during a multi-hour compaction failure loop the only signal was a generic agent-runner-failure event and the heartbeat consecutiveErrors counter. Nothing said that compaction was the failing stage or why. The fix (PR #167016, merged 8 October 2026) logs the actual reason and compaction model for both /compact and auto-compaction. On builds without it, match the time of the failure against the gateway log's model fallback decision lines and your heartbeat run history to find the provider error.

A related change (PR #164246, merged 4 October 2026) stops a summary timeout from dead-ending every later turn: OpenClaw commits the compaction without a summary and logs reason=timeout summary=deterministic. Check your version's release notes before relying on either fix.

Still failing?

  • If the reason is a 429 or overload, the compaction model's provider is the problem; switch compaction.model to another provider.
  • If compaction never triggers before the context fills, set agents.defaults.compaction.maxActiveTranscriptBytes to compact earlier.
  • If the agent forgets details after compaction succeeds, see the silent context compression decoder for keepRecentTokens and postCompactionSections.

Related errors

Full guideOpenClaw Memory Compaction Explained: What It Is, When It Triggers, and How to Control ItEvery error, one pageOpenClaw "Context Window Reached" Error: Why It Happens and How to Stop It

Hit a different error?

Paste any agent error and get the cause and fix in seconds.

Open the decoder

Frequently asked questions

What is compaction in OpenClaw?

When a session nears the model's context limit, OpenClaw summarizes older turns into one entry and keeps recent messages verbatim. The full history stays on disk; only what the model sees changes.

Can I turn compaction off?

Setting agents.defaults.compaction.enabled to false disables proactive threshold compaction only. Overflow recovery and manual /compact still run, so a too-large session can still hit this error.

Is there a maxContextTokens setting?

No. Older guides mention it, but it is not an OpenClaw config key. The real knobs live under agents.defaults.compaction, such as timeoutSeconds, model, keepRecentTokens and maxActiveTranscriptBytes.

Stop firefighting agent errors

Decoding errors one at a time is the manual version of what BetterClaw automates. Run your agents on a no-code AI agent platform with managed models, retries and config validation built in.

Free plan available · Pro $49/mo · BYOK · 7-day money-back guarantee