Repository navigation
fix: resume compacted turns after a Gateway restart - #160128
Conversation
Reuse the validated persisted input when compaction has removed its model-context copy. Clear one-shot suppression for distinct queued inputs, preserving the transcript turn and ownership guards. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 9bb76237-cd52-47d4-8178-4be2a0fca461
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 7:35 PM ET / 23:35 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch repairs built-in agent replay after compaction and a Gateway restart, adds SQLite replay regression cases, and updates the compaction documentation. Merge readiness✅ Ready for maintainer review Keep open. Current main and the latest release still lack the replay repair, and review found no actionable defect in the proposed patch. Priority: P2 Review scores
Verification
How this fits togetherThe built-in agent runner restores a Gateway session from its SQLite transcript after a restart. Compaction can omit the accepted input from model context, so replay validation and the persistence guard must feed it to the model without saving it twice. flowchart LR
A[Accepted user input] --> B[SQLite transcript]
B --> C[Compaction summary]
C --> D[Gateway restart]
D --> E{Current turn validated?}
E -->|Yes| F[Prompt persistence guard]
F --> G[Model continuation]
F --> H[Transcript without duplicate]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +12, Docs 0. Total +15 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep validated current-turn replay in the built-in agent runner so a compacted restart preserves one durable accepted input and writes later distinct inputs normally. Do we have a high-confidence way to reproduce the issue? Yes, the checked-in SQLite cold-reopen fixture gives a concrete compaction-and-restart path to the keyed-user failure. This read-only review did not execute it. Is this the best way to solve the issue? Yes. Reusing the existing one-shot persistence guard after validated replay, then clearing it for a distinct queued input, keeps the repair within the current transcript owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ca1706469639. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Keep the existing eight GC calls and all retention assertions, but invoke collection before resolving the immediate callback so Bun does not retain completed Promise frames during the collection. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 0dde0ca5-2371-4363-b454-6504a78a8052
Keep the original cold-restart replay repair and current main APIs. Preserve main’s already-landed Bun retention fixture repair, removing that helper from the PR delta. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 83686719-0a5c-4ba0-96b9-39e28eeb7125
Co-authored-by: steipete <[email protected]>
Use the canonical landed collector write-admission repair instead of publishing a competing local fix. The five-file replay repair remains byte-identical. Co-authored-by: steipete <[email protected]>
|
Merged via squash.
|
* fix: resume compacted turns after a Gateway restart Reuse the validated persisted input when compaction has removed its model-context copy. Clear one-shot suppression for distinct queued inputs, preserving the transcript turn and ownership guards. Co-authored-by: steipete <[email protected]> * fix: resume compacted turns after a Gateway restart Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 9bb76237-cd52-47d4-8178-4be2a0fca461 * test: collect plugin retention fixtures in native tasks Keep the existing eight GC calls and all retention assertions, but invoke collection before resolving the immediate callback so Bun does not retain completed Promise frames during the collection. Co-authored-by: steipete <[email protected]> * fix: resume compacted turns after a Gateway restart Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 0dde0ca5-2371-4363-b454-6504a78a8052 * fix: resume compacted turns after a Gateway restart Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 83686719-0a5c-4ba0-96b9-39e28eeb7125 --------- Co-authored-by: steipete <[email protected]>
Channel ingress saves the user's message before the run starts, so the first attempt prepares a durable-turn replay and suppresses the runtime re-append (#160128). The suppressed append never reported the message as persisted, leaving the run's active-prompt fact stale. After timeout compaction moved the saved message out of the current turn, the retry re-sent the original keyed prompt, the transcript adopted the old row by idempotency key, and the current-turn guard failed the reply. Fallback candidates and worker re-placement read the same stale fact. Report the replayed durable user through the existing persisted callback when its append is suppressed, matching the adopted append it replaces. The recorder already holds the turn, so no transcript write is added.
… was already saved (#162260) * fix(test): hold timeout recovery until the child handoff is leasable The Gateway timeout-recovery subagent E2E released the held compaction as soon as the child's execution row was terminal. On 2-core Linux runners compaction then finished before the child's announce resolved, so the announce found the recovered retry already active and steered the completion into it as an internal event. The fixture provider only recognizes the steering-queue form that a retry leases from a deferred handoff, answered PARENT-OK, and the 90 s composite deadline expired. Hold compaction until the child row is terminal/ok and its delivery is a pending payload without an in-flight announce reservation, the predicate the requester steering lease consumes. Assert that the first recovered parent reply carries the child result, and name the stalled phase with provider and handoff evidence when the composite budget expires. * fix(agents): report replayed durable users as persisted Channel ingress saves the user's message before the run starts, so the first attempt prepares a durable-turn replay and suppresses the runtime re-append (#160128). The suppressed append never reported the message as persisted, leaving the run's active-prompt fact stale. After timeout compaction moved the saved message out of the current turn, the retry re-sent the original keyed prompt, the transcript adopted the old row by idempotency key, and the current-turn guard failed the reply. Fallback candidates and worker re-placement read the same stale fact. Report the replayed durable user through the existing persisted callback when its append is suppressed, matching the adopted append it replaces. The recorder already holds the turn, so no transcript write is added.
… was already saved (openclaw#162260) * fix(test): hold timeout recovery until the child handoff is leasable The Gateway timeout-recovery subagent E2E released the held compaction as soon as the child's execution row was terminal. On 2-core Linux runners compaction then finished before the child's announce resolved, so the announce found the recovered retry already active and steered the completion into it as an internal event. The fixture provider only recognizes the steering-queue form that a retry leases from a deferred handoff, answered PARENT-OK, and the 90 s composite deadline expired. Hold compaction until the child row is terminal/ok and its delivery is a pending payload without an in-flight announce reservation, the predicate the requester steering lease consumes. Assert that the first recovered parent reply carries the child result, and name the stalled phase with provider and handoff evidence when the composite budget expires. * fix(agents): report replayed durable users as persisted Channel ingress saves the user's message before the run starts, so the first attempt prepares a durable-turn replay and suppresses the runtime re-append (openclaw#160128). The suppressed append never reported the message as persisted, leaving the run's active-prompt fact stale. After timeout compaction moved the saved message out of the current turn, the retry re-sent the original keyed prompt, the transcript adopted the old row by idempotency key, and the current-turn guard failed the reply. Fallback candidates and worker re-placement read the same stale fact. Report the replayed durable user through the existing persisted callback when its append is suppressed, matching the adopted append it replaces. The recorder already holds the turn, so no transcript write is added.
What Problem This Solves
Fixes: an unfinished conversation can fail with “Session transcript keyed user is outside the current turn” when a Gateway restart follows compaction.
User Impact
The built-in runtime can resume the accepted request without saving it twice, while still saving a distinct queued message. No configuration or database migration is required.
Why This Change Was Made
Compaction can summarize the current input out of model context without removing it from the transcript. Restart replay validates that durable input, but prompt submission reconstructs it when it is absent from model context. The reconstructed copy previously reached ordinary persistence and collided with the saved input.
Reuse the existing one-shot persistence suppression only after interrupted-turn replay preparation succeeds, and clear it when a differently keyed queued input arrives. The ordinary transcript turn guard and replay ownership revalidation remain unchanged. No new dispatcher, fallback, state, or replay key is introduced.
Evidence
Inherited CI failures and canonical repairs
The previous head's failed CI shard exposed two main-branch defects outside this replay change: an abort/reset fixture deadlock and a collector completion race that left scheduler capacity active. Both were independently reproduced on unmodified main.
Integrated the existing fixes rather than publishing a competing implementation: abort fixture commit 79f0e9bf127 and collector publication repair from #161019. On this combined source, the exact captured 25-file CI plan passes 376/376 cases (198.63 s), and the canonical publication owner's 21/21 cases pass (3.66 s). No skips, retry-to-green, weakened assertions, or CI-limit changes were used. These are local receiving results, not a hosted-CI success claim.
Qualification gap: during diagnosis, a discarded local collector candidate passed six full Stop-file runs, but its seventh stress run exited with native Node 24.19.0 heap corruption/SIGABRT. Core inspection located detection in V8 compilation during worker bootstrap; the corruption's cause remains unknown. That stress sequence stopped immediately and is not claimed green or fixed. The canonical upstream repair—not that candidate—is included here; normal current-head CI and review remain required.
Worked on by
Work sessions
View the OpenClaw team session