feat: implement credential-based round-robin for gemini-cli#1663
feat: implement credential-based round-robin for gemini-cli#1663luispater merged 1 commit intorouter-for-me:devfrom
Conversation
…uths Changes the RoundRobinSelector to use two-level round-robin when gemini-cli virtual auths are detected (via gemini_virtual_parent attr): - Level 1: cycle across credential groups (parent accounts) - Level 2: cycle within each group's project auths Credentials start from a random offset (rand.IntN) for fair distribution. Non-virtual auths and single-credential scenarios fall back to flat RR. Adds 3 test cases covering multi-credential grouping, single-parent fallback, and mixed virtual/non-virtual fallback.
Summary of ChangesHello @rensumo, 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 enhances the 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
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
The pull request successfully implements a two-level round-robin selection strategy for gemini-cli virtual auths. This change ensures that load is distributed evenly across different credentials (parent accounts) before cycling through projects within each credential. The implementation is robust, handles mixed auth types gracefully by falling back to flat round-robin, and includes comprehensive unit tests. I have identified a minor performance optimization regarding the grouping logic being executed under a mutex for all providers.
|
|
||
| // Check if any available auth has gemini_virtual_parent attribute, | ||
| // indicating gemini-cli virtual auths that should use credential-level polling. | ||
| groups, parentOrder := groupByVirtualParent(available) |
There was a problem hiding this comment.
The groupByVirtualParent function iterates through all available auths and performs string operations and map allocations. Since this is called while holding the s.mu mutex, it could potentially become a bottleneck if the number of available auths is large or if there is high concurrency. Consider checking the provider string first to only perform this grouping for relevant providers (like gemini-cli), or optimizing the check to bail out early if no virtual auths are expected.
feat: implement credential-based round-robin for gemini-cli
The previous code applied flat round-robin across all virtual auths (including projects from different credentials) in a fixed order, causing the same credential to be used consecutively in bulk, resulting in uneven load distribution.