antigravity: an account's tiers are asked again each hour, so one that became Ultra lists Gemini 4 without a restart (rick_49551 on Discord)

rick_49551 reports an Antigravity account on Google AI Ultra whose model
list in magpie has no Gemini 4. magpie lists whatever fetchAvailableModels
gives, less chat_/tab_ ids, six fixed ids and the models Google marks
disabled; which models Google gives depends on the tier named in
entitlement.userTier, and that tier came from loadCodeAssist once per
magpie run: googleState.projects kept it with no expiry, while Gemini
CLI's experiments (flags) are asked again each hour. An account that
became Pro or Ultra after magpie first asked went on naming its old tier
(none, for a free account) in every hourly relist, and Google went on
listing it gemini-4-argon-disabled with "disabled": true, as it does the
owner's free account today (app.log 11-04: "disabled
[gemini-4-argon-disabled]"), which a7ed2f61d leaves out. Only a restart
asked again.

Now the list (modelInfo) asks loadCodeAssist again once the tiers are an
hour old, keeps the project, and takes the new current/paid tier and plan;
a failed or empty answer keeps the old ones for another hour. A change is
logged with the old tiers. The request path (project()) is unchanged, so
no request waits on loadCodeAssist.

Tests: TestAntigravityTierAskedAgainAfterUpgrade (free account, then the
fake's loadCodeAssist says g1-ultra-tier "Google AI Ultra": within the hour
no new loadCodeAssist; an hour on the list names g1-ultra-tier and has
gemini-4-argon, the plan reads Google AI Ultra; a failed loadCodeAssist
keeps it).
Broken by hand: with the antigravityTiers call commented out it fails
"Ultra: models [gemini-3.8-flash-high], want [gemini-3.8-flash-high
gemini-4-argon]"; restored, it passes.
Run (mote, at this tree): gofmt -l; go vet ./internal/provider/ on darwin,
GOOS=linux -tags nogui, GOOS=windows; go test -tags nogui -count=1
./internal/provider/ (ok, 138s).
Not tried: a real Ultra account. The Ultra fixture (gemini-4-argon enabled
under g1-ultra-tier) is inferred from the free account's real list and
Google's forum notes, not rick's bytes. Whether this is rick's case
depends on his magpie log's loadCodeAssist/fetchAvailableModels lines:
if loadCodeAssist itself has no paid tier, or Google refuses
g1-ultra-tier (400), this change doesn't help, and those lines say so.
This commit is contained in:
yetone
2026-11-04 17:46:30 +08:00
parent 8ac5f98e2a
commit 69eb93e0a2
2 changed files with 134 additions and 0 deletions
@@ -381,3 +381,92 @@ func TestAntigravityTierNotRestedForOtherFailures(t *testing.T) {
t.Errorf("asked %v", f.fetches)
}
}
// An account that becomes Google AI Ultra while magpie runs gets Ultra's
// models on the next list, without a restart (rick_49551 on Discord: an
// Ultra account without Gemini 4). The tiers loadCodeAssist gave were kept
// for as long as magpie ran, so every hourly list went on naming none, and
// Google went on listing gemini-4-argon-disabled, as it does a free
// account (magpie's own log on 11-04: "disabled [gemini-4-argon-disabled]").
// Now they are asked again once an hour old, as Gemini CLI's experiments
// are, and a list names the tier the account has now.
func TestAntigravityTierAskedAgainAfterUpgrade(t *testing.T) {
const free = `{"currentTier":{"id":"free-tier","name":"Antigravity"},"cloudaicompanionProject":"aicode-consumers"}`
const ultra = `{"currentTier":{"id":"standard-tier","name":"Antigravity","usesGcpTos":true},
"paidTier":{"id":"g1-ultra-tier","name":"Google AI Ultra"},"cloudaicompanionProject":"aicode-consumers"}`
f := &fakeGoogle{load: free, modelsFor: func(body map[string]any) (int, string) {
e, _ := body["entitlement"].(map[string]any)
switch tier, _ := e["userTier"].(string); tier {
case "":
return 200, `{"models":{
"gemini-3.8-flash-high":{"displayName":"Gemini 3.8 Flash (High)","maxTokens":1048576,"quotaInfo":{"remainingFraction":1}},
"gemini-4-argon-disabled":{"displayName":"Gemini 4 Argon","maxTokens":1048576,"disabled":true,"quotaInfo":{"remainingFraction":1}}}}`
case "g1-ultra-tier":
return 200, `{"models":{
"gemini-3.8-flash-high":{"displayName":"Gemini 3.8 Flash (High)","maxTokens":1048576,"quotaInfo":{"remainingFraction":1}},
"gemini-4-argon":{"displayName":"Gemini 4 Argon","maxTokens":1048576,"quotaInfo":{"remainingFraction":1}}}}`
default:
return 400, tierRefused
}
}}
googleSandbox(t, f)
buf := captureLog(t)
auth := googleAuth{AccessToken: "tok", RefreshToken: "rt-ultra", Expiry: time.Now().Add(time.Hour).UnixMilli()}
if err := addGoogleLogin("antigravity", "ultra@example.com", "", auth); err != nil {
t.Fatal(err)
}
if got, want := antigravityModelIDs(t, "antigravity"), []string{"gemini-3.8-flash-high"}; !slices.Equal(got, want) {
t.Fatalf("free: models %v, want %v", got, want)
}
// the account becomes Ultra; within the hour the tiers stand
f.mu.Lock()
f.load = ultra
loads := len(f.loads)
f.mu.Unlock()
if got := antigravityModelIDs(t, "antigravity"); slices.Contains(got, "gemini-4-argon") {
t.Fatalf("tiers asked again within the hour: %v", got)
}
f.mu.Lock()
if len(f.loads) != loads {
t.Errorf("loadCodeAssist asked %d times within the hour", len(f.loads)-loads)
}
f.mu.Unlock()
// an hour on, the list names Ultra and has Gemini 4 Argon
googleState.Lock()
for k, p := range googleState.projects {
p.at = p.at.Add(-googleTiersFor)
googleState.projects[k] = p
}
googleState.Unlock()
if got, want := antigravityModelIDs(t, "antigravity"), []string{"gemini-3.8-flash-high", "gemini-4-argon"}; !slices.Equal(got, want) {
t.Fatalf("Ultra: models %v, want %v", got, want)
}
f.mu.Lock()
last := f.fetches[len(f.fetches)-1]
f.mu.Unlock()
if fmt.Sprint(last["entitlement"]) != "map[userTier:g1-ultra-tier]" || last["project"] != "aicode-consumers" {
t.Errorf("asked %v", last)
}
if w := `paid tier g1-ultra-tier (Google AI Ultra), project "aicode-consumers" (was current tier "free-tier", paid tier "")`; !strings.Contains(buf.String(), w) {
t.Errorf("log lacks %q:\n%s", w, buf.String())
}
if q := googleLogins("antigravity")[0].acct.quota(context.Background(), ""); q.Plan != "Google AI Ultra" {
t.Errorf("plan %q", q.Plan)
}
// loadCodeAssist failing keeps the tiers it gave
f.mu.Lock()
f.load = `not json`
f.mu.Unlock()
googleState.Lock()
for k, p := range googleState.projects {
p.at = p.at.Add(-googleTiersFor)
googleState.projects[k] = p
}
googleState.Unlock()
if got := antigravityModelIDs(t, "antigravity"); !slices.Contains(got, "gemini-4-argon") {
t.Fatalf("tiers lost on a failed loadCodeAssist: %v", got)
}
}
+45
View File
@@ -383,6 +383,8 @@ type googleProject struct {
// is on ("free-tier", "standard-tier") and the Google One plan it pays
// for ("g1-pro-tier"), "" when not known
tier, paid string
// when loadCodeAssist was last asked for them (antigravityTiers)
at time.Time
}
// entitlements are the tiers to name in fetchAvailableModels'
@@ -574,12 +576,54 @@ func (g googleAccount) project(ctx context.Context) (googleProject, error) {
if err != nil {
return googleProject{}, err
}
p.at = time.Now()
googleState.Lock()
googleState.projects[key] = p
googleState.Unlock()
return p, nil
}
// googleTiersFor is how long the tiers loadCodeAssist gave an Antigravity
// account are named in its fetchAvailableModels before they are asked
// again. They were kept for as long as magpie ran: an account that became
// Google AI Pro or Ultra after magpie first asked went on naming the tier
// it had then, and Google listed it the models of that tier, with Gemini 4
// Argon marked disabled and so left out, until magpie restarted (rick_49551
// on Discord: an Ultra account without Gemini 4). Asked again at most every
// hour, as Gemini CLI's experiments are (flags).
const googleTiersFor = time.Hour
// antigravityTiers is p with the account's tiers and plan as
// loadCodeAssist gives them now, once p's are googleTiersFor old; p as it
// was, its project the same, when they can't be read, asked again after
// another googleTiersFor.
func (g googleAccount) antigravityTiers(ctx context.Context, p googleProject) googleProject {
if time.Since(p.at) < googleTiersFor {
return p
}
var load loadCodeAssistReply
body := map[string]any{"metadata": map[string]any{"ideType": "ANTIGRAVITY"}}
if err := g.call(ctx, g.app.loadBase, "loadCodeAssist", body, &load, nil); err != nil {
log.Printf("antigravity %s: loadCodeAssist at %s: %v; naming the tiers it gave before (current %q, paid %q)", g.user, g.app.loadBase, err, p.tier, p.paid)
} else if cur, paid := load.tiers(); cur != "" || paid != "" {
if cur != p.tier || paid != p.paid {
log.Printf("antigravity %s: loadCodeAssist at %s: %s (was current tier %q, paid tier %q)", g.user, g.app.loadBase, load.describe(), p.tier, p.paid)
}
p.tier, p.paid = cur, paid
if pl := load.plan(); pl != "" {
p.plan = pl
}
}
p.at = time.Now()
key := g.app.agent + "\x00" + g.auth.RefreshToken
googleState.Lock()
if _, ok := googleState.projects[key]; ok { // not since forgotten (setGoogleProject)
googleState.projects[key] = p
}
googleState.Unlock()
return p
}
type loadCodeAssistReply struct {
CurrentTier *codeAssistTier `json:"currentTier"`
PaidTier *codeAssistTier `json:"paidTier"`
@@ -984,6 +1028,7 @@ func (g googleAccount) modelInfo(ctx context.Context) ([]googleModelInfo, error)
}
var out []googleModelInfo
if g.app.agent == "antigravity" {
p = g.antigravityTiers(ctx, p)
var res struct {
Models map[string]struct {
DisplayName string `json:"displayName"`