Repository navigation
fix(sessions): stop retrying replaced delivery endpoints on every restart - #174278
Conversation
Record a durable blocked-delivery notice before cancelling replay of inputs whose source or target was reset, archived, or replaced. Preserve accepted input data and all endpoint fences; leave permission and storage failures retryable. Add correlation identifiers without logging messages or raw session keys, and prove that a second recovery pass is silent.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis PR cancels automatic recovery of replaced session endpoints after saving a conversation notice, while retaining the accepted input. Example: The source of saved delivery saved-delivery changes generation from source-before-reset to source-after-reset.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it addresses a current recovery defect, but exact-head CI exposes a cold-restart test expectation that needs repair. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherGateway startup reads persisted sessions_send inputs, validates their original endpoints and current permissions, and either admits delivery or records a blocked-delivery notice. flowchart TD
A[Gateway startup] --> B[Persisted pending inputs]
B --> C[Recovery owner]
C --> D[Endpoint and permission checks]
D --> E[Normal agent admission]
D --> F[Durable conversation notice]
F --> G[Existing withdrawal worker]
Technical reviewBest possible solution: Keep the existing notice-before-withdrawal implementation and repair the cold-restart assertions around initial notice persistence and subsequent replay suppression. Do we have a high-confidence way to reproduce the issue? Current main visibly leaves endpoint-replaced inputs interrupted after recording their notice; the supplied persisted-input regression exercises that path, although no target code was run during this review. Is this the best way to solve the issue? The implementation fixes candidate settlement at the recovery owner using an existing worker operation, preserves accepted content and endpoint fences, and avoids another queue or schema. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3431d6ad4374. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +43, Tests +103, Docs +4. Total +150 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 10:27 AM ET / 14:27 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 190929487c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…tart (openclaw#174278) * fix(sessions): settle replaced delivery endpoints after restart Record a durable blocked-delivery notice before cancelling replay of inputs whose source or target was reset, archived, or replaced. Preserve accepted input data and all endpoint fences; leave permission and storage failures retryable. Add correlation identifiers without logging messages or raw session keys, and prove that a second recovery pass is silent. * test(sessions): preserve cancelled delivery receipt assertions * fix(sessions): preserve recovery notices during orphan repair * test(sessions): assert typed recovery context messages * fix(sessions): preserve notices at orphan rewind boundaries * test(sessions): retain fake timers for recovery persistence
What Problem This Solves
Fixes saved
sessions_sendupdates warning about a replaced endpoint on every Gateway boot. Recovery wrote a deduplicated notice but left the input interrupted, so every restart selected the same undeliverable work again.User Impact
After recording a durable conversation notice, recovery cancels automatic delivery for reset, archived, or replaced endpoints. The accepted input remains stored. Permission and storage failures remain eligible for later recovery. Resend an update if it is still needed; recovery does not redirect it across an endpoint fence.
Warnings now include a hashed session key, input ID, age, endpoint side, and previous/current session identity and lifecycle generation. They do not include message content or raw session keys.
Why This Change Was Made
Reuse the existing worker-owned pending-input withdrawal operation and cancelled state. No schema, configuration, cache, or alternate delivery path is added. Save the notice before withdrawal: a crash between these writes can repeat cleanup, but cannot discard the input without a durable explanation. Existing identity checks do not establish authority to retarget a successor, so this change preserves them.
The restart test also exposed orphan repair rewinding past a notice omitted from model context. Repair now checks the already-loaded durable ancestry, including the exact rewind parent, before rewinding. When that tail contains an unloaded entry, it preserves the original conversation branch and leaves the current prompt unmerged. This retains the notice without injecting it into model context, loading more history, or replaying it.
Evidence
d28abe4e9777in 79.29 seconds. It verifies ordered recovery, retained cancelled receipts, permission/reset fences, no repeated replacement warning, and the visible original notice after subsequent turns and the second restart.d28abe4e9777f8e304d03a3105828b5b85f0bb08, including production/test types, lint, guards, builds, and planned tests.git diff --checkpass. Independent Codex autoreview is scoped clean through P2, including the final assertion correction.CI exposed the orphan-repair visibility defect while exercising the real restart flow; the original notice assertion remains intact. Broad validation stays in PR CI under the operator's local-compute limit. No Testbox/Crabbox lease was allocated, and no production deployment or state repair was performed.
Production delta: +84 / -10 lines (net +74). Growth implements the requested correlation fields, notice-before-withdrawal settlement, and protection against rewinding through unloaded notices. It reuses existing storage and transcript owners without adding a schema, cache, or alternate delivery path.
Review decisions: the requested diagnostic contract explicitly calls for a session-key hash, so the raw-session-key logging suggestion is not applied; input IDs, opaque session IDs, and lifecycle generations still provide correlation. The unnecessary real-timer override was removed from the persistence regression, which passes using the suite fake clock. The implementation and final test cleanup have independent review through P2.