Repository navigation
fix(openai): preserve ChatGPT HTTP status for retry pacing - #137146
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 3, 2026, 5:25 AM ET / 09:25 UTC. ClawSweeper reviewWhat this changesThe PR carries ChatGPT SSE HTTP status and provider error codes into OpenClaw’s terminal error projection so the existing failover controller can apply Retry-After pacing. Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open. Its status-preserving error handoff repairs the linked retry-pacing regression, the prior documentation finding is addressed, and current main still has the status-dropping implementation. Priority: P1 Review scores
Verification
How this fits togetherChatGPT SSE converts provider HTTP failures into terminal assistant errors, then the embedded agent runner classifies those errors for retry or model failover. This change preserves the HTTP status needed by that downstream classifier. flowchart LR
A[ChatGPT SSE response] --> B[Provider error parsing]
B --> C[Terminal assistant error]
C --> D[Failover retry controller]
D --> E[Paced same-model retry]
D --> F[Profile or model fallback]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -5, Tests +4, Docs 0. Total -1 across 6 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land the focused transport-boundary repair after the normal exact-head CI and maintainer landing gates complete. Do we have a high-confidence way to reproduce the issue? Yes: the linked issue supplies a deterministic loopback 503 plus Retry-After scenario, and the reviewed source shows the exact transport-to-failover handoff it exercises; this read-only review did not rerun it. Is this the best way to solve the issue? Yes: retaining status on the typed transport error lets the existing canonical projection and centralized retry owner classify pacing, instead of adding another retry loop or downstream workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 587455b04a3d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
fc9e715 to
94332ed
Compare
Keep HTTP status distinct from provider codes when creating the existing ChatGPT SSE error. The canonical projection then carries status and Retry-After to the central retry controller, including unfamiliar 503 messages. Remove the intermediate parsed-info object and retain the existing encrypted replay, WebSocket, and permanent-failure paths. Clarify embedded versus SDK-only retry ownership. Production net -5; test net +2. Proof: 241 focused tests, full changed gate, actual loopback before/after pacing and 503-to-200 recovery, authenticated synthetic ChatGPT 200/400 probes, and independent Codex review. Coordinator replayed 34 cases and paced recovery.
Mainline in-process dispatch now explicitly identifies its system actor. Retain exact update-tool and update-command call assertions while adding that expected field, preserving owner gates, routing, scopes, deadlines, and no-remote-fallback checks. Reproduced four failures on untouched main; both callers and their shared helper pass 50 tests after correction. The complete retry candidate passes 332 tests and the full changed gate.
94332ed to
8a3bc11
Compare
|
Addressed the latest P2 finding and its duplicate next-step/rank-up item in Maintainer handling: proceed with the requested repair once the exact-head checks and native landing gates pass. Mainline #137196 independently landed the same two shared-dispatch test expectations; the effective runtime repair remains net −5 production lines. The new head hit GitHub’s |
|
Merged via squash.
|
* refs/remotes/origin/main: fix(plugins): reject unverifiable pinned npm installs (#136725) improve(ui): lift sidebar section headers on hover and mark online owners (#136985) test(cron): reuse isolated run suite hooks (#137341) test(channels): reuse shared indexed call guards (#137350) fix(ui): sidebar header controls read misaligned after the + button lost its border (#137317) fix(qa-channel): preserve conversation kind for implicit actions (#137343) fix: target the source checkout in Control UI repair commands (#137354) chore: reduce CI job count and database test overhead (#137352) fix(ios): preserve chat live edge across keyboard transitions (#136660) refactor(control-ui): consolidate mention inbox requests (#137375) fix(openai): preserve ChatGPT HTTP status for retry pacing (#137146) fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] (#136546) test(queue): reuse shared deferred fixtures (#137338) fix(gateway): repair the Gateway E2E shard (browser suite project, skill resource argv, Codex diagnostic) (#137358)
…137146) * fix(openai): preserve ChatGPT HTTP status for retry pacing Keep HTTP status distinct from provider codes when creating the existing ChatGPT SSE error. The canonical projection then carries status and Retry-After to the central retry controller, including unfamiliar 503 messages. Remove the intermediate parsed-info object and retain the existing encrypted replay, WebSocket, and permanent-failure paths. Clarify embedded versus SDK-only retry ownership. Production net -5; test net +2. Proof: 241 focused tests, full changed gate, actual loopback before/after pacing and 503-to-200 recovery, authenticated synthetic ChatGPT 200/400 probes, and independent Codex review. Coordinator replayed 34 cases and paced recovery. * test(agents): align update dispatch expectations with system actor Mainline in-process dispatch now explicitly identifies its system actor. Retain exact update-tool and update-command call assertions while adding that expected field, preserving owner gates, routing, scopes, deadlines, and no-remote-fallback checks. Reproduced four failures on untouched main; both callers and their shared helper pass 50 tests after correction. The complete retry candidate passes 332 tests and the full changed gate. * docs(retry): distinguish WebSocket reconnects from HTTP retries
Closes #137145
Related: #134281
What Problem This Solves
Fixes an issue where users of the ChatGPT SSE transport could receive an avoidable failure or premature model fallback during a temporary HTTP outage. A response such as HTTP 503 with an unfamiliar message lost its status before retry classification, so three immediate empty-error retries exhausted recovery despite
Retry-After: 7.Why This Change Was Made
HTTP error parsing now creates the typed provider error directly, carrying HTTP status and provider code into the existing canonical terminal projection alongside the retry hint. The failover controller remains the transient HTTP-response retry owner; WebSocket errors and encrypted-content recovery keep their existing paths. The temporary parsed-info handoff is removed, and retry documentation distinguishes embedded retries from SDK-only retry caps.
User Impact
Transient ChatGPT SSE HTTP errors retain server-requested pacing even when their text or provider code is unfamiliar. Permanent HTTP failures keep their status and provider-specific code. No new configuration, dependency, public message field, or retry loop is introduced.
Evidence
Retry-After: 7, using the real SSE transport and failure/retry controller: before, four requests arrived as a burst without consulting the controller; after, request times were 0/7114/14121/21124 ms without a fallback and 0/7005/14011/21020 ms with one. Every retry slept seven seconds, and the empty-error counter stayed zero. This is a synthetic server, not an authenticated outage test.gpt-5.6-luna: HTTP 200, completed expected synthetic reply, 26 input/10 output tokens, 1161 ms. A separate safe unsupported-parameter request returned HTTP 400 and retained the canonical status in its terminal error, with zero tokens. Existing read-only credential resolution was used; no refresh, auth-file copy, or operator-state change.OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs packages/ai/src/providers/openai-chatgpt-responses packages/ai/src/utils/provider-error.test.ts src/agents/embedded-agent-runner/run/assistant-failure.test.ts src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts src/agents/embedded-agent-runner/run/helpers.test.ts.git diff --checkand the fullnode scripts/check-changed.mjs -- <four changed paths>gate pass, including core/core-test typechecks, formatting, lint, import cycles, and selected guards. Independent isolated Codex autoreview is scoped-clean through P2; a separate frozen-head review also found no P0/P1/P2 issue. The coordinator personally read the full producer, canonical projector, central retry owner and exact pinned dependency sources, then replayed 34 tests and real loopback 503-to-200 recovery (requests 0/7141 ms).rust-v0.153.0retry and API-error mapping contracts:codex-rs/codex-client/src/retry.rs:22–35andcodex-rs/codex-api/src/api_bridge.rs:66–186. They preserve HTTP status; this does not alter native app-server retry policy.Production LOC: +18/-23, net -5. Tests: +39/-35, net +4. Docs: +3/-3. No material persistent-store, protocol, or configuration changes.
The original 503 outage timing is exercised deterministically on loopback, not forced against the live service. The existing central classifier's 503-to-timeout reason mapping is unchanged. No further cleanup in this repair's invariant remains.
Exact publication candidate:
579f4ad615bb5910fa5f69c0eb1d94564ddf163d. Hosted CI and repository-native landing gates remain pending; no release or publication of package artifacts is included.Integration and CI recovery
The initial CI merge failed an inherited node-host test-file max-lines check. Mainline PR #137149 now splits the exact failing file while retaining all 41 cases, so this candidate was rebased onto that fix and a redundant local fixture cleanup was discarded. The original four-file SSE patch and every source hash remain unchanged.
Refreshed local proof on this candidate: all 282 tests pass (the original 241 plus both upstream runner suites), the complete four-path changed gate passes, and fresh isolated Codex review is clean through P2. Actual loopback 503-to-200 recovery completes after one 7.064-second retry with no empty-error retry. Native Codex and OpenAI dependency versions are unchanged. Refreshed exact-head CI is required before landing.
Shared-dispatch test correction
The refreshed CI run also exposed four inherited failures in the update-tool and
/updatetests. Mainline #136952 added the shared dispatcher’s explicit system actor, but those two exact expectations still omitted it. The coordinator reproduced all four failures on untouched main and added the missing actor field to both assertions. Owner gates, trusted routing, scopes, deadlines and no-remote-fallback assertions remain exact; no production policy or timeout changed.On the final six-file candidate, all 332 tests across 15 files pass, including the two update callers and their shared helper; the complete changed-file gate passes. Fresh isolated Codex review is clean through P2. Real loopback HTTP 503-to-200 recovery completes after one 7.108-second paced retry with HTTP status preserved and zero empty-error retries. The original four-file SSE patch is byte-identical. Production remains net −5 lines; the CI correction adds two test lines. Earlier authenticated 200/400 receipts remain evidence for the unchanged transport, not newly rerun inference. Exact-head CI is still required before landing.
Final documentation correction
Addressed the latest ClawSweeper finding and rank-up move: the retry page now explicitly preserves the one-time pre-stream WebSocket connection-limit reconnect and scopes controller ownership to transient HTTP-response retries. Runtime and test bytes are unchanged from the 332-test candidate above; the docs-only changed gate passes and a fresh isolated P0–P2 review is clean. Mainline #137196 independently added the same two update-test expectations, so those files are identical at merge and do not add duplicate changes. Exact-head hosted CI remains required.