fix(auto-reply): add memory flush failure tracking with retry exhaustion#88676
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 31, 2026, 12:44 PM ET / 16:44 UTC. Summary PR surface: Source +103, Tests +235. Total +338 across 4 files. Reproducibility: yes. from source inspection: current main catches memoryFlush failures without advancing durable state, and the caller returns visible error payloads before the normal reply path. I did not run a live provider-crash reproduction in this read-only review. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the non-destructive exhaustion path only after redacted real Gateway or close integration proof and explicit maintainer acceptance of the fail-open policy; keep broader configurable escalation or force-truncate behavior with #85645 or #30452. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: current main catches memoryFlush failures without advancing durable state, and the caller returns visible error payloads before the normal reply path. I did not run a live provider-crash reproduction in this read-only review. Is this the best way to solve the issue? Mostly yes: the non-destructive exhaustion marker is a narrow safer shape than transcript truncation. The remaining question is whether maintainers accept fail-open after three failures and whether the contributor can provide current real behavior proof. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against c7b190beec73. Label changesLabel justifications:
Evidence reviewedPR surface: Source +103, Tests +235. Total +338 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
ea725dc to
74385e7
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ive flush skip After MAX_FLUSH_FAILURES consecutive memory flush failures, mark the flush as attempted for the current compaction cycle instead of truncating the session transcript. The next compaction cycle will retry. This avoids data loss while still breaking the retry loop. Reserve the three new failure-tracking session fields in the slot key list so plugins cannot collide with them.
74385e7 to
b3737db
Compare
|
Addressed both P1 findings in b3737db: [P1] Reserve the new session fields — Fixed Added [P1] Replace destructive force-truncation with non-destructive loop break — Fixed Removed the entire New behavior after
Failure tracking (kept):
All 40 agent-runner-memory tests pass. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer land-ready note for Policy decision: accepting the non-destructive fail-open tradeoff for this PR. After three consecutive non-abort memoryFlush failures, OpenClaw marks only the current compaction cycle as exhausted so later messages can proceed; it does not force-truncate or delete transcript history. Configurable escalation / reset policy remains follow-up scope. Local proof run: node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts
pnpm check:test-types
.agents/skills/autoreview/scripts/autoreview --mode local
git diff --checkResults: CI proof: Known proof gap: no live Gateway/provider-crash repro was run. The failure path is covered with focused regression tests using a rejected |
Summary
Fix memory flush failures permanently wedging sessions by adding per-session failure tracking, bounded retry, and a non-destructive retry-exhaustion path.
When a session exceeds the
memoryFlushthreshold, OpenClaw starts an embedded agent turn to create a handoff summary before compacting history. If that provider call fails, currentmainonly logs/surfaces the error and persists no failure state. The transcript stays over threshold, so each later user message can retry the same failing flush and never reach the normal reply path.This PR records consecutive non-abort memory flush failures and, after three failures in the same compaction cycle, marks that cycle as exhausted so the next normal reply can proceed. No transcript content is truncated or deleted by this PR.
Partially addresses #85645.
Changes
memoryFlushFailureCount,memoryFlushLastFailedAt, andmemoryFlushLastFailureErrortoSessionEntry.memory_flush_failedlifecycle events.memoryFlushCompactionCountfor the current cycle, emitmemory_flush_exhausted, and show a visible warning that memory flush is being skipped for this cycle.Real behavior proof
node:24-bookwormcoverage before maintainer fixup.node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts pnpm check:test-types .agents/skills/autoreview/scripts/autoreview --mode local git diff --checkrunWithModelFallbackrejection against real session-store JSON on disk.Test plan
node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.tspnpm check:test-typesto confirm the PR-owned type error is gone; unrelated current-main doctor migration type errors remain locally.agents/skills/autoreview/scripts/autoreview --mode localgit diff --check