Per review quota#156
Open
helq wants to merge 4 commits into
Open
Conversation
Introduce new configuration parameters under the [ai] section in Settings.toml to support more flexible backoff strategies: - global_backoff: toggle between global and per-worker backoff - quota_backoff_secs: flat delay for Quota Exceeded (429) errors - transient_backoff_type: exponential or flat transient retry backoff - transient_flat_backoff_secs: flat delay for transient retries Also implement corresponding fields and serde-defaults inside the Rust Settings parsing layer in src/settings.rs. Signed-off-by: Elkin Cruz <elkin@google.com>
Define a unified, downcastable AiError enum in src/ai/mod.rs to map provider-specific errors (QuotaExceeded, Transient, Fatal) at the API boundary. Implement custom error mappings for GeminiClient, ClaudeClient, and OpenAiCompatClient so that they return the standardized AiError wrapped in anyhow::Error. This decouples provider-specific error formatting from the core orchestration layer. Signed-off-by: Elkin Cruz <elkin@google.com>
Refactor QuotaManager to support flat backoffs and enforce a minimum delay cap (1s) to prevent zero-delay CPU exhaustion loops. Update Reviewer's orchestration in run_review_tool to instantiate a local QuotaManager if global_backoff is disabled, and update the retry loop to robustly downcast errors to AiError. Implement comprehensive unit tests for QuotaManager using Tokio's virtual clock, and add integration tests in reviewer.rs verifying worker isolation (local backoff) and dynamic deadline extensions (timeout exemption). Also update the design documentation under designs/ to document the new configurable backoff and AiError architecture. Signed-off-by: Elkin Cruz <elkin@google.com>
1e32510 to
46df351
Compare
This allows faster recovery after LLM API outages. If there is an outage, the exponential backoff might be overly aggressive, making some reviews stay stuck for much longer after the outage has happened. Signed-off-by: Elkin Cruz <elkin@google.com>
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.
The global throttling system might stall reviews after an API outage. These changes make the global quota mechanism configurable and allow to set up more aggressive retries.
Instead of using an exponential backoff mechanism that can stall reviews for hours, we can force a review on a given timeoff.