Repository navigation
Retry waits as long as the provider's Retry-After asks - #1703
Merged
Merged
Conversation
Muizzkolapo
marked this pull request as ready for review
November 8, 2026 12:40
When a provider rate-limited a request and said how long to wait, agac parsed the header into the error and then waited a random backoff of up to 1, 2, 4 seconds anyway. The backoff's base_delay and max_delay were read from the retry block, but the schema refused those keys, so they were always 1 and 60 seconds. RetryService now waits the Retry-After the error carries, capped at max_delay with a warning that names both numbers; without one it keeps the jittered backoff. The header is read as retry-after-ms, then as seconds or an HTTP date; a past date is 0 and a value that is not a number is unreadable. RetryConfig declares base_delay (above 0, at most 300) and max_delay (above 0, at most 3600, at least base_delay). Batch retry is unchanged and reads neither.
Muizzkolapo
force-pushed
the
retry-waits-as-the-provider-asks
branch
from
November 8, 2026 16:01
7ea902f to
d42a10d
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Retry-Afterinto the error and then waited a random backoff of up to 1, 2, 4 seconds anyway.RetryServicenow waits theRetry-Afterthe error carries, capped atmax_delaywith a warning that names both numbers. Without one, it keeps the jittered backoff.retry-after-ms, then as seconds or as an HTTP date. A past date is 0; a value that is not a number is unreadable and gets the backoff.RetryConfigdeclaresbase_delay(above 0, at most 300, default 1.0) andmax_delay(above 0, at most 3600, default 60.0, at leastbase_delay). Before, the code read them but the schema refused them.BatchRetryService) is unchanged and reads neither delay.Verification
tests/unit/processing/test_retry_waits_as_the_provider_asks.pyonmain)Retry-After: nanmadetime.sleep(nan)raise. Lens C: YES, but the cap test used the default 60, so a hard-coded 60 passedmax_delay=5. Lens A re-review: YESagac-provider, which never rate-limits, so it cannot reach this pathRateLimitEventstill shows the provider's uncapped value ("retrying in 500.0s" when the wait is 60 s); the OpenAI, Anthropic and Groq SDKs keep their own two retries.