Repository navigation
fix(ai): reject non-text Codex websocket frames - #111138
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 2:10 PM ET / 18:10 UTC. ClawSweeper reviewWhat this changesThis PR makes the ChatGPT/Codex Responses WebSocket transport reject non-text response frames with OpenClaw’s canonical malformed-stream error, then discard the cached connection and continuation before a later turn reconnects. Merge readinessKeep this PR open for normal maintainer review. The patch is a focused repair: current Priority: P2 Review scores
Verification
How this fits togetherThe ChatGPT Responses provider receives streamed model events over a WebSocket and may cache that connection plus a continuation id for follow-up turns. The parser feeds decoded events into the response stream, and any terminal parser failure reaches the cache owner, which clears continuation state and closes the socket before another request starts. flowchart LR
A[ChatGPT Responses service] --> B[WebSocket response frame]
B --> C[OpenClaw frame parser]
C --> D{Text frame?}
D -->|yes| E[JSON response event]
D -->|no| F[Malformed stream error]
F --> G[Clear continuation and close socket]
G --> H[Next turn opens fresh connection]
Decision needed
Why: The branch’s central correctness claim is an external Codex WebSocket protocol contract. This reviewer could not personally inspect the mandatory sibling source because it is absent in the read-only environment, although a member has documented that inspection. Before merge
Agent review detailsSecurityNone. PR surfaceSource -17, Tests +103. Total +86 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain one canonical text-only response-frame parser, preserve the existing terminal cache-cleanup path, and land only after an authorized reviewer confirms the exact sibling Codex source contract and native exact-merge verification succeeds. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current Is this the best way to solve the issue? Unclear: the patch is the narrowest owner-boundary repair and correctly reuses established cleanup, but the required direct sibling Codex source inspection was unavailable to this reviewer, so the external frame contract cannot be independently confirmed here. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a67c52611e57. 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 (6 earlier review cycles)
|
773f366 to
628a36c
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: zenglingbiao <[email protected]>
628a36c to
7b52e5d
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer disposition for the latest ClawSweeper
No ClawSweeper rank-up move is being skipped. |
|
Merged via squash.
|
* origin/main: (25 commits) test(qa): cover plugin authoring contracts (#118821) fix(parallels): keep provider keys out of POSIX job logs (#118840) improve: reduce redundant Code Mode test work (#118815) fix(models): report primary OpenRouter limits in scans (#110855) test: speed up setup inference fixtures (#118811) fix(auto-reply): enforce canonical reset authorization (#118580) docs(gateway): fix invalid heartbeat visibility examples (#118827) fix(plugins): unify HTTP route conflict handling (#118203) test(agents): use prepared auth fixtures (#118816) fix(lmstudio): resolve JIT embedding variants fix(lmstudio): preserve embedding preload and model identity fix(ai): reject binary Codex websocket frames (#111138) fix(deps): bump brace-expansion override to 5.0.9 for HIGH advisory 1130705 (#118804) feat(cli): add session archive and delete commands (#118791) fix(openai): commit eligible final realtime transcription audio safely (#118782) fix(reef): restrict management commands to owners [AI] (#118578) fix(google): honor Cloud SDK credential location and Vertex billing project (#118745) fix(bedrock): preserve private embedding endpoints and AWS routing policy (#118744) fix(voice): make signed callback replay reservations durable and retryable (#118754) fix(openrouter): isolate custom proxy credentials and transport security (#118773) ...
Co-authored-by: Vincent Koc <[email protected]>
What problem this solves
The Codex Responses WebSocket protocol delivers response events as text frames
and treats binary frames as terminal protocol errors. OpenClaw instead accepted
ArrayBuffer, typed-array, and Blob-like frames, decoded them as UTF-8, and fedthem into the JSON response stream.
That behavior diverged from Codex's protocol contract and allowed an unexpected
binary frame to participate in a cached continuation before the transport
failed.
Canonical fix
caller receives OpenClaw's canonical retry guidance.
evicts the cached socket, closes it, and reconnects cleanly on the next run.
No config, Plugin SDK, protocol schema, persistence, or product feature surface
changes.
Upstream contract
Direct inspection of sibling
openai/codexat414782450952a196bbb64b1605a458c2531c47b6:codex-rs/codex-api/src/endpoint/responses_websocket.rs:672-764processesMessage::Textresponse events and terminally rejectsMessage::Binary.codex-rs/codex-api/src/endpoint/responses_websocket.rs:778-795sendsrequests as
Message::Text.codex-rs/core/tests/common/responses.rs:1392-1399emits mocked responseevents as text.
Binary parsing at
codex-rs/core/tests/common/responses.rs:1425-1429is forinbound client requests, not server response events.
Evidence
Exact rewritten head:
7b52e5d96c458fc543e57c419de7fd658ee458fblistener/socket cleanup, cache invalidation, and a clean text-frame reconnect.
git diff --check: clean.check-changed --dry-run:coreandcoreTests.maina67c52611e5768ffe89dc2c4eea0cea0e26e34e6.Real behavior proof
On exact head
7b52e5d96c458fc543e57c419de7fd658ee458fb, a transienttrusted-local harness used an unexpired OpenAI OAuth credential read from
OpenClaw's canonical auth store and the real
openai/gpt-5.5ChatGPT WebSockettransport:
continuation.
frame into turn 2 at the actual transport boundary.
continuation id.
frames, exactly 1 injected binary frame.
Redacted behavior evidence:
{"modelRef":"openai/gpt-5.5","firstTurn":"stop","injectedBinaryFrames":1,"malformedMarkerMatched":true,"recoveredTurn":"stop","downstreamConnections":2,"upstreamTextFrames":28,"cachedContinuationBeforeFault":true,"staleContinuationAfterFault":"cleared"}This was not a mock provider or mock channel run: turns 1 and 3 reached the
real ChatGPT service. The upstream service did not naturally emit binary; the
targeted non-text server frame was injected locally between those two real
turns. Trusted-local fallback was used because the disposable Testbox's
hydrated Codex OAuth token was expired, and refreshing the shared rotating
credential from an ephemeral host was intentionally avoided.
The permissive binary decoder entered through PR #85341 (
bb46b79d) and movedwith the AI package extraction in PR #99059 (
062f88e3).Scope
Production delta:
+34/-51(net -17) in the Codex Responses WebSockettransport. Tests add 103 lines.
Changelog not required: this aligns the existing transport with the upstream
protocol contract.