Honor Retry-After header in rate-limit retry policy and clarify terminal message - #839
Merged
TheGreatAxios merged 2 commits intoSep 10, 2026
Conversation
TheGreatAxios
force-pushed
the
cl-7523-fix-rate-limit-retry-to-honor-retry-after-header-and-clarify
branch
from
September 8, 2026 20:12
185c064 to
24bba00
Compare
TheGreatAxios
commented
Sep 9, 2026
TheGreatAxios
left a comment
Collaborator
Author
There was a problem hiding this comment.
Greybeard · Comment
Responses adapters extract Retry-After; Corbits policy paces remapped 429s instead of the 500/1000ms backoff.
Findings
src/agent/retry-policy.ts:49—MAX_BLIND_WAIT_MSowns abort-vs-sleep for quota windows, not a delay cap.min(retryAfterMs, 30s)then retry waits 30s into the existing 45s xAI/Codex fixtures, retries early, and burns the attempt budget. HonorretryAfterMson remapped retryable 429s; abort if the value is a hang.src/agent/retry-policy.ts— hardcodedattempt >= 3re-owns vendoredMAX_ATTEMPTS. AskdefaultPolicyfor abort-vs-retry; override onlydelayMs.
Notes
extractRetryAfterMson Codex/Grok/OpenAI Responses is the right adapter boundary.- Terminal copy is the right surface for the "retrying" lie; that string only appears after abort.
TheGreatAxios
commented
Sep 9, 2026
TheGreatAxios
left a comment
Collaborator
Author
There was a problem hiding this comment.
Critic · Comment
Retry policy honors Retry-After on retryable 429s (capped at 30s), Responses adapters extract the header, and terminal copy no longer claims an in-flight retry after abort.
Findings
src/agent/retry-policy.ts:59— new path hardcodesattempt >= 3instead of reusing vendoredMAX_ATTEMPTSviadefaultPolicy. Sequence: retryable 429 withretryAfterMsset,attempt === 3aborts here; if vendor bumps the cap, this branch silently stays at 3. OverridedelayMson adefaultPolicyretry (or share a constant) rather than re-capping.src/provider/grok-responses-adapter.ts:255/src/provider/openai-responses-adapter.ts:237—extractRetryAfterMsis wired but only Codex asserts it (codex-responses-adapter.test.ts:67). Dropping the one-liner on Grok or OpenAI would not fail the suite.src/provider/codex-responses-adapter.ts:643—extractResponsesRetryAfterMsmatches vendored Chat Completions (vendor/intx-inference/src/providers/openai.ts:1011): numericretry-after/retry-after-msonly. HTTP-dateRetry-Afterstill yieldsundefinedand the 500/1000ms fallback. Same as vendor; not a regression.
Notes
- Remapped xAI/Codex 429 with
retryAfterMs: 45_000now waitsMAX_BLIND_WAIT_MS(30s) rather than aborting or using 500ms. Documented by the updated tests; a header longer than 30s without quota body markers can still under-wait and burn the remaining attempts. GATEWAY_OVERLOAD_USER_MESSAGEstill says “retrying…” and can surface terminally. Out of this diff.
Capping the wait at the blind-wait ceiling retried while the server was still closed. Attempt abort now follows defaultPolicy so the cap cannot drift from the vendored maximum.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
bun run checkpasses (lint, typecheck, build, projects-dir-guard)Fixes CL-7523