feat: add scoped composite rate limiting#102
Conversation
Introduce a composable limiter registry for global and targeted throttling, and update generators/tests to use it.
Summary of ChangesHello @kevinmessiaen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly overhauls the rate limiting infrastructure, moving from a basic, per-instance approach to a sophisticated, registry-driven system. The core purpose is to provide more granular control over request throttling, allowing for the application of multiple, layered rate limits across different components or external services. This change enhances the system's ability to manage resource consumption and prevent abuse more effectively, particularly for external API calls, without adding complexity to individual generator implementations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-designed refactoring of the rate limiting mechanism, moving to a composable and scoped system. The new RateLimiter primitives and the registry for applying them based on target paths are a great improvement, making the system more flexible and powerful. The code is clean and the accompanying tests are thorough. I've found a few minor issues, mostly related to the test suite and a type hint, which I've detailed in the comments below.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Ensure already-acquired limiters are released if a later acquire fails.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| return self.rate_limiters == other.rate_limiters | ||
|
|
||
| def __hash__(self) -> int: | ||
| return hash(tuple(self.rate_limiters)) |


Introduce a composable limiter registry for global and targeted throttling, and update generators/tests to use it.
Note
Medium Risk
Touches core throttling behavior and removes the prior
rate_limiterconfiguration/serialization path, which could change runtime request pacing and how downstream code configures limits.Overview
Introduces a new composable, scoped rate-limiting system (
RateLimiterprimitives +CompositeRateLimiter+ hierarchical registry) that can apply global and target-specific throttles and exposes wait-time details viaRateLimitDetails/RateLimitEntry.Updates
LiteLLMGeneratorto always use registry-basedthrottle("llm","litellm",...)instead of a per-generatorrate_limiterfield, removes theWithRateLimitermixin/old singleton registry APIs, and rewrites tests (plus addspytest-timeout) to cover RPM, concurrency, composition, and scoped resolution behavior; generator/workflow serialization tests drop rate-limiter serialization expectations.Written by Cursor Bugbot for commit d4bc92d. This will update automatically on new commits. Configure here.