Skip to content

fix(openai): preserve ChatGPT HTTP status for retry pacing - #137146

Merged
steipete merged 3 commits into
mainfrom
codex/stable-review-f07-20260902
Sep 3, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/stable-review-f07-20260902

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before the fix, four new transport regressions failed because HTTP 429/500/503 status was missing. After the fix, all 241 focused provider, projection, encrypted-replay, WebSocket, failure-owner, and retry-controller tests pass.
  • Actual loopback HTTP 503 plus 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.
  • A separate real loopback 503-then-200 recovery completed the expected synthetic reply after one paced retry (requests 0/7886 ms).
  • Authenticated ChatGPT SSE smoke with 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.
  • Focused command: 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 --check and the full node 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).
  • Personally inspected pinned Codex rust-v0.153.0 retry and API-error mapping contracts: codex-rs/codex-client/src/retry.rs:22–35 and codex-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 /update tests. 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.

@steipete steipete self-assigned this Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 3, 2026 07:34
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S maintainer Maintainer-authored PR labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 3, 2026, 5:25 AM ET / 09:25 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 579f4ad615bb5910fa5f69c0eb1d94564ddf163d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned repair with strong described boundary proof and no remaining correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the reviewed body nevertheless records terminal evidence from a real loopback 503-to-200 SSE recovery through the retry boundary.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the reviewed body nevertheless records terminal evidence from a real loopback 503-to-200 SSE recovery through the retry boundary.
Evidence reviewed 6 items Introduced transport repair: The introduced SSE failure path now builds a typed error from the full Response, preserving its HTTP status before the stream’s terminal-error projection.
Canonical projection and retry consumer: The shared projection reads an error status and prefixes the terminal message, while the embedded failure path extracts that leading status and Retry-After before consulting the centralized retry controller.
Focused regression coverage: The transport tests cover 429, 500, and unfamiliar 503 responses, asserting a status-prefixed terminal error, preserved provider code, Retry-After text, and no internal transport retry.
Findings None None.
Security None None.

How this fits together

ChatGPT 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -5, Tests +4, Docs 0. Total -1 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 1 18 23 -5
Tests 4 39 35 +4
Docs 1 3 3 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 60 61 -1

Review metrics

Metric Value Why it matters
Production versus test delta production -5, tests +4, docs 0 net The repair absorbs status preservation into the existing terminal-error owner without production growth.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137145
Summary: This PR is the focused candidate fix for the linked ChatGPT SSE retry-pacing issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the reviewed body nevertheless records terminal evidence from a real loopback 503-to-200 SSE recovery through the retry boundary.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Transient ChatGPT SSE outages can otherwise exhaust recovery immediately or cause premature model fallback.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the reviewed body nevertheless records terminal evidence from a real loopback 503-to-200 SSE recovery through the retry boundary.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-03T07:42:02.408Z sha fc9e715ea3c42834cda5fdfc16e358228183dcad :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T08:28:06.022Z sha 94332ed9008810642934ee1caedd69241bc2f1b7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T09:02:16.837Z sha 8a3bc11 :: blocked before merge. :: [P2] Scope the no-transport-retries documentation claim

@steipete
steipete force-pushed the codex/stable-review-f07-20260902 branch from fc9e715 to 94332ed Compare September 3, 2026 08:20
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 3, 2026
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.
@steipete
steipete force-pushed the codex/stable-review-f07-20260902 branch from 94332ed to 8a3bc11 Compare September 3, 2026 08:54
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest P2 finding and its duplicate next-step/rank-up item in 579f4ad615bb5910fa5f69c0eb1d94564ddf163d: the docs explicitly retain the pre-stream WebSocket connection-limit reconnect and distinguish it from SSE HTTP-response retries. I verified the actual transport branch, ran the docs-only changed gate, and obtained a fresh clean P0–P2 review. Production and tests are unchanged from the 332-test candidate.

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 BuildFailed/startup_failure pull-request admission race before any CI job existed. The PR is mergeable. I am recovering that exact PR event by close/reopen, not bypassing CI or retrying a nonexistent job.

@steipete steipete closed this Sep 3, 2026
@steipete steipete reopened this Sep 3, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
@steipete
steipete merged commit cfa7876 into main Sep 3, 2026
180 checks passed
@steipete
steipete deleted the codex/stable-review-f07-20260902 branch September 3, 2026 15:43
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 3, 2026
* 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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatGPT SSE drops HTTP status and ignores Retry-After pacing

1 participant