Skip to content

fix(layers/aimd): pace requests after shared cooldown - #9634

Merged
Xuanwo merged 2 commits into
mainfrom
xuanwo/aimd-cooldown-contract
Dec 4, 2026
Merged

Xuanwo merged 2 commits into
mainfrom
xuanwo/aimd-cooldown-contract

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Dec 4, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #9546.

Rationale for this change

A shared Retry-After pause 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 as Unexpected or an inner retry succeeds.

What changes are included in this PR?

When a usable Retry-After establishes 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 RateLimited errors 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 ConcurrentLimitLayer before AIMD so queued requests take HTTP permits after admission, while operations may hold service permits during the wait.

Breaking changes

AI Usage Statement

  • Pi with magpie/codex/gpt-6.2-astra at high traced the cooldown and feedback contracts, checked permit ordering, and proposed acceptance cases.
  • Pi with magpie/codex/gpt-6.2-sol at max implemented the changes and verified them with a paused clock, the HTTP service, and the Retry layer over a controlled transport.
  • Pi with magpie/codex/gpt-6.2-sol at high independently 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.

@Xuanwo
Xuanwo requested a review from PsiACE December 4, 2026 00:02
@Xuanwo
Xuanwo merged commit 869b69c into main Dec 4, 2026
145 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/aimd-cooldown-contract branch December 4, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement(layers/aimd): prevent post-cooldown burst spikes and refine HTTP 429/503 throttle feedback policy

2 participants