feat(rotation): add multi-account support with automatic model rotation#78
Open
deuriib wants to merge 9 commits into
Open
feat(rotation): add multi-account support with automatic model rotation#78deuriib wants to merge 9 commits into
deuriib wants to merge 9 commits into
Conversation
Shows consumed quota per model when remainingFraction and remainingAmount are both available, calculated as total = remaining / fraction, used = total - remaining.
The Code Assist quota API returns remainingFraction but not remainingAmount, so absolute 'used' counts cannot be calculated. Fall back to showing used percentage (100% - remaining%) instead of 'unknown' when only fraction data is available.
- Introduce AccountPool for managing multiple accounts - Implement health-weighted rotation strategy with quota fallback - Add AccountManager for dynamic account addition/removal - Persist dynamic accounts to ~/.config/opencode/gemini-auth.json - Make retry cooldowns, auth caches, and project contexts per-account - Update quota tool to display per-account and aggregate summaries
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.
Problem
Using a single Gemini account often leads to immediate rate limits and capacity exhaustion (429 errors) when handling complex coding sessions or multi-model agents. This affects users on both free and premium plans, particularly with high-reasoning models like Gemini Pro and Flash.
Solution
This PR implements comprehensive Multi-Account Profile and Automatic Model Rotation Support. The plugin dynamically distributes API requests across multiple configured accounts in an account pool, tracking their health status, remaining quotas, and rate-limit cooldowns. When an account experiences transient errors or capacity limits, the pool automatically rotates to the next healthiest available account.
Closes #25
Closes #30
PR Type
Summary
src/plugin/account-pool.ts,src/plugin/account-manager.ts): Manages multiple accounts loaded from configured provider options or user login profiles. Supports dynamic pool selection and status reporting.src/plugin/health.ts,src/plugin/rotation.ts): Ranks accounts by availability, success history, and quota. Employs priority sorting, ties breaking via LRU, and weighted random selection for low-quota states.src/plugin/retry/index.ts): Retries transient connection issues, handlesRetry-Afterheaders, and automatically triggers cooling-off periods for models experiencing 429 errors.src/plugin/quota.ts): Provides terminal formatting for multi-account usage checks, grouping limits by model version and displaying comprehensive usage/remaining percentages.Changes Table
src/plugin/account-pool.tssrc/plugin/health.tssrc/plugin/rotation.tssrc/plugin/retry/index.tssrc/plugin/token.tssrc/plugin/quota.tsTest Plan
bun testpasses successfully for all 140 tests.Contributor Checklist
type:*labelCo-Authored-Bytrailers