fix(server): Codex retries on HTTP 429 count as usage limits #30376
main fromrefs/pull/30376/head·opened View on GitHubProblem#
Codex reports each retry as responseStreamDisconnected, with the failed attempt's HTTP status in httpStatusCode (notify_stream_error in codex-rs). T3 counts a 429 as a usage limit only on responseTooManyFailedAttempts, the exhaustion variant (#17501). So a 429 retry is filed as a transport_error. When a turn ends on that pending retry, for example when #29208's retry budget stops it, the turn shows "Provider error" instead of Limited, without Limited's Resume.
This is the retry in #28936. A provider answers 429 with a Retry-After but without OpenAI's usage_limit_reached body, as CLIProxyAPI does once every account behind it is out of quota. Codex then sleeps until Retry-After, and T3 shows "Retrying provider (1/5)" for that retry.
Change#
CodexAdapterV2 reads the HTTP status from every Codex error info that carries one:
responseStreamDisconnected;responseStreamConnectionFailed;httpConnectionFailed;- exhaustion, as before.
A 429 on any of them is a usage limit. Other statuses keep their current class. As #17501 set up for exhaustion, an explicit status on the turn's completion still overrides the earlier notification's class; that check now reads the status the same way.
On its own, this does not end Codex's wait: T3 still shows "Retrying provider" while Codex sleeps. #29208 bounds that wait and settles the turn with the retry's own failure. With both, a turn stuck on a 429 ends Limited with Resume instead of Provider error. The two changes touch different code and merge cleanly with #29208 at 575bc94717.
Scope and approval#
Refs #28936. No maintainer has triaged it yet.
Why it qualifies as a focused fix of an obvious bug:
- #17501 settled that Codex retry exhaustion on HTTP 429 is a usage limit. Its regression table already expects a turn that fails on a pending 429 retry to end
usage_limit. But it builds that retry withresponseTooManyFailedAttempts, which Codex never sends for a retry. - The triage of #16288 named
httpConnectionFailedand theresponseStream*variants, which "carry the same status field", as candidates for the same rule. - It changes one classifier in one adapter. It adds no timer, setting or UI, and resumes nothing on its own.
Related: #24885 reports that a 429 can also be Codex's short-lived "at capacity" refusal. Codex passes T3 only the status, so this PR keeps #17501's classification and changes no wording. #26532 retitles 429 usage limits as "Provider rate limit (HTTP 429)", keyed on responseTooManyFailedAttempts. If both land, that title should also cover the three codes this PR adds.
Verification#
- Replay tests (
CodexAdapterV2.test.ts):- A 429 retry is
usage_limitwhile it runs. A turn that then fails without new evidence endsfailedwithusage_limitand the retry's data. A 502 retry staystransport_errorboth times. - The terminal table gains
responseStreamDisconnected,responseStreamConnectionFailedandhttpConnectionFailedwith 429 (usage_limit), andhttpConnectionFailedwith 503 (provider_error). - #17501's contradictory-status table now runs on all four variants. On each, 500 then 429 ends
usage_limitand 429 then 500 endsprovider_error. - The existing 529 retry case now asserts
transport_error.
- A 429 retry is
- Mutations: each of these fails at least one of the tests:
- classifying from exhaustion only;
- dropping any one of the three variants;
- treating any status as a limit;
- keeping the exhaustion-only status in the completion override;
- dropping that override.
- Checks:
vp test run src/orchestration-v2/Adapters/CodexAdapterV2.test.ts: 156 passed.- The pre-commit
vp fmt,vp lintandknip:checkpass. vp run typecheckinapps/serverreports nothing in the changed files. The 51 errors it reports elsewhere are identical onmainin this environment.
- With #29208 (
575bc94717) merged locally, I ran a replay test like its budget test but with a 429 retry. It endsfailedwithusage_limit. With #29208 alone, the same stop endstransport_error. - Live: Codex CLI 0.166.0 against a local CLIProxyAPI whose credentials were refused upstream with
usage_limit_reached, each build on an isolated T3 dev server.Codex first retried over WebSocket. Those resets carry no HTTP status and are
transport_erroron every build. It then fell back to HTTPS and got the proxy's 429 withRetry-After.Both threads show "Retrying provider (1/5)" while Codex waits. The retry item stored for that 429 (
statev2.sqlite; it readsrunningduring the wait andcancelledhere because the dev servers were stopped afterwards):main: {"status":"cancelled","failure":{"class":"transport_error","message":"exceeded retry limit, last status: 429 Too Many Requests","code":"responseStreamDisconnected","retryable":true},"retry":{"attempt":1,"maxAttempts":5,"retryDelayMs":null}} this branch: {"status":"cancelled","failure":{"class":"usage_limit","message":"exceeded retry limit, last status: 429 Too Many Requests","code":"responseStreamDisconnected","retryable":true},"retry":{"attempt":1,"maxAttempts":5,"retryDelayMs":null}}With #29208 merged into each, after its 10-minute budget:
main + #29208 | this PR + #29208 |
|---|---|
![]() | ![]() |
Not checked:
- mobile clients, which read the same failure class;
- a reset time on the Limited state. A proxy like this sends no Codex rate-limit headers, so Resume is manual and "Resume at reset" does not appear.
Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
3e63a29Macroscope's review found this PR approvable — Codex HTTP 429 retries and connection failures now use existing usage-limit handling, preserving Limited-state recovery controls. Automatic recovery remains governed by existing preferences and reset-time safeguards.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).🟡 Changes recommended#
The completion-override guard still uses
codexExhaustionHttpStatus, causing status changes in newly supported variants to incorrectly retainusage_limitor hide a terminal 429.1 open issue
[Use the generalized HTTP status guard for terminal events](https://github.com/pingdotgg/t3code/pull/30376#discussion_r4460458824) · New
What changed in this PR
This PR extends T3 Code’s Codex error classification so HTTP 429 retries count as usage limits, consistent with existing retry-exhaustion handling. It does not add a retry timeout; that is handled separately by #29208.
Changes:
- Recognizes HTTP 429 across three additional structured Codex error variants.
- Adds replay coverage for retry classification, terminal failure retention, and non-429 controls.
Review effort: BalancedFile Description apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.tsBroadens HTTP-status extraction for usage-limit classification. apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.tsAdds 429 regression cases and non-429 classification checks. apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 1147Resolvedby ntindle(GitHub profile, opens in a new tab)@@ -1124,8 +1128,20 @@1128+ */1129+function codexErrorHttpStatus(errorInfo: CodexErrorInfo | null | undefined): number | null {1130+ if (typeof errorInfo !== "object" || errorInfo === null) return null;1131+ if ("responseStreamDisconnected" in errorInfo)1132+ return errorInfo.responseStreamDisconnected.httpStatusCode ?? null;1133+ if ("responseStreamConnectionFailed" in errorInfo)1134+ return errorInfo.responseStreamConnectionFailed.httpStatusCode ?? null;1135+ if ("httpConnectionFailed" in errorInfo)1136+ return errorInfo.httpConnectionFailed.httpStatusCode ?? null;1137+ return codexExhaustionHttpStatus(errorInfo);1138+}1139+11241140 function codexUsageLimitError(11251141 code: string | null,11261142 errorInfo: CodexErrorInfo | null | undefined,11271143 ): boolean {11281144 return (11291145 code === "usageLimitExceeded" ||11301146 code === "rateLimitExceeded" ||1131- codexExhaustionHttpStatus(errorInfo) === 4291147+ codexErrorHttpStatus(errorInfo) === 429makeRootTerminalEventstill usescodexExhaustionHttpStatusto decide whether completion evidence overrides a cached failure. For any of the three newly supported variants, matching notification and completion messages/codes with statuses changing from 429 to 503 incorrectly retainusage_limit; the reverse transition can hide a terminal 429. UsecodexErrorHttpStatusin that guard too, preserve the null-status fallback, and extend the existing contradictory-status regression table to cover these variants.Fixed in 86c8230d16. The completion override now reads the status with
codexErrorHttpStatus, and a missing status still keeps the notification's failure. #17501's contradictory-status table now runs on all four variants. Putting the exhaustion-only guard back fails the six new 500→429 and 429→500 rows.No actionable comments were generated in the recent review.
Walkthrough
-
The Codex adapter now checks HTTP statuses across supported error-info variants. HTTP 429 is classified as
usage_limit; other tested statuses, such as HTTP 500 and 503, are classified asprovider_error. Terminal failure reconciliation uses the generalized status lookup.Changes: Codex error classification
Layer / File(s) Summary Retry status extraction and classification
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.tsThe adapter extracts statuses from supported retry-related error variants and uses HTTP 429 to classify usage limits. Terminal failure reconciliation checks the generalized status lookup. Tests cover retry and terminal classifications, status combinations, retained error codes, and retry behavior. Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
- pingdotgg/t3code#28936 — The issue describes HTTP 429
responseStreamDisconnectedretries that remaintransport_error. This change classifies that variant and status asusage_limit. - pingdotgg/t3code#24885 — The issue concerns Codex HTTP 429 capacity responses classified as
usage_limit. This change applies the classification across additional error variants. - pingdotgg/t3code#17503 — The issue concerns gaps in HTTP 429 retry handling. This change addresses classification in that retry path, but not the silent retry period or
systemErrorstate.
Possibly related PRs
- pingdotgg/t3code#29208 — Adds a Codex retry budget and terminal handling; this change classifies retry and terminal failures in that path.
- pingdotgg/t3code#23842 — Implements bounded retries and terminal handling for stalled Codex HTTP 429 errors; this change extends classification across more error variants.
- pingdotgg/t3code#29283 — Reads Codex rate limits for usage-limit terminals; this change affects which HTTP 429 terminals receive the
usage_limitclass.
Suggested reviewers:
juliusmarminge,t3dotgg - pingdotgg/t3code#28936 — The issue describes HTTP 429
Merge Risk:
Minimal · up to86c82-
HTTP 429 retries are classified as usage limits. No concrete merge-blocking risk was identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title is concise, uses the expected conventional format, and clearly describes the main change: classifying Codex HTTP 429 retries as usage limits. Description check The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, scope rationale, focused tests, checks, limitations, and obs… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, scope rationale, focused tests, checks, limitations, and observed results.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
CodeRabbit Verify#
- Run CodeRabbit Verify to test the changes in this pull request.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: a104909
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
64743bec-0fcb-40f5-b41f-5e20df7ba9af
Commits-
Reviewing files that changed from the base of the PR and between 3e63a294774a639d68e7e88900f4a0098d98e2ca and 86c8230d1625ae4045124fdce1b3317330cbda4c.
Files selected for processing: 2-
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
partial verification at
86c8230d1625ae4045124fdce1b3317330cbda4con a linux boat vm, using repo playwright and/usr/bin/google-chromeagainst the actual dev web app. main (7c22e24e3f) ran first in a separate worktree; only one dev server ran at a time. the reported pr results use the explicit isolated home/home/user/t3code/.t3.- created the project, thread, and messages through the app. real codex
gpt-6.1-solcompleted ordinary turns on main and the exact pr head. high reasoning with fast service also completed on both. - on the pr, real websocket resets carried
responseStreamDisconnectedwithhttpStatusCode: null. the app showed retries, then "provider recovered". a read-only database query confirmed both recovered retry items remainedtransport_error(4/5 and 3/5 retries). - stopped a real tool-running turn through "stop generation". the client showed "stopped by user" and offered resume. a follow-up in the same thread completed with "continuation ok."
- blacksmith passed the 156 adapter tests.
vp run check:changed FETCH_HEAD~2also passed format, lint, knip, graphql, affected typechecks, and 157 tests after fetching the exact contributor head to supply remote merge-base history. observed ci was 28/28 successful.


Not verified#
the central http 429 change remains unverified in the real app. no isolated app turn received a genuine 429, so i could not reproduce the original bug on main or prove
usage_limiton the pr. no synthetic responses, mocks, fixtures, deliberate quota exhaustion, or companion retry-budget change were used. the passing replay tests do not replace that missing proof.terminal limited/resume after a 429, completion-status contradictions, and the other structured http error variants were not exercised with a real provider. this pr adds no retry timeout. native desktop, ios/android, other operating systems, and remote/relay/tunnel connections were not exercised.
no code changes or pushes.
- created the project, thread, and messages through the app. real codex
tanstack-source added labelsbug
This PR conflicts with
main. Rebase it or mergemaininto it. If it still conflicts after 7 days with no activity, it will be closed automatically.See the conflict window.
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
Closing: this PR still conflicts with
mainand has had no activity for 7 days since the rebase request.To continue, rebase the branch and open a new PR that links this one. See the conflict window.
github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes