runking on Discord: Antigravity has three groups (Gemini 3, Gemini 4,
Claude); Claude was used up, Gemini 4 not, and the card showed only
Gemini 5h/7d and Claude 5h/7d, no Gemini 4.
Cause: when retrieveUserQuotaSummary has no "Gemini 4 Argon" group (an
Ultra account's, whose Argon quota Antigravity-Manager reads in
Gemini's; or the prod endpoint's, per CodexBar), pools() put every
Gemini model into the family-wide "Gemini Models" pool, gemini-4-argon
too, though fetchAvailableModels gave it a reading of its own. The card
then showed Gemini's reading for it and hid Argon's.
Now a model is folded into its family's pool only when its own reading
matches the pool's 5 hours (share left within half a point, reset within
a minute when both tell one). Otherwise it is a pool of its own, named
as Google names the model without its level ("Gemini 4 Argon (High)" is
Gemini 4 Argon), with a week's span when its reset is past 5 hours. It
is Aside, as every pool is, so routing still reads the model's own
window. The GUI already shows a model's own pool ("Gemini 4 7d" ring);
its code is unchanged.
Routing: Allowance.Pooled said a model no window counts was the
account's. Antigravity's Gemini models that fetchAvailableModels gives
no quotaInfo (#3737) have no window, so a 429 on one rested the whole
account. When every window an account has is some models' only, a
refusal of a model none counts now rests the model. An account with a
window of its whole stays as before. A used-up Claude group already
rested only Claude's models.
pools() logs the summary's group names and bucket ids once per change
per account, under an 8-hex hash of the account, with no token or
email, so the next report shows the shape Google sent.
Run (mote, at this head): go test ./internal/provider ./internal/gateway
-count=1 -timeout 45m ok; GUI quota-pool-model, quota-pools,
quota-pool-order (Chromium and WebKit, en and zh) 12/12 ok; gofmt; GOOS
linux and windows go vet ./internal/provider ok.
Red on the old code: TestAntigravityQuotaModelApartFromGroup (Argon
folded into Gemini) and TestAllowancePooledModelNoWindowCounts (rests
the account).
Broken by hand: sameReading always false makes the "read alike" case red
(every Gemini model split off).
Not tried: a real account. The fixtures come from the proto in the agy
binary and the shapes Antigravity-Manager and CodexBar record, with and
without the Argon group. Whether runking's summary lacks the group, or
has it inside Gemini Models, is unconfirmed; the new log will show it.
Reported-by: runking (Discord)
128 lines
5.3 KiB
Go
128 lines
5.3 KiB
Go
package provider
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
)
|
|
|
|
// A refusal for a model counted by a pool of some models only is that
|
|
// model's, not the account's: Cursor's Other Models used up leaves Auto in
|
|
// Cursor Models (Xiaopodev on X), Opus's own week leaves Sonnet; one of
|
|
// the whole account's windows used up is the account's.
|
|
func TestAllowancePooled(t *testing.T) {
|
|
now := time.Now()
|
|
month := now.Add(20 * 24 * time.Hour)
|
|
pool := map[string]bool{"auto": true, "composer-2": true}
|
|
q := quotaOfPlugin(SubscriptionQuota{}, plugin.Usage{Windows: []plugin.UsageWindow{
|
|
{Name: "Cursor Models", Used: fptr(12), Models: []string{"auto", "composer-2"}},
|
|
{Name: "Other Models", Used: fptr(100), NotModels: []string{"auto", "composer-2"}},
|
|
{Name: "Total", Used: fptr(60), Aside: true},
|
|
}})
|
|
cursor := allowanceOf(q.Windows, now)
|
|
for _, m := range []string{"auto", "composer-2", "claude-4.6-sonnet", "gpt-5.5"} {
|
|
if !cursor.Pooled(m, 100, now) {
|
|
t.Errorf("Cursor: %s refused isn't the model's alone", m)
|
|
}
|
|
if used, _ := cursor.For(m, now); (used == 100) == pool[m] {
|
|
t.Errorf("Cursor: %s used %v", m, used)
|
|
}
|
|
}
|
|
|
|
claude := Allowance{
|
|
{Used: 100, Resets: month, Span: 7 * 24 * time.Hour, Model: "opus"},
|
|
{Used: 40, Resets: month, Span: 7 * 24 * time.Hour},
|
|
}
|
|
if !claude.Pooled("claude-opus-4-7", 100, now) {
|
|
t.Error("Opus's own week used up rests the account")
|
|
}
|
|
if claude.Pooled("claude-sonnet-4-6", 100, now) {
|
|
t.Error("Sonnet, refused with no pool of its full, counts as pooled")
|
|
}
|
|
claude[1].Used = 100
|
|
if claude.Pooled("claude-opus-4-7", 100, now) {
|
|
t.Error("the account's week used up rests only Opus")
|
|
}
|
|
if (Allowance{}).Pooled("auto", 100, now) {
|
|
t.Error("an allowance not known counts as pooled")
|
|
}
|
|
}
|
|
|
|
// Will on Discord: Cursor's plugin lists Grok 4.7 at its context sizes
|
|
// alone (grok-4.7@256k, grok-4.7@500k), and a routing group still asks for
|
|
// bare cursor/grok-4.7, which the plugin runs at its default size. That is
|
|
// the Cursor Models pool's (84% left), not Other Models' (used up); the
|
|
// Routing page showed it 0% left and routing ranked it last. The lists are
|
|
// the ones cursor 0.2.3's usage() returns for such an account.
|
|
func TestPluginPoolCountsBareIDOfSizes(t *testing.T) {
|
|
now := time.Now()
|
|
pool := []string{"auto", "grok-4.7@256k", "grok-4.7@500k", "composer-2.5", "default"}
|
|
q := quotaOfPlugin(SubscriptionQuota{}, plugin.Usage{Windows: []plugin.UsageWindow{
|
|
{Name: "Cursor Models", Used: fptr(16), Models: pool},
|
|
{Name: "Other Models", Used: fptr(100), NotModels: pool},
|
|
{Name: "Total", Used: fptr(60), Aside: true},
|
|
}})
|
|
a := allowanceOf(q.Windows, now)
|
|
for m, want := range map[string]float64{
|
|
"grok-4.7": 16, // the reporter's: bare, its sizes listed
|
|
"Grok-4.7": 16,
|
|
"grok-4.7@256k": 16,
|
|
"composer-2.5": 16,
|
|
// distinct models stay in Other Models: another family member, a
|
|
// suffix that isn't a size, a size of a model the pool doesn't list
|
|
"grok-4": 100,
|
|
"grok-4.7-trial": 100,
|
|
"claude-opus-5-5": 100,
|
|
"claude-opus-5-5@300k": 100,
|
|
"composer-2.5-fast@1m": 100,
|
|
"@256k": 100,
|
|
} {
|
|
if used, _ := a.For(m, now); used != want {
|
|
t.Errorf("%s: used %v, want %v", m, used, want)
|
|
}
|
|
}
|
|
if !q.Windows[0].Counts("grok-4.7") || q.Windows[1].Counts("grok-4.7") {
|
|
t.Error("the usage page's holds count grok-4.7 in Other Models")
|
|
}
|
|
|
|
// the other way: the pool lists a bare id (Cursor's autoBucketModels),
|
|
// and the model is asked for at a size
|
|
q = quotaOfPlugin(SubscriptionQuota{}, plugin.Usage{Windows: []plugin.UsageWindow{
|
|
{Name: "Cursor Models", Used: fptr(16), Models: []string{"auto", "grok-4.8"}},
|
|
{Name: "Other Models", Used: fptr(100), NotModels: []string{"auto", "grok-4.8"}},
|
|
}})
|
|
a = allowanceOf(q.Windows, now)
|
|
if used, _ := a.For("grok-4.8@1m", now); used != 16 {
|
|
t.Errorf("grok-4.8@1m: used %v, want 16 (Cursor Models)", used)
|
|
}
|
|
}
|
|
|
|
// A model no window counts, on an account whose every window is some
|
|
// models' only — Antigravity's Gemini models that fetchAvailableModels
|
|
// gives no quota (#3737) beside Claude's own — is refused alone: nothing
|
|
// says the account is out, and Claude used up never stopped Gemini 4
|
|
// either (runking on Discord). With a window of the whole account, its
|
|
// refusal is still the account's.
|
|
func TestAllowancePooledModelNoWindowCounts(t *testing.T) {
|
|
now := time.Now()
|
|
week := now.Add(5 * 24 * time.Hour)
|
|
agy := allowanceOf([]QuotaWindow{
|
|
{Name: "Claude Sonnet 4.6", Model: "claude-sonnet-4-6", Family: "Claude", Used: 100, ResetsAt: &week},
|
|
{Name: "Gemini 3 Flash", Model: "gemini-3-flash", Family: "Gemini", Used: 8, ResetsAt: &week},
|
|
{Name: "5 hours", Pool: "Gemini", Used: 8, Aside: true},
|
|
}, now)
|
|
for _, m := range []string{"gemini-4-argon-high", "claude-sonnet-4-6", "gemini-3-flash"} {
|
|
if !agy.Pooled(m, 100, now) {
|
|
t.Errorf("Antigravity: %s refused rests the account", m)
|
|
}
|
|
}
|
|
whole := Allowance{{Used: 30, Resets: week, Span: 7 * 24 * time.Hour}, {Used: 10, Resets: week, Model: "opus"}}
|
|
if whole.Pooled("gemini-4-argon-high", 100, now) {
|
|
t.Error("a model the account's own week counts, refused, rests only the model")
|
|
}
|
|
if (Allowance{{Used: 10, Resets: week, Model: "opus"}, {Used: 20, Resets: week}}).Pooled("x", 100, now) {
|
|
t.Error("with a window of the whole account, a model no window counts is refused alone")
|
|
}
|
|
}
|