Repository navigation
fix(openai): conversations fail when hooks override saved-context replay - #199451
Conversation
Enforce stateless checkpoint replay on the final hooked request and preserve code-specific recovery guidance in terminal replies. Do not replay requests after accepted output. Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by: - @vyctorbrzezowski Co-authored-by: vyctorbrzezowski <[email protected]> OpenClaw-Publication: 82463cca-ea02-47f4-b2d3-61750f433b26
|
🦞👀 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. What this changesThis PR enforces stateless OpenAI checkpoint replay after payload hooks and preserves conflict recovery guidance in chat replies. Example: A payload hook adds checkpoint cmp_stored with store:true and previous_response_id:resp_stale.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a verified gap still present on main, and the previous continuation-test finding is resolved; no new correctness or security findings were identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Responses transport converts conversation history and payload-hook output into provider requests; the reply failure pipeline converts provider error facts into visible replies and lifecycle notices. flowchart TD
A[Conversation history] --> B[Responses request builder]
B --> C[Payload hook]
C --> D[Shared checkpoint policy]
D --> E[OpenAI transport]
E --> F[Failure facts]
F --> G[Chat reply and lifecycle notice]
Technical reviewBest possible solution: Retain the shared post-hook storage invariant and existing code-aware recovery renderer, with the corrected continuation regression. Do we have a high-confidence way to reproduce the issue? Current main permits a late hook to restore conflicting checkpoint storage settings, and its reply-facts path bypasses the existing code-aware conflict renderer; the added regressions exercise both paths, but were not run during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair using existing owners: reuse one checkpoint policy at final request preparation and one recovery-copy renderer, without adding retries, state, configuration, or transcript changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 281042bc8a92. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +27, Tests +119, Docs +4. Total +150 across 9 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 HistoryReview history (1 earlier review cycle)
Reviewed November 15, 2026, 1:12 AM ET / 06:12 UTC (Revision 2). |
|
The continuation test now verifies complete checkpoint/recovery input and reuse of the valid stored prefix. Fresh 25-case validation passed; production is unchanged. Details are in the updated body. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
vyctorbrzezowski
left a comment
There was a problem hiding this comment.
Reviewed the post-hook payload policy, continuation preparation, transport tests and error presentation. The final checkpoint replay is made stateless before continuation selection, preserving complete input without adding retries or per-turn preference/network lookups. Azure/custom endpoint policy remains unchanged. Reproduced the obsolete continuation expectation on the original published head and corrected that existing test: 25 continuation and real-loopback transport cases then passed, with scoped type/lint/format checks. All current-head CI checks are green. This does not establish provenance of the originally reported incident, whose payload was not retained; no new external OpenAI API run is claimed.
|
Merged. Reviewed the post-hook request policy and continuation handling. Corrected the existing continuation test's stale expectations and verified 25 continuation/loopback transport cases; current-head CI passed. The repair preserves full replay input without adding retries, preference lookups, or network calls. The original incident's provenance remains unconfirmed because its payload was not retained. Thanks for the fix. |
…lay (openclaw#199451) Enforce stateless checkpoint replay after payload hooks and before continuation preparation. Preserve full replay input and code-specific error guidance without replaying accepted output. Align existing continuation coverage with stateless checkpoint and recovery requests. Co-authored-by: vyctorbrzezowski <[email protected]>
Related: #198357
What Problem This Solves
Fixes OpenAI conversations failing with a saved-context conflict when a later payload hook overrides checkpoint replay settings, and restores the recovery guidance that was lost on the way to chat.
User Impact
Conversations using retained OpenAI checkpoints keep their context without re-storing conflicting checkpoint records. If an item conflict still occurs, the chat shows the existing recovery instructions instead of only the raw provider error. No configuration changes, migrations, transcript rewrites, or automatic replay of completed work are introduced.
Why This Change Was Made
The earlier checkpoint safeguard ran before the final payload hook. The transport now reapplies the same storage invariant to the final hooked input, including removing a stale continuation reference. Ordinary stored continuation and Azure/custom endpoint policies remain unchanged.
The reply-failure path now uses the existing code-aware format renderer rather than rebuilding a generic diagnostic from the raw error.
OpenAI can report this conflict after streaming output, so this fix prevents the conflicting request rather than retrying after output or tool work has started.
Evidence
Maintainer verification and test correction
The published head
96d47170reproduced the failing continuation assertion without incorporating a newer main. Production behavior was correct; the test still expected stored references for a stateless checkpoint replay and recovery.The corrected test verifies the complete input in the checkpoint request and in recovery, with no
previous_response_id. The next normal turn reuses the last valid stored prefix (resp_1) and includes all intervening messages; it never references the unstored recovery response. The scenario retains its exact four requests for three prompts, including the existing recovery attempt. No new retry path or production change was added.Fresh validation on Tempbook: 25 existing tests passed (22 continuation cases and 3 real-loopback SSE/WebSocket/cached-WebSocket cases). Focused types, lint, formatting and line limits passed. One redundant checkpoint assertion was then removed; formatting was rechecked without repeating the unchanged behavior tests. No external OpenAI API call was repeated; the earlier live proof below remains the implementation author's evidence.
The published correction has the same Git tree as the reviewed local candidate. Current-head CI is the remaining broad validation.
Verified published head:
ed2e15050265b21356c539f183c551b40a68fa3e; Git tree matches the reviewed local correction.The original production request payload was not retained. The late-hook escape is reproduced and fixed, but is not claimed as the confirmed trigger of that particular incident. The affected production conversation has not been reset or resumed as part of this change.
Contributor credit
Reported and requested by @vyctorbrzezowski.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by