fix: align API retry logic with Claude Code (Retry-After header, jitter, 10 retries)#1327
Merged
Conversation
…er, 10 retries) - Honor Retry-After response header instead of fixed exponential backoff - Increase max retries from 5 to 10 - Change base delay from 2000ms to 500ms with 25% jitter - Add max delay cap of 32s - Update spec 012-ai-error-handling.md (user story 3, FR-005, FR-010) - Add test for Retry-After header behavior
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
Align API retry logic in
openaiClient.tswith Claude Code'swithRetry.tsto avoid ineffective retries during rate limiting.Changes
Retry-Afterresponse header: when the server returns 429 with aRetry-Afterheader, wait the specified duration instead of using exponential backoff. This was the root cause of the first 3 retries being wasted — the server hadn't lifted the rate limit yet.retryAftervalue in warning logsSpec
Updated
specs/012-ai-error-handling.md:Test
Retry-Afterheader test: verifies 30s header is honored and no retry happens before thatBefore vs After