fix: simplify Gemini routing and ignore legacy quota_fallback#413
fix: simplify Gemini routing and ignore legacy quota_fallback#413
Conversation
WalkthroughThis PR documents quota_fallback as deprecated/ignored at runtime and clarifies that Gemini quota fallback between Antigravity and Gemini CLI is always enabled. It adds a description to the JSON schema and updates configuration and multi-account docs to reflect the always-on, bidirectional fallback. In code, header routing logic is centralized via a new exported resolveHeaderRoutingDecision(urlString, family, config) that returns cliFirst, preferredHeaderStyle, explicitQuota, and allowQuotaFallback; resolveQuotaFallbackHeaderStyle is simplified to accept only family, headerStyle, and alternateStyle. Tests and __testExports were updated to expose the new routing decision hook. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile OverviewGreptile SummaryThis PR centralizes Gemini routing logic and removes the Key changes:
Critical issue: The new code sets Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Plugin
participant RoutingDecision
participant AccountManager
participant Antigravity
participant GeminiCLI
Client->>Plugin: Request Gemini model (e.g., gemini-3-flash)
Plugin->>RoutingDecision: resolveHeaderRoutingDecision(url, family, config)
alt cli_first = false (default)
RoutingDecision-->>Plugin: preferredHeaderStyle="antigravity", allowQuotaFallback=true
Plugin->>AccountManager: getCurrentOrNextForFamily("antigravity")
Plugin->>Antigravity: Request with antigravity headers
alt Antigravity exhausted on all accounts
Plugin->>AccountManager: Check for gemini-cli availability
Plugin->>GeminiCLI: Fallback to gemini-cli quota
GeminiCLI-->>Plugin: Response
else Antigravity available
Antigravity-->>Plugin: Response
end
else cli_first = true
RoutingDecision-->>Plugin: preferredHeaderStyle="gemini-cli", allowQuotaFallback=true
Plugin->>AccountManager: getCurrentOrNextForFamily("gemini-cli")
Plugin->>GeminiCLI: Request with gemini-cli headers
alt Gemini-CLI exhausted
Plugin->>AccountManager: Check for antigravity availability
Plugin->>Antigravity: Fallback to antigravity quota
Antigravity-->>Plugin: Response
else Gemini-CLI available
GeminiCLI-->>Plugin: Response
end
end
Plugin-->>Client: Response
|
docs/MULTI-ACCOUNT.md
Outdated
| @@ -27,7 +27,7 @@ For Gemini models, the plugin accesses **two independent quota pools** per accou | |||
| | **Antigravity** | Default for all requests | | |||
| | **Gemini CLI** | Automatic fallback when Antigravity exhausted on ALL accounts | | |||
There was a problem hiding this comment.
description implies unidirectional fallback (only Antigravity → CLI) but fallback is now bidirectional. Consider clarifying: "Automatic fallback between Antigravity and Gemini CLI in both directions"
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/MULTI-ACCOUNT.md
Line: 28:28
Comment:
description implies unidirectional fallback (only Antigravity → CLI) but fallback is now bidirectional. Consider clarifying: "Automatic fallback between Antigravity and Gemini CLI in both directions"
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| cliFirst, | ||
| preferredHeaderStyle, | ||
| explicitQuota, | ||
| allowQuotaFallback: family === "gemini", |
There was a problem hiding this comment.
allowQuotaFallback ignores explicitQuota, breaking documented behavior. Previously, explicit quota suffixes (:antigravity or :gemini-cli) would "always use that specific quota and switch accounts if exhausted" without falling back. Now they fallback to the alternate quota.
| allowQuotaFallback: family === "gemini", | |
| allowQuotaFallback: !explicitQuota && family === "gemini", |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugin.ts
Line: 2834:2834
Comment:
`allowQuotaFallback` ignores `explicitQuota`, breaking documented behavior. Previously, explicit quota suffixes (`:antigravity` or `:gemini-cli`) would "always use that specific quota and switch accounts if exhausted" without falling back. Now they fallback to the alternate quota.
```suggestion
allowQuotaFallback: !explicitQuota && family === "gemini",
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
cli_firstcontrols initial pool selection consistently for unprefixed modelsquota_fallbackgating and make Gemini fallback between Antigravity and Gemini CLI automatic in both directionsquota_fallbackaccepted in config/schema for backward compatibility, but mark it deprecated/ignored and update docs/tests accordinglyValidation
Supersedes #404.