Repository navigation
fix(layers/aimd): pace requests after shared cooldown - #9634
Merged
Merged
Conversation
PsiACE
approved these changes
Dec 4, 2026
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.
Which issue does this PR close?
Closes #9546.
Rationale for this change
A shared
Retry-Afterpause can leave each AIMD budget full, allowing many requests to reach the backend together when the pause expires. A visible 429 or 503 can also increase the rate when the service reports it asUnexpectedor an inner retry succeeds.What changes are included in this PR?
When a usable
Retry-Afterestablishes or extends the shared cooldown, settle each budget and preserve at most one existing token. Apply feedback due by the shared deadline before crediting subsequent time at each budget's own rate. Each budget admits requests in FIFO order and cancellation leaves its balance available to the next waiter.Mark visible 429 and 503 responses as throttling for the request's budget. Service and I/O wrappers continue to feed parsed
RateLimitederrors to the enclosing operation's budget. The next window transition applies one decrease per throttled budget, even when the window contains several signals or a successful retry.Are there any user-facing changes?
After a cooldown, a budget with at least one token can dispatch one request immediately. An exhausted budget waits for refill. The layer documentation explains how to install
ConcurrentLimitLayerbefore AIMD so queued requests take HTTP permits after admission, while operations may hold service permits during the wait.Breaking changes
AI Usage Statement
magpie/codex/gpt-6.2-astraathightraced the cooldown and feedback contracts, checked permit ordering, and proposed acceptance cases.magpie/codex/gpt-6.2-solatmaximplemented the changes and verified them with a paused clock, the HTTP service, and the Retry layer over a controlled transport.magpie/codex/gpt-6.2-solathighindependently reviewed the initial and revised candidates, contributed the paused-clock regression for a late first poll, and verified pacing when an in-flight response arrives after an extended cooldown.