-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
memoryFlush has no escalation when assistant process dies mid-flush — session permanently over threshold, every subsequent message wedges #85645
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
When
memoryFlushtriggers but the assistant model required to produce the handoff summary crashes (e.g. Codexapp-server connection closed during startup), the flush silently fails. The session's on-disk transcript stays over threshold. Every subsequent user message hits the same wedge —memoryFlush checkre-fires, the same flush attempt fails (because the same broken provider is still broken or the session is now even larger), and the user-facing channel sees no reply. No lifecycle escalation, no fallback path.A gateway restart clears the in-memory
stalled_agent_runbut does NOT clear the on-disk bloat. Without a separate, manual transcript truncation, the next inbound message wedges again within seconds.Symptom (one observed incident)
agent=forge, sessionc0b5jmpcq4s, Slack channel inbound, 2026-05-23 UTC:Two consecutive wedges on the same session in <30 minutes, both invisible to monitoring beyond the existing
stalled_agent_runevent (which doesn't surface the on-disk-bloat distinction).Root cause
memoryFlushis implemented as an assistant turn — the gateway prompts the session's own assistant to write a handoff summary, then truncates older history once that summary is written. This is fine when the assistant is healthy. It fails closed when the assistant itself is the broken dependency:sessions cleanup/ forced truncation) when flush keeps failing.Result: the session is stuck in a permanent flush-attempt loop with no observable degradation signal beyond the underlying provider error (which is reported as a provider failure, not a session-state failure).
Reproduction
Hard to reproduce on demand, but the precondition is:
memoryFlushthreshold (>130k tokens in our config —softThresholdTokenssemantics per openclaw-memoryflush-semantics-reversed).Reliable repro recipe (untested upstream, matches our gateway behavior):
Suggested fix
Add a per-session flush-failure escalation tracker in the gateway:
The escalation path needs to be provider-independent — it should be able to truncate the JSONL transcript and emit a placeholder "[session reset: prior context dropped due to repeated flush failures]" entry without calling out to any LLM. This is the safety valve: a degraded session that loses context is far better than a silent permanent wedge.
Configurability:
{ \"agents\": { \"defaults\": { \"memoryFlush\": { \"escalation\": { \"enabled\": true, \"thresholdMinutes\": 5, \"maxFailures\": 2, \"action\": \"force-truncate\" // or \"alert-only\" for observability-first } } } } }Related upstream issue #30452 (flush-then-reset mode) covers the configurable-mode angle; this issue is the failure-mode angle — even with the default mode, you need an escape hatch when the assistant required by flush is the failing dependency.
Observability
Independent of the fix, two lifecycle events would have caught this in monitoring:
memory.flush.failed(currently the only signal is the underlying provider error, not session-attributed)memory.flush.escalated(would distinguish "transcript force-truncated" from "transcript still bloated")Workaround
openclaw gateway restart— clears in-memorystalled_agent_run. Does NOT clear on-disk bloat.~/.openclaw/workspace-<agent>/sessions/<sessionId>.jsonl(or use a script that does the equivalent).memoryFlush check tokenCountreads below threshold before declaring recovery.Skipping step 2 → next inbound message re-wedges within seconds.
Environment
openai-codex/gpt-5.5(Codex OAuth via ChatGPT subscription)memoryFlush.softThresholdTokensconfigured such that flush fires at ~130k tokenCount; affected session at 163k on-diskRelated
Downstream tracking: rhclaw/openclaw-server#291