feat(llm): add opt-in provider-wide in-flight limit for review runs - #1102
Open
nitishagar wants to merge 1 commit into
Open
feat(llm): add opt-in provider-wide in-flight limit for review runs#1102nitishagar wants to merge 1 commit into
nitishagar wants to merge 1 commit into
Conversation
Review runs overlap LLM requests from several paths: file-foreground work (plan, main loop, grace round), one async memory-compression job per file conversation, the comment worker pool's re-location calls, and the review filter. --concurrency bounds file workers only, so a loaded provider sees unbounded overlap. This adds a provider-scoped admission gate at the shared SDK middleware boundary, acquired once per real SDK attempt (inside the SDK retry loop) and released through an idempotent response-body wrapper: transport errors and body-less responses release immediately, retryable responses free their slot before the SDK's backoff sleep, and streaming bodies hold theirs until the stream ends. A panic anywhere between acquisition and the body handoff still releases via a deferred path, and a failed read frees the slot just like EOF. Admission applies only to ocr review: the run context is marked with an admission scope that survives context.WithoutCancel, so compression and pooled re-location children are gated, while ocr scan and ocr llm test never carry the scope and are untouched. The gate mounts outside the retry observer, keeping gate queue time out of the retry report's duration_to_headers_ms; observed_backoff_ms may include it, documented at its definition. Configuration is a per-provider max_in_flight field (custom and preset provider entries), settable via ocr config set, defaulting to unset/0 which mounts no middleware at all. The SDK remains the sole retry owner: no retry policy, count, or backoff behavior changes. Part of alibaba#368
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 8 selected item(s). |
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.
Implements #787. The issue's Status section asks for the configuration surface to be aligned before code — this PR is that proposal made concrete: field
max_in_flighton provider entries (custom and preset),ocr config set custom_providers.<name>.max_in_flight N, default unset/0= disabled, provider-only (nollm.*mirror — it describes endpoint capacity, not model config). Every naming/placement decision below is one comment away from adjustment if you'd like it shaped differently.What
One provider-scoped admission gate per review run, shared by every
ocr reviewLLM request path — plan, main task, grace round, memory compression, comment re-location, review filter:Close(double-close safe; a panic between acquisition and handoff releases via a deferred path). The SDK closes retryable bodies before backoff, so 429/529 retries free their slot during the wait; streaming responses hold theirs until the stream ends.review_cmd.go);context.WithoutCancelchildren (async compression, pooled re-location) inherit it.ocr scanandocr llm testnever carry the scope — ungated by construction, verified by tests.WaitBackgroundboundary.ocr.llm-retry-report/v1schema untouched. The gate mounts outside the retry observer, soduration_to_headers_msstill measures transport time only (test-asserted);observed_backoff_msmay include admission waiting — documented at its definition per the issue's wording.0mounts no middleware at all — the request path is byte-identical to today.Config example
ocr config set custom_providers.my-gateway.max_in_flight 4Tests
duration_to_headers_msexcludes gate wait; limit=1 foreground+background both complete.ocr reviewagainst a config-file provider withmax_in_flight: 1and asserts the same review that overlapped without the limit serializes to exactly one in-flight attempt.make coveragethreshold 90%), full suite green under-race.Part of #368 (the fixed provider-wide admission limit it requires; repository workflows may display but must not implement provider admission).
Closes #787