Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Codex retries on HTTP 429 count as usage limits #30376

Closedntindle(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/30376/headopened View on GitHub

Problem

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 with responseTooManyFailedAttempts, which Codex never sends for a retry.
  • The triage of #16288 named httpConnectionFailed and the responseStream* 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_limit while it runs. A turn that then fails without new evidence ends failed with usage_limit and the retry's data. A 502 retry stays transport_error both times.
    • The terminal table gains responseStreamDisconnected, responseStreamConnectionFailed and httpConnectionFailed with 429 (usage_limit), and httpConnectionFailed with 503 (provider_error).
    • #17501's contradictory-status table now runs on all four variants. On each, 500 then 429 ends usage_limit and 429 then 500 ends provider_error.
    • The existing 529 retry case now asserts transport_error.
  • 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 lint and knip:check pass.
    • vp run typecheck in apps/server reports nothing in the changed files. The 51 errors it reports elsewhere are identical on main in this environment.
  • With #29208 (575bc94717) merged locally, I ran a replay test like its budget test but with a 429 retry. It ends failed with usage_limit. With #29208 alone, the same stop ends transport_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_error on every build. It then fell back to HTTPS and got the proxy's 429 with Retry-After.

    • Both threads show "Retrying provider (1/5)" while Codex waits. The retry item stored for that 429 (statev2.sqlite; it reads running during the wait and cancelled here 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 + #29208this PR + #29208
Failed: Provider error after 1/5 retriesLimited: Usage limit reached, retry manually

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

    2. Approvability

      Verdict: Approved at 3e63a29

      Macroscope'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).
    3. The completion-override guard still uses codexExhaustionHttpStatus, causing status changes in newly supported variants to incorrectly retain usage_limit or hide a terminal 429.

      1 open issue
      • Medium severity [Use the generalized HTTP status guard for terminal events](https://github.com/pingdotgg/t3code/pull/30376#discussion_r4460458824) · New
    4. 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.
      FileDescription
      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.
      Review effort: Balanced
  • coderabbitai[bot](GitHub profile, opens in a new tab)commented
    Review in Change Stack →

    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 as provider_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.ts
    The 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 responseStreamDisconnected retries that remain transport_error. This change classifies that variant and status as usage_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 systemError state.

    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_limit class.

    Suggested reviewers: juliusmarminge, t3dotgg

    Merge Risk: Minimal · up to 86c82

    HTTP 429 retries are classified as usage limits. No concrete merge-blocking risk was identified.

    Pre-merge checks: Passed 4
    Check nameStatusExplanation
    Title checkPassedThe title is concise, uses the expected conventional format, and clearly describes the main change: classifying Codex HTTP 429 retries as usage limits.
    Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
    Out of Scope Changes checkPassedCheck 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
    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.ts
    • apps/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.

  • maria-rckscommented

    Note

    Written by gpt-6.1-sol on behalf of Maria

    Verified in a real dev environment

    partial verification at 86c8230d1625ae4045124fdce1b3317330cbda4c on a linux boat vm, using repo playwright and /usr/bin/google-chrome against 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-sol completed 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 responseStreamDisconnected with httpStatusCode: null. the app showed retries, then "provider recovered". a read-only database query confirmed both recovered retry items remained transport_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~2 also 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.

    real codex websocket recovery, interrupted turn, and successful continuation

    real codex retry recovery, stop, and continuation recording

    short runtime transcript

    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_limit on 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.

  • tanstack-source added labelsbug

  • This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

    See the conflict window.

  • Closing: this PR still conflicts with main and 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.