Repository navigation
fix: preserve conversation after memory flush exhaustion - #132010
Conversation
Optional memory maintenance must not reset unsummarized conversation history. Preserve ordinary replies after exhausted flush retries and surface required compaction failures through the existing recovery outcome. Fixes #131957
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 2:53 PM ET / 18:53 UTC. ClawSweeper reviewWhat this changesThe PR stops optional memory-flush exhaustion from resetting an active conversation, while retaining explicit recovery for required preflight-compaction failures. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking findings. This active maintainer-authored PR removes a source-proven session reset that current main still performs after optional memory-flush exhaustion, and it has focused boundary plus Gateway-path proof. Priority: P1 Review scores
Verification
How this fits togetherA channel turn enters the reply coordinator, which runs optional memory maintenance and preflight compaction before the main agent turn. These phases update the active session and then either continue the reply or return an explicit recovery message. flowchart LR
A[Inbound channel turn] --> B[Reply coordinator]
B --> C[Optional memory flush]
C --> D[Preflight compaction]
D --> E[Main agent turn]
E --> F[Channel reply]
D --> G[Explicit recovery reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -56, Tests +5, Docs +2. Total -49 across 4 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the coordinator free of memory-flush reset inference: preserve the active session after optional maintenance failure, and let the compaction owner return either successful compaction or its explicit recovery outcome. Do we have a high-confidence way to reproduce the issue? Yes, source reproducibly identifies the exhausted optional flush plus successful no-op preflight condition on current main; the supplied boundary and Gateway evidence exercise that scenario after the repair. Is this the best way to solve the issue? Yes. Removing the coordinator's reset inference is the clean owner-boundary repair because the compaction owner already decides whether compaction is required and surfaces its own failure outcome. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d43520b04c29. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Pre-merge verification for The boundary regression failed in the two intended cases before the fix, then passed all 17. Memory/preflight/reset/execution/followup siblings passed 173, and the resumed CLI-compaction shard passed 31: 221 focused/sibling tests passed. The changed-file gate passed. Exact-head hosted CI is successful, including openclaw/ci-gate. The Blacksmith Testbox proof ( The isolated Codex autoreview passed at its P0-only threshold. The fresh ClawSweeper review has no findings, no before-merge work, and no Rank-up moves. Native review, PR-head guards, and review artifacts are validated. Exact local commands and proof limitsnode scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-direct-runtime-config.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts src/auto-reply/reply/agent-runner-memory.preflight-stale-tokens.test.ts src/auto-reply/reply/agent-runner-session-reset.test.ts src/auto-reply/reply/agent-runner-execution-conversation-failures.test.ts src/auto-reply/reply/followup-turn-admission.test.ts src/auto-reply/reply/followup-turn-execution.test.ts src/agents/command/cli-compaction.test.tsThe auto-reply shard completed before interruption; the remaining CLI shard was explicitly resumed: node scripts/run-vitest.mjs src/agents/command/cli-compaction.test.tsnode scripts/check-changed.mjs -- docs/concepts/compaction.md src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts src/auto-reply/reply/agent-runner-execute.ts src/auto-reply/reply/agent-runner-run.tsGateway proof uses a synthetic provider/channel, not live Telegram. The pre-fix failure and required-compaction failure branch are regression evidence, not separate live Gateway scenarios. Earlier interrupted check/review attempts are not counted as passes. Native prepare encountered a GitHub HTTPS fetch HTTP 429; its exact retained lock was recovered only after verifying the owned child processes had exited. No landing gate was bypassed. |
|
Merged via squash.
|
…2010) Optional memory maintenance must not reset unsummarized conversation history. Preserve ordinary replies after exhausted flush retries and surface required compaction failures through the existing recovery outcome. Fixes openclaw#131957
Closes #131957
What Problem This Solves
Fixes an issue where conversations lost older, unsummarized context after optional pre-compaction memory maintenance exhausted its retries, even when the conversation was small and preflight compaction correctly had nothing to do. Required compaction failures could also be hidden by an automatic reset instead of giving the user the existing recovery guidance.
Why This Change Was Made
Memory maintenance failure is not evidence that conversation history should be discarded. The reply coordinator now leaves compaction decisions and failure reporting with the compaction owner, removing the exhaustion-triggered reset and its special overflow-error swallow. The now-unused reset callback/type plumbing is removed; the separate role-ordering recovery path is unchanged.
This changes no configuration, schema, dependency, retry budget, credential routing, or compaction threshold. It preserves the optional degraded notice and ordinary replies when preflight is unnecessary or succeeds. AI-assisted audit and repair.
User Impact
Older asks and decisions stay available after exhausted memory flushing. When compaction really is required but fails, users receive the existing explicit failure/recovery reply and keep their conversation, rather than silently starting over. The behavior is documented at https://docs.openclaw.ai/concepts/compaction#memory-flush.
Release-note context: preserve conversation continuity after optional memory-maintenance exhaustion; do not mask required compaction failures with a reset.
Evidence
Production LOC: +29/-85 (net -56). Tests: +152/-147 (net +5). Docs: +3/-1.
The regression uses real memory-flush preparation, preflight decisions, the reset implementation, and SQLite-backed transcript reconstruction. A regular file blocks the isolated workspace's memory directory while token usage remains low. The test verifies that older context reaches the next agent turn and that session lifecycle, usage, and compaction counters are preserved. Required overflow and auth-shaped compaction failures remain visible and never reset the session.
Before the production change, the updated boundary suite failed in the two intended cases (context continuity and required-overflow failure) and passed the other 15. After the fix, all 17 pass. Another 173 memory/preflight/reset/queued-followup tests and 31 CLI-compaction sibling tests pass.
Commands executed:
The sibling invocation was interrupted after its 173-test auto-reply shard passed; the remaining 31-test CLI shard was rerun explicitly and passed:
The resumed changed-file gate passed core/test typechecks, targeted formatting/lint, dead exports, import cycles, and the selected guards. Its earlier attempt was interrupted, not counted as a pass.
Real Gateway behavior
Provider: blacksmith-testbox. Lease:
tbx_01m14qh81rwetqqcs75k3kg9an. Testbox run.The isolated proof built private QA with
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build, then ran a temporary driver through the existing Gateway-child, mock-openai, and qa-channel harnesses. No reply-coordinator mock, monkey patch, or production test seam was used. It created an actual channel session, seeded twenty short historical messages, blocked memory-file preparation, and sent three normal inbound channel turns. Failure counts advanced 1, 2, then exhausted; all three replies arrived, and the oldest marker remained in every actual outbound provider request.{ "verdict": "PASS", "gateway": "ephemeral-child", "runtime": "openclaw", "provider": "mock-openai", "channel": "qa-channel", "ordinaryRepliesDelivered": true, "finalProviderRequestRetainsOldMarker": true, "allProviderRequestsRetainOldMarker": true, "exactlyThreeOrdinaryProviderRequests": true, "filesystemPreparationFailedThreeTimes": true, "exhaustionObserved": true, "cycleSkipPersisted": true, "noCompaction": true, "noResetBoundary": true, "sameSessionLifecycle": true, "terminalHealthy": true, "lowReportedUsage": true, "ownedServicesStopped": true }Testbox committed the synchronized candidate as temporary snapshot
71f679a136fffc02e89c18f1731d345f6d113cf5, parent787e602e228edb9fd1b4a88111de2608f6444b4a; hashes of both repaired production files match the local candidate exactly. The snapshot therefore has an empty working diff, not missing changes. Command exit 0; build plus proof took approximately seven minutes.Proof limits: this is a real Gateway with a synthetic channel/provider, not live Telegram or a live model. There was no separate pre-fix built Gateway artifact; the pre-fix failure is the captured boundary regression. Required-compaction failure propagation is covered by that regression, not this channel scenario. Independent live OpenAI/Anthropic compact-and-replay and pinned Codex compact/replay/restart probes passed during the wider audit, but are not substitutes for this changed-path Gateway proof.
The isolated Codex autoreview completed successfully with no actionable findings at its requested P0-only threshold. This is not a claim of an all-severity independent review. Exact-head CI completed successfully for
4a5703c73ebd55fc63e7a4d6082ea67064802fe6, includingopenclaw/ci-gate. The fresh ClawSweeper review reports no actionable findings, sufficient changed-path Gateway proof, and no before-merge work or Rank-up moves.Provenance and solution choice
The exhaustion reset originated in the memory-flush reply recovery change, authored and merged by @steipete on 2026-07-06. The subsequent preflight ordering change, authored by @TurboTheTurtle and merged by @steipete that day, retained the reset behind the no-compaction condition; later extraction carried it forward.
The best fix is deleting the optional-maintenance reset inference at the reply coordinator. Restricting resets to a different error string would still discard unsummarized context, and adding another retry or configuration switch would retain the wrong ownership relationship. The existing compaction failure outcome already tells the user how to recover without losing the active conversation.