Repository navigation
fix(providers): recover conversations after encrypted reasoning stream rejection - #129886
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 26, 2026, 2:50 AM ET / 06:50 UTC. ClawSweeper reviewWhat this changesExtends Responses transport recovery so encrypted-reasoning rejections raised during stream iteration or failure events retry sanitized history before assistant output begins. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the new in-stream recovery can bypass the replacement stream’s first-event deadline and can persist compaction suppression before that replacement stream succeeds. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherResponses-compatible providers send conversation history to a shared transport, which consumes provider stream events into an assistant response. The recovery path can remove rejected encrypted replay state and issue one replacement request while preserving hooks and conversation state. flowchart LR
A[Conversation history] --> B[Responses request]
B --> C[Provider stream]
C --> D{Encrypted replay rejection}
D -->|Before output| E[Sanitize replay state]
E --> F[Replacement stream]
F --> G[Assistant lifecycle]
D -->|Other result| G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +77, Tests +332. Total +409 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: 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:
Copy recommended automerge instructionTechnical reviewBest possible solution: Make timeout and compaction-commit ownership attempt-scoped: reset the first-event boundary for every replacement response, and persist suppression only after the stripped recovery reaches a successful terminal response. Do we have a high-confidence way to reproduce the issue? Yes—source reproducible: emit a first stream event then an encrypted rejection, and make the replacement response hook never settle; separately, let a compaction-stripped replacement iterator fail after headers but before output. Is this the best way to solve the issue? No—the complete-stream retry needs attempt-scoped timeout and commit semantics so a failed replacement cannot bypass its timeout or durably suppress replay state. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fc64c5704a77. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Merged via squash.
|
…m rejection (openclaw#129886) * fix(providers): recover encrypted reasoning rejected while streaming * fix(providers): narrow encrypted replay rejection matching
Fixes #124465
Related: #95493, #95587, #97926
What Problem This Solves
Fixes an issue where users chatting with GitHub Copilot could permanently lose a conversation after replayed encrypted reasoning was rejected: the assistant repeatedly failed with
LLM request faileduntil the session was reset. The same failure could affect another Responses-compatible provider when its rejection arrived after streaming had already started.Why This Change Was Made
The OpenAI SDK can defer a provider error until the Responses stream is iterated, and those streamed SDK errors do not necessarily retain their HTTP status or structured error code. OpenClaw's existing encrypted-replay recovery wrapped only initial stream creation, so both the deferred SDK exception and normal
response.failed/errorstream events escaped recovery.Move recovery ownership across the complete SDK create-and-drain lifecycle used by both Responses transport callers. Recognize narrowly bounded encrypted-content verification/decryption failures, retry only before thinking, text, or tool output has been committed, preserve the existing reasoning-then-compaction recovery stages, re-run the correct response hook for replacement HTTP responses, and keep one visible assistant lifecycle. Aborted requests and failed response hooks never retry.
The existing Copilot plugin remains responsible for proactively stripping connection-bound reasoning before dispatch. Its producer-side mitigation and this shared transport-side recovery are complementary; this change does not recursively remove valid encrypted compaction state or change provider configuration.
Production delta: +126/-49 (net +77). The additional production code is necessary to own deferred single-consumption stream failures, provider response/continuation lifecycles, and the pre-output/abort safety boundary; the existing creation-only retry cannot express that capability. Regression tests: +332/-0.
User Impact
Copilot and other Responses-compatible conversations recover automatically from a rejected stale reasoning item instead of repeatedly resending poisoned history. Valid compaction remains available, existing streamed output is never duplicated, and operators do not need to reset the conversation.
Evidence
Before the fix, the real shared lifecycle regression failed for iterator-thrown errors,
response.failed, anderrorevents: each sent only one poisoned request instead of the required sanitized recovery request.Direct dependency proof: installed OpenAI SDK 7.5.0
node_modules/openai/src/core/streaming.ts:58-87consumes SSE only during async iteration and constructsnew APIError(undefined, data.error, undefined, response.headers)at lines 83-85. A real SDKStreamover a realResponsecontaining an SSE error yieldedAPIErrorwith absent status and code, confirming the deferred shape independently of mocks.Additional independent review reproduced two real edge cases before repair: a nested status-only
response.faileddid not recover, and an encrypted-looking response-hook failure incorrectly attempted a second request.After the fix, seven focused Responses transport and agent-side replay suites pass 261 tests, including immediate HTTP 400, deferred SDK errors without status/code, flat/nested error events, unrelated OAuth-sidecar/HTTP-500 negative cases, the existing xAI rejection contract, exactly one start/done lifecycle, no retry after thinking/text/tool output, aborted hooks, retained encrypted compaction, prompt observation, replacement-response headers, continuation state, and WebSocket siblings:
A genuine authenticated GitHub Copilot request from the patched checkout completed through the documented disposable CLI flow using
github-copilot/gpt-5.4; the real/responsesendpoint returned HTTP 200 and the requested assistant response.A deliberate live 400-to-200 recovery cannot be safely forced through the normal disposable CLI: the shipped Copilot plugin removes stale reasoning ciphertext before dispatch, the disposable command supports only one turn, and inducing the original state would require bypassing the production sanitizer, altering an operator-owned session, or invalidating credentials. The maintainer accepts this concrete live-fault-proof limitation; genuine authenticated Copilot success, direct SDK source/real-SSE fault proof, and real exported production-boundary recovery regressions are the strongest safe evidence. No live fault recovery is claimed.
The separate handwritten ChatGPT SSE transport does not serve Copilot and remains a named sibling follow-up; its WebSocket path already owns complete-stream semantic recovery.
Structured Codex autoreview: no accepted/actionable findings. Independently source-reviewed across the SDK contract, both production caller paths, response hooks, continuation state, compaction, and cancellation.
Reported by @shanselman. AI-assisted implementation; no prior contributor code was copied.