Repository navigation
feat(llm): add opt-in provider-wide in-flight limit for review runs - #1102
nitishagar wants to merge 1 commit into
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 8 selected item(s). |
51149c5 to
91f829d
Compare
00c36ee to
0f44294
Compare
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
0f44294 to
6f6ebc3
Compare
|
@nitishagar The feature is well-designed and worth merging. The per-attempt permit lifecycle correctly avoids the deadlock that oh-my-pi encountered in #3749, and max_in_flight matches the naming Hermes Agent Before merging, please address the following two items:
The business logic itself looks good. I’m happy to approve once these two items are addressed. |
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