Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Bug Report: Gateway becomes completely unresponsive after compaction triggers
Issue Description
After a compaction event fires on the main session, the Gateway stops responding to all messages (webchat). Messages are sent but receive no reply. Gateway restart is required to recover.
Environment:
- Platform: Ubuntu (VM on Tencent Cloud)
- OpenClaw version: v2026.5.2
- Node version: v24.14.1
- Memory: 3.7GB total
- Webchat channel (direct conversation, not Feishu)
Compaction config:
"compaction": {
"truncateAfterCompaction": true,
"maxActiveTranscriptBytes": "10mb"
}Steps to Reproduce
- Main session runs for an extended period with significant conversation history
- Compaction triggers (context overflow or byte threshold reached)
- User sends a message via webchat after the system prompt about compaction appears
- Gateway becomes completely unresponsive — no reply, no error, no feedback
- Only Gateway restart (
systemctl --user restart openclaw-gateway) restores functionality
Actual Behavior
After compaction triggers:
- Compaction itself completes successfully (seen in logs:
[compaction] rotated active transcript after compactionin ~30 seconds) - But subsequent messages get no response
- Session shows
state=processing queueDepth=1 reason=queued_behind_active_workfor extended periods - Log shows
agent cleanup timed outevents - Liveness warnings show high
eventLoopDelayMaxMsvalues (up to 3454ms) - WebSocket connections (sessions.list, chat.history) continue to work for other sessions but main session is stuck
Expected Behavior
Messages sent during/after compaction should either:
- Be processed after compaction completes, or
- Return an error message indicating the session is busy with compaction
Log Evidence
# Stuck session during compaction window
12:36:04 long-running session: sessionId=main sessionKey=agent:main:main state=processing age=125s queueDepth=1 reason=queued_behind_active_work classification=long_running
12:36:34 long-running session: sessionId=main sessionKey=agent:main:main state=processing age=155s queueDepth=1 reason=queued_behind_active_work
12:37:21 [compaction] rotated active transcript after compaction (sessionKey=agent:main:main)
12:39:37 long-running session: sessionId=main sessionKey=agent:main:main state=processing age=135s queueDepth=0 reason=active_work classification=long_running
# Cleanup timeouts during the stuck period
12:30:36 agent cleanup timed out: runId=... sessionId=... step=pi-trajectory-flush timeoutMs=
12:33:05 agent cleanup timed out: runId=... sessionId=... step=pi-trajectory-flush timeoutMs=
# Event loop delays
12:21:55 liveness warning: reasons=event_loop_delay interval=31s eventLoopDelayP99Ms=897.1 eventLoopDelayMaxMs=1784.7
12:22:55 liveness warning: reasons=event_loop_delay,cpu interval=30s eventLoopDelayP99Ms=1891.6 eventLoopDelayMaxMs=3454 eventLoopUtilization=0.852
12:24:56 liveness warning: reasons=event_loop_delay,event_loop_utilization,cpu interval=30s eventLoopDelayP99Ms=3259 eventLoopDelayMaxMs=3259 eventLoopUtilization=0.999
Preliminary Root Cause Analysis
The issue appears to be in how messages are handled during/after preflightCompaction:
preflightCompactionexecutes synchronously inside the session lane (viaenqueueCommandInLaneinagent-runner.runtime-DCKwkWFL.jsline ~1742)setPhase("preflight_compacting")is set but has no timeout protection- During compaction, new messages from webchat arrive and are queued (
queueDepth=1) - After compaction completes, queued messages appear to not be properly dequeued/processed
- The session remains in
state=processingindefinitely
The replyOperation.abortSignal passed to compaction does not have a timeout that would interrupt a slow compaction.
Possible Related Factors
- Session file:
/root/.openclaw/agents/main/sessions/b84aa148-4a29-4f2f-94e5-9b7296aabbf3.jsonl - Context overflow events:
Context overflow: estimated context size exceeds safe threshold during tool loop(compaction attempts: 0 — meaning preflight compaction didn't run before overflow) - Compaction succeeded but didn't prevent the stuck state
- Recovery required full Gateway restart, not just session reset
Tags
bug compaction session-lane webchat v2026.5.2
Reacted by clawsweeper
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon May 3, 2026
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
Close as duplicate/superseded: the remaining compaction-causes-unresponsive-session behavior is already tracked by the open compaction lane-starvation issue, with the successful-compaction stuck path tracked separately; the same-author fix PR for this issue is closed unmerged and is no longer an implementation path.
Canonical path: Keep the remaining compaction lane-starvation work on #53008 and the successful-compaction stuck proof on #70334, linking this issue's WebChat logs there if needed.
So I’m closing this here and keeping the remaining discussion on #53008 and #70334.
Review details
Best possible solution:
Keep the remaining compaction lane-starvation work on #53008 and the successful-compaction stuck proof on #70334, linking this issue's WebChat logs there if needed.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level: current main still awaits preflight compaction inside the foreground reply path and serializes same-session work while that operation is active. I did not run a live WebChat replay.
Is this the best way to solve the issue?
Yes for tracker cleanup: closing this as a duplicate of the canonical lane-starvation tracker is the narrowest maintainer outcome because the attempted fix PR is closed unmerged and the remaining work needs the broader compaction scheduling decision already tracked elsewhere.
Security review:
Security review: This is non-PR issue triage with no patch or security-sensitive report to review.
What I checked:
runReplyAgentawaitsrunPreflightCompactionIfNeededbefore the normal reply run continues, so compaction still occupies the active reply operation on current main333f65fc8a1247b67a9dbc701d8ab1a36ec5bb14. (src/auto-reply/reply/agent-runner.ts:1302, 333f65fc8a12)replyOperationtopreflight_compactingimmediately before invoking embedded compaction, matching the reported compaction window. (src/auto-reply/reply/agent-runner-memory.ts:627, 333f65fc8a12)isReplyRunStreamingForSessionIdandqueueReplyRunMessageboth requireoperation.phase === "running", so compacting operations do not use the active streaming queue helper. (src/auto-reply/reply/reply-run-registry.ts:488, 333f65fc8a12)Likely related people:
src/auto-reply/reply/agent-runner-memory.ts,src/auto-reply/reply/reply-run-registry.ts,src/agents/pi-embedded-runner/compact.ts)src/auto-reply/reply/agent-runner-memory.ts,src/gateway/server-methods/chat.ts,src/process/command-queue.ts)src/auto-reply/reply/agent-runner-memory.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against 333f65fc8a12.
njuboy11 commentedon May 3, 2026
Update: Fix submitted
We found and fixed the root cause. PR: #76485
Root cause:
queueReplyRunMessage()only accepted messages whenoperation.phase === 'running', silently dropping messages sent duringpreflight_compactingormemory_flushing. This caused queued webchat messages to never be drained after compaction completed.Fix: Expanded accepting phases in
queueReplyRunMessageto include'preflight_compacting'and'memory_flushing'.5 regression tests added, all passing. Existing registry tests: still 5/5 passing.