OpenClaw Auto-Compaction Timeout: Why a Successful Compaction Still Ends in /new
Auto-compaction is supposed to save long sessions from context overflow. But on
embedded agent sessions, OpenClaw can successfully compact the session, then retry
the original prompt โ and then hit a 120-second LLM idle timeout on the
retry, exhausting all retries and forcing a /new reset anyway. The
compaction worked. The session was killed regardless.
The Failure Sequence
Issue #67750 documents the exact chain of events:
- Session hits context overflow threshold
- OpenClaw detects overflow, initiates auto-compaction
- Compaction runs successfully โ old messages summarized, context trimmed
- OpenClaw retries the original prompt with the compacted context
- The retried LLM call hits a 120-second idle timeout (provider taking too long)
- OpenClaw exhausts retry attempts
- Falls back to
/newโ session reset, context lost
From the user's perspective: agent stops mid-task, session resets, all context is gone โ same result as if compaction had never run. But compaction did run successfully. The failure is in the retry layer, not the compaction itself.
Why the Retry Times Out
Compaction runs a silent LLM summarization turn before the retry. On long sessions, that summarization call can itself be slow. By the time the original prompt retry fires, the provider may already be under load โ and the retry inherits the same 120-second timeout window with no fresh budget. A slow summarization pass + slow retry = timeout.
Fix #1 โ Reduce Context Overhead Before Sessions Get Long
The best fix is preventing the situation. Keep bootstrap files lean so compaction runs faster and the retry has more timeout headroom:
- Trim MEMORY.md to under 500 tokens (archive old entries)
- Delete BOOTSTRAP.md if you still have it
- Move reference content to skills rather than workspace files
See our context bloat guide for the full workflow.
Fix #2 โ Increase the LLM Idle Timeout
If your provider is legitimately slow (local Ollama, VPS with limited CPU, or a congested API endpoint), increasing the timeout gives the retry more room:
// openclaw.json
{
"llm": {
"idleTimeoutMs": 300000 // 5 minutes instead of 120 seconds
}
}
Trade-off: hung requests will take longer to surface as errors. Only increase this if you know your provider is slow but reliable โ not if you're on a fast API that shouldn't need more than 2 minutes.
Fix #3 โ Use /compact Manually Before Sessions Get Critical
Don't wait for auto-compaction to trigger at overflow. Run /compact
proactively when sessions get long โ before the context limit is hit. This gives
compaction and the subsequent retry their full timeout budget rather than running
under pressure.
/compact
A good rule: if a session has been running for more than 2 hours or 50+ turns,
run /compact manually during a natural pause in work.
Fix #4 โ Use Lossless Claw for Long Sessions
Lossless Claw replaces OpenClaw's compaction entirely with a DAG-based system that never hits the overflow threshold in the same way. If you're regularly running sessions long enough to trigger this bug, it's worth installing.
TL;DR
- Auto-compaction succeeds โ retry hits 120s LLM timeout โ forced
/newanyway - Fix A: Lean workspace files = faster compaction + more retry headroom
- Fix B: Increase
llm.idleTimeoutMsif provider is legitimately slow - Fix C: Run
/compactmanually before sessions get critical - Fix D: Install Lossless Claw for persistent long sessions
- Tracking: GitHub issue #67750
Losing session context from compaction failures?
ClawReady configures workspace architecture and compaction settings to minimize context loss โ including Lossless Claw setup for long-running agent workflows.
Book a Free Call โ