fix(codex): harden websocket API-error recovery - #717
Open
yxlyx wants to merge 1 commit into
Open
Conversation
Retire terminal-error sockets before returning while preserving bounded downstream diagnostics. Gate stale-chain rebuilds on the rejected request body that actually used previous_response_id, rather than retained session state.\n\nKeep malformed provider envelopes out of last_api_error so unparsed response data cannot bypass the existing diagnostic boundary.
cursor Bot
pushed a commit
that referenced
this pull request
Sep 1, 2026
Release-cut bump after the #717 fold. Slack stays 25.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
type:errorframe while preserving a one-request marker for bounded downstream diagnostics.previous_response_id; retained chain state alone no longer triggers an unchanged full-input retry.last_api_error.Why
Problem / failure mode
The initial #692 fix correctly treats generic WebSocket error frames as API responses, but three edge paths remained. The lower-level transport retained a dead socket until the parser ran, stale-chain recovery consulted session state even when the serialized request had deliberately omitted
previous_response_id, and malformed response bodies bypassed the redaction boundary.Reason for this approach
A short-lived marker separates transport cleanup from later error formatting, so the socket can be closed immediately without losing the structured diagnostic. Recovery now follows the rejected wire body rather than stale in-memory state, which preserves the safe one-shot re-anchor while avoiding deterministic retries. Unparseable bodies use the same bounded diagnostic formatter as structured provider failures.
Constraints and trade-offs
Raw malformed envelopes are intentionally omitted because they can contain echoed request or authentication-adjacent data. The trace still records request and response sizes for diagnosis. Generic errors remain terminal; only recognized chain errors on requests that actually used the chain can rebuild.
Rejected alternatives
Leaving the dead socket as a sentinel was rejected because lower-level callers could reuse it before parser cleanup. Checking only
codex_prev_idwas rejected because full-resend and property-change paths retain that state while emitting full input.Verification
scripts/eval-tier1.shpython3 scripts/test-pty-codex-ws.py ./zig-out/bin/graffFixes #692