Repository navigation
Adaptive per-provider concurrency limiter (HAL-1372) - #17
Merged
Merged
Conversation
A fixed concurrency number is a guess about a limit the provider does not publish and changes without notice. Guess high and a 429 is a request silently lost unless every caller handles it; guess low and the wall clock waits on a semaphore that could have been wider. Measured on 2026-09-18: a chat provider at concurrency 6 rate-limited 13 of 21 documents into empty results that reported success; a System One provider under moderate load failed 3 of 40 batches after four minutes of retries. The limiter moves the number — additive increase, multiplicative decrease. A slot is taken before every call and released with the outcome; a rate-limit or transport failure halves the limit and honours Retry-After as a pause on new calls; a window of consecutive successes widens it by one. Auth and bad-request errors are not about capacity and leave the limit alone. Every change is reported through OnChange. It wraps both Client and Judge and sits inside retry, so each attempt takes a slot and the failure that triggers a retry has already narrowed the limit. Against a mock provider that admits 4 calls at once, 200 requests starting from a limit of 16 all complete and the limit settles near 4.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideIntroduces a shared adaptive AIMD semaphore for provider chat and judge operations, positioned inside retry so each attempt is capacity-controlled; it reacts to rate limits and transient failures, honors Retry-After pauses, reports changes and stats, and is covered by concurrency and behavior tests. Sequence diagram for adaptive per-provider request limitingsequenceDiagram
participant Caller
participant Retry
participant Limiter
participant Provider
participant OnChange
Caller->>Retry: Complete or Judge
Retry->>Limiter: Acquire(ctx)
Limiter-->>Retry: release
Retry->>Provider: Complete or Judge
Provider-->>Retry: response or error
Retry->>Limiter: release(err)
alt rate limit or transient failure
Limiter->>OnChange: Event(rate_limited or transient)
Limiter-->>Retry: narrow limit and honor Retry-After
Retry->>Retry: retry attempt
else success window reached
Limiter->>OnChange: Event(success)
Limiter-->>Retry: widen limit by one
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Closes HAL-1372 (llmgate half).
middleware/limit: an AIMD semaphore per provider that wraps bothClientandJudge. Halves on a 429 or transport failure and honoursRetry-Afteras a pause; widens by one after a window of successes; auth and bad-request errors leave it alone; every change is anOnChangeevent. Sits insideretryso each attempt takes a slot.Test: a mock provider that admits 4 concurrent calls and 429s the rest — 200 requests from an initial limit of 16 all complete under retry, and the limit settles near 4. Race detector clean.
Engine wiring (both binaries, tocdump and navbench in parallel through it, judgewalk page batches concurrent) follows in vectorless-engine.
Summary by Sourcery
Introduce adaptive per-provider concurrency control for client and judge requests, with retry-aware slot acquisition and operational visibility into capacity changes.
New Features:
Enhancements:
Documentation:
Tests:
Summary by CodeRabbit