Skip to content

fix(quota): fix antigravity/agy multi-model quota skipping in combos - #7695

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.49from
irvandikky:fix/antigravity-multi-model-quota-skipping
Jul 19, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.49from
irvandikky:fix/antigravity-multi-model-quota-skipping

Conversation

@irvandikky

Copy link
Copy Markdown
Contributor

Fixes a bug in combos where an exhausted antigravity/agy model blocks all other models in the same provider connection due to connection-wide quota exhaustion short-circuiting in quotaCache.ts. Scopes rate limiters by model family in rateLimitManager.ts and updates antigravityQuotaFamily.ts for 'agy' spelling alias.

@irvandikky
irvandikky requested a review from diegosouzapw as a code owner July 18, 2026 21:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the 'antigravity' and 'agy' providers to the quota and rate-limiting systems, ensuring that model families (such as Claude and Gemini) are properly isolated. It updates prefix normalization, provider checks, rate limiter key generation, and quota exhaustion logic, and adds corresponding unit tests. Feedback on these changes highlights two key issues: in both the quota cache and the rate limiter, grouping unknown models under the generic 'other' family will cause them to incorrectly share quota evaluations and rate limits. To prevent this, exact-model scoping should be preserved for any models classified under the 'other' family.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/domain/quotaCache.ts Outdated
Comment on lines +229 to +232
const requestedFamily = getAntigravityQuotaFamily(requestedModel);
const matchingWindows = quotaNames.filter((windowName) => {
return getAntigravityQuotaFamily(windowName) === requestedFamily;
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Grouping all unknown models under the 'other' family in isQuotaExhaustedForRequest causes them to share a single quota evaluation. If one unknown model is exhausted but another is not, the exhausted model will not be correctly blocked because matchingWindows.every(...) will evaluate to false. To preserve exact-model scoping for unknown models, we should match the exact model name when the family is 'other'.

    const requestedFamily = getAntigravityQuotaFamily(requestedModel);
    const matchingWindows = quotaNames.filter((windowName) => {
      const family = getAntigravityQuotaFamily(windowName);
      if (family === "other" || requestedFamily === "other") {
        const getBare = (m: string) => {
          const norm = m.toLowerCase().trim().replace(/^(antigravity|agy)\/\//, "");
          const idx = norm.indexOf("/");
          return idx >= 0 ? norm.slice(idx + 1) : norm;
        };
        return getBare(windowName) === getBare(requestedModel);
      }
      return family === requestedFamily;
    });

Comment on lines +460 to +463
if ((provider === "antigravity" || provider === "agy") && model) {
const family = getAntigravityQuotaFamily(model);
return `${provider}:${connectionId}:${family}`;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using the 'other' family name directly in the rate limiter key groups all unknown models under a single rate limiter. A 429 on one unknown model would then incorrectly pause requests for all other unknown models on the same connection. We should use the exact model name as the scope when the family is 'other' to preserve exact-model rate limiting.

Suggested change
if ((provider === "antigravity" || provider === "agy") && model) {
const family = getAntigravityQuotaFamily(model);
return `${provider}:${connectionId}:${family}`;
}
if ((provider === "antigravity" || provider === "agy") && model) {
const family = getAntigravityQuotaFamily(model);
const scope = family === "other" ? model : family;
return `${provider}:${connectionId}:${scope}`;
}

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Nice fix — the family-scoping approach is correct and I confirmed the 'other' family exact-scoping issue flagged by the automated review is already handled in your second commit. Tests are well-targeted (Claude/Gemini isolation + 'agy' alias + 'other' exact-scope). Looks ready to merge as-is.

…der the cognitive-complexity cap

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @irvandikky! Real fix for connection-wide quota exhaustion short-circuiting on antigravity/agy multi-model combos. I extracted three helpers from isQuotaExhaustedForRequest so it clears the cognitive-complexity cap (behavior unchanged, tests green). Validated in local merge-train @ 2ae9ba63c (FAST gates green: static + changed tests + vitest).

@diegosouzapw
diegosouzapw merged commit ad5e67d into cheaper-inference:release/v3.8.49 Jul 19, 2026
3 checks passed
diegosouzapw added a commit that referenced this pull request Jul 19, 2026
… (owner-approved)

The /fix-prs validation-train sweep surfaced a cluster of otherwise-clean
contributor feature PRs (#6973/#7683/#7662/#7672/#7633/#7767) whose per-PR
+1/+2 own-growth collectively exceeded the tip's 3-unit complexity slack
(2056 vs 2059). This was the 4th such block of the day (#7695/#7747/#7768
each needed helper extraction earlier). Owner approved raising both ceilings
to give new-feature PRs breathing room: complexity to 2072 (combined-cluster
2068 + 4 headroom), cognitive to 900 (combined 896 + 4). Structural shrink
stays debt (#3501); tighten via --update next cycle.
@diegosouzapw diegosouzapw mentioned this pull request Jul 23, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…heaper-inference#7695)

* fix(quota): fix antigravity/agy multi-model quota skipping in combos

* fix(quota): preserve exact-model scoping for unknown models in 'other' family

* refactor(quota): extract helper to keep isQuotaExhaustedForRequest under the cognitive-complexity cap

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: irvandikky <irvandikky@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
… (owner-approved)

The /fix-prs validation-train sweep surfaced a cluster of otherwise-clean
contributor feature PRs (cheaper-inference#6973/cheaper-inference#7683/cheaper-inference#7662/cheaper-inference#7672/cheaper-inference#7633/cheaper-inference#7767) whose per-PR
+1/+2 own-growth collectively exceeded the tip's 3-unit complexity slack
(2056 vs 2059). This was the 4th such block of the day (cheaper-inference#7695/cheaper-inference#7747/cheaper-inference#7768
each needed helper extraction earlier). Owner approved raising both ceilings
to give new-feature PRs breathing room: complexity to 2072 (combined-cluster
2068 + 4 headroom), cognitive to 900 (combined 896 + 4). Structural shrink
stays debt (cheaper-inference#3501); tighten via --update next cycle.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…heaper-inference#7695)

* fix(quota): fix antigravity/agy multi-model quota skipping in combos

* fix(quota): preserve exact-model scoping for unknown models in 'other' family

* refactor(quota): extract helper to keep isQuotaExhaustedForRequest under the cognitive-complexity cap

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: irvandikky <irvandikky@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
… (owner-approved)

The /fix-prs validation-train sweep surfaced a cluster of otherwise-clean
contributor feature PRs (cheaper-inference#6973/cheaper-inference#7683/cheaper-inference#7662/cheaper-inference#7672/cheaper-inference#7633/cheaper-inference#7767) whose per-PR
+1/+2 own-growth collectively exceeded the tip's 3-unit complexity slack
(2056 vs 2059). This was the 4th such block of the day (cheaper-inference#7695/cheaper-inference#7747/cheaper-inference#7768
each needed helper extraction earlier). Owner approved raising both ceilings
to give new-feature PRs breathing room: complexity to 2072 (combined-cluster
2068 + 4 headroom), cognitive to 900 (combined 896 + 4). Structural shrink
stays debt (cheaper-inference#3501); tighten via --update next cycle.
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.

2 participants