Skip to content

Conversation

@NoeFabris
Copy link
Owner

Summary

  • centralize Gemini routing decisions so cli_first controls initial pool selection consistently for unprefixed models
  • remove runtime quota_fallback gating and make Gemini fallback between Antigravity and Gemini CLI automatic in both directions
  • keep quota_fallback accepted in config/schema for backward compatibility, but mark it deprecated/ignored and update docs/tests accordingly

Validation

  • npm run typecheck
  • npm test -- quota-fallback
  • npm test -- accounts
  • npm run build
  • npm test

Supersedes #404.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Walkthrough

This 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)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main changes: simplifying Gemini routing logic and removing the runtime gating of the legacy quota_fallback config option.
Description check ✅ Passed The description clearly relates to the changeset, explaining the three main objectives of the PR and listing validation steps performed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5234cfc and 00ec4e2.

📒 Files selected for processing (1)
  • docs/MULTI-ACCOUNT.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/MULTI-ACCOUNT.md
⏰ 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)
  • GitHub Check: Greptile Review

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

This PR centralizes Gemini routing logic and removes the quota_fallback config flag, making bidirectional fallback between Antigravity and Gemini CLI quotas automatic for all Gemini requests.

Key changes:

  • Introduced resolveHeaderRoutingDecision() to centralize routing decisions
  • Removed cliFirst condition from antigravity→gemini-cli fallback path, enabling bidirectional fallback
  • Deprecated quota_fallback flag (accepted but ignored)
  • Updated tests to reflect new bidirectional behavior

Critical issue:
The implementation changes documented behavior for explicit quota suffixes. Previously, models with explicit :antigravity or :gemini-cli suffixes would never fallback to the alternate quota (they would only switch accounts). The old schema docs stated: "Only applies when model is requested without explicit quota suffix. Explicit suffixes like :antigravity or :gemini-cli always use that specific quota and switch accounts if exhausted."

The new code sets allowQuotaFallback: family === "gemini" unconditionally, ignoring the explicitQuota flag. This means explicit quota models will now fallback, breaking the documented contract and potentially affecting users who rely on strict quota isolation.

Confidence Score: 2/5

  • This PR contains a breaking behavior change that affects explicit quota model routing
  • The code quality is good and the refactoring improves maintainability, but there's a logic error where explicitQuota is no longer checked when setting allowQuotaFallback. This breaks the documented behavior that explicit quota suffixes should not fallback to alternate quotas. The test at line 157 confirms this new behavior but contradicts the old documentation.
  • Pay close attention to src/plugin.ts:2834 where the routing decision logic needs to respect explicitQuota

Important Files Changed

Filename Overview
src/plugin.ts Core routing logic centralized but introduces breaking change: explicit quota suffixes (:antigravity, :gemini-cli) now fallback to alternate quota, violating documented contract
src/plugin/quota-fallback.test.ts Tests updated to reflect new bidirectional fallback, but test at line 157 demonstrates that explicit quota models now fallback, changing documented behavior
README.md Updated to describe automatic fallback, but doesn't clarify behavior change for explicit quota suffixes
docs/MULTI-ACCOUNT.md Updated to reflect automatic bidirectional fallback, but doesn't document behavior change for explicit quota suffixes

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@@ -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 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

cliFirst,
preferredHeaderStyle,
explicitQuota,
allowQuotaFallback: family === "gemini",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

@NoeFabris NoeFabris merged commit 45e82c8 into dev Feb 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant