Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
antigravity: a tier Google refuses in fetchAvailableModels is asked once a day and is no "Model list" row (ferock4669)
yetone7c900f468f4f
diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.mdindex ae2c84fa5..abd601aeb 100644--- a/docs/subsystems/gateway-sessions.md+++ b/docs/subsystems/gateway-sessions.md@@ -546,7 +546,14 @@ for: `provider_test`, `api_detect` or `model_list`full of 0-token rows no agent sent. A list that failed is still a row,under the Failed filter too, as is every Test and Detect APIs. Olderlines stay in `usage.jsonl`, read by nothing.- `TestAnsweredModelListIsNoRow` covers it.+ `TestAnsweredModelListIsNoRow` covers it. A request that is only a step+ towards a list is no row either (`probelog.Taken`): an Antigravity+ account's `fetchAvailableModels` with its tier named, which Google+ answers 400 for a Google AI Pro account before the request without one+ lists its models (ferock4669 on Discord, a 400 "Model list" row beside+ every list). That tier isn't named again for a day (`tierRefusedFor`);+ the request without one is written down as any list.+ `TestAntigravityRefusedTierAskedOnceAndNoRow`.- **Whose:** a row recorded under its host, sent before its provider hadan id, is listed under the provider saved on that host now(`Renames.ProbeOf`), and with none on it, a deleted one's, under the iddiff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.mdindex 8d7779606..ca1c08b72 100644--- a/docs/subsystems/providers-accounts.md+++ b/docs/subsystems/providers-accounts.md@@ -233,7 +233,7 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`.- The account Codex or Claude Code is signed in to can be paused (`SetLoginOn` off, #263) only while another of its accounts is on. The gateway then sends it nothing: Codex's own-model turns go through routing, which passes over it (`OwnPaused`), and a native compaction (`/responses/compact`) goes to the first account on that isn't resting, signed as that account (`compactOn` in [codex_backend.go](../../internal/gateway/codex_backend.go)). The last other account off, the paused one is used again. A switched-off Codex provider is not a pause: Codex's own-model requests still relay on its sign-in as they came.- A switched-off provider (`Off`, #163) stays saved. The gateway says it is off instead of saying the model is unknown.- A subscription switched off (`Off`) or whose account was removed from magpie (`Hidden`) is left alone in the background (`leftAlone` in [`left_alone.go`](../../internal/provider/left_alone.go); Riko on Discord, whose Claude switched off still ran `claude auth status --json` every minute). No CLI is asked who is signed in (`claudeIdentity`, `cliIdentity.get` for Cursor and Devin): what it said last, in memory or `cli-identity.json`, is served, so the account stays listed to switch on again. Nor is its allowance read (`fetchSubscriptionUsage`, `loginUsageAt`), a saved ChatGPT sign-in renewed (`RenewLogins`), the agent's account switched (`NextLogin`), a window warmed (`keepWarm`), its model list fetched (`newDue`), a daily check-in made by the loop (`checkinNow` with `soon` false; a press still checks in), or a Codex reset about to run out read and spent (`SpendExpiringCodexResets`, #2226; `TestExpiringResetLeftAlone`). A Cursor switched off that was never asked who is signed in isn't listed until it is switched on. `TestLeftAloneRunsNoCLI` runs those paths with fake `claude`, `cursor-agent` and `devin` CLIs on PATH and checks none ran. Plugins' model lists (`KeepPluginsListed`) are asked of the plugin host all at once and aren't held back per provider.-- An Antigravity subscription offers the union of its On accounts' models (`antigravityPoolModels` in [`antigravity_pool.go`](../../internal/provider/antigravity_pool.go)), each account's own list kept beside it (`accountModels`, read by `Account.Lists` for routing). The lists are fetched at the first listing, a probe, a sync or a Refetch, and also at each account's quota reading, which asks `fetchAvailableModels` anyway: a reading whose models differ from the account's saved list saves it and merges the pooled list again from every On account's own (`noteAntigravityList`), so a model Google gives one account of several later (01huadalang on Discord: Gemini 4) is offered, routed to and given its bar without that account made preferred or probed. A switched-off account's reading changes nothing. `TestAntigravityQuotaReadingListsNewModels`.+- An Antigravity subscription offers the union of its On accounts' models (`antigravityPoolModels` in [`antigravity_pool.go`](../../internal/provider/antigravity_pool.go)), each account's own list kept beside it (`accountModels`, read by `Account.Lists` for routing). The lists are fetched at the first listing, a probe, a sync or a Refetch, and also at each account's quota reading, which asks `fetchAvailableModels` anyway: a reading whose models differ from the account's saved list saves it and merges the pooled list again from every On account's own (`noteAntigravityList`), so a model Google gives one account of several later (01huadalang on Discord: Gemini 4) is offered, routed to and given its bar without that account made preferred or probed. A switched-off account's reading changes nothing. `TestAntigravityQuotaReadingListsNewModels`. Each `fetchAvailableModels` names the account's paid and current tier first (`entitlement.userTier`, `askTiers`), then none; a tier Google answers 400 (a Google AI Pro account's g1-pro-tier, #1553) is left out of that account's lists and quota readings for `tierRefusedFor` (a day), and the refused request is no row of the request log.- A provider removed or switched off takes its models out of the catalog. [Agent wiring](agent-wiring.md)'s `Reseat` moves agents off them.- A preset marked `NoList` uses its preset model list instead of requesting `/models`, and ignores previously fetched lists, including their protocol and key restrictions, unless the user sets `ModelsURL` or chooses a region marked `Lists`. Each region can carry a different list. Volcengine Ark's Coding Plan and Agent Plan use separate preset lists. Both plans include their embedding model separately from agents' chat-model lists; Agent Plan additionally exposes its image- and video-generation models to Settings → Images; Ark itself refuses video generation on Small and Medium Agent Plans, which include it only in the Large and Max tiers. Models magpie does not yet serve (Agent Plan's speech models) are not advertised. Ark's pay-as-you-go region still fetches its own list. Coding's `/api/coding/v3/models` returns a general Ark catalog instead of the plan's model ids, while Agent's `/api/plan/v3/models` returns 404. [`presets.go`](../../internal/provider/presets.go) defines these choices; `List`, `fetch`, `live`, `planModels`, `PlanEmbeddings`, `PlanDrawers` and `PlanVideos` in [`models.go`](../../internal/provider/models.go) apply them when adding, refreshing and reading cached models. `TestVolcengineModelLists` checks that the plans make no list requests, ignore old cached lists and return their own preset models; pay-as-you-go and an explicit list URL still make requests.- A gateway key held to some accounts (#905) is held to those of the providers its list names: a provider it names no account of, the key uses as it always did. The key's menu says so on each account of such a provider ("Used: no … account is picked"), and its badge's tooltip that a key is kept off a provider by its models (#2077: unticking every Codex account left Codex's models served). The list keeps an account by its stable id — `logins.json`'s `id`, set once written and kept through renames; the agents that keep no logins (and plugins) are known by a hash of the account's name, so an account renamed there drops out of a key's list, holding it closer, never wider. Storing an id for every agent is a larger change, not this one's.diff --git a/internal/provider/antigravity_tier_test.go b/internal/provider/antigravity_tier_test.goindex 937744917..a4995b7d7 100644--- a/internal/provider/antigravity_tier_test.go+++ b/internal/provider/antigravity_tier_test.go@@ -265,3 +265,119 @@ func TestAntigravityProInvalidTierAsksWithoutOne(t *testing.T) {}}}++// ferock4669 on Discord: an Antigravity subscription's Requests page filled+// with "Model list" rows for /v1internal:fetchAvailableModels, each a 400.+// A Pro account's list is asked first with its paid tier named, which+// Google answers 400 INVALID_ARGUMENT (#1553), then without one, which+// lists its models. That first ask was a row of its own on every list, and+// was sent again on every list and quota reading. Now the refused tier is+// a step no row is written for, it isn't named again for tierRefusedFor,+// and a list that fails without one is still written down.+func TestAntigravityRefusedTierAskedOnceAndNoRow(t *testing.T) {+ const load = `{"currentTier":{"id":"free-tier","name":"Antigravity"},+ "paidTier":{"id":"g1-pro-tier","name":"Google AI Pro"},+ "cloudaicompanionProject":"aicode-consumers"}`+ const invalid = `{"error":{"code":400,"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT"}}`+ plain := 200+ f := &fakeGoogle{load: load, modelsFor: func(body map[string]any) (int, string) {+ if body["entitlement"] != nil {+ return 400, invalid+ }+ if plain != 200 {+ return plain, invalid+ }+ return 200, withClaude+ }}+ googleSandbox(t, f)+ captureLog(t)+ rows := probeRows(t)+ auth := googleAuth{AccessToken: "tok", RefreshToken: "rt-ferock", Expiry: time.Now().Add(time.Hour).UnixMilli()}+ if err := addGoogleLogin("antigravity", "[email protected]", "", auth); err != nil {+ t.Fatal(err)+ }+ p, _ := googleAccountOf("antigravity")+ for range 3 {+ if ms, err := p.Fetch(context.Background()); err != nil || len(ms) != 2 {+ t.Fatalf("models %v, %v", ms, err)+ }+ }+ // the account's quota reading asks the same list+ g := googleLogins("antigravity")[0].acct+ if q := g.quota(context.Background(), ""); q.Error != "" {+ t.Fatalf("quota: %s", q.Error)+ }+ f.mu.Lock()+ var named int+ for _, b := range f.fetches {+ if b["entitlement"] != nil {+ named+++ }+ }+ asked := len(f.fetches)+ f.mu.Unlock()+ if named != 1 || asked != 5 {+ t.Errorf("asked %d times, %d with the refused tier named; want 5 and 1", asked, named)+ }+ for _, r := range rows() {+ if r.Status == 400 {+ t.Errorf("a refused tier written down: %+v", r)+ }+ }++ // a day on, the tier is named again+ googleState.Lock()+ for k := range googleState.refused {+ googleState.refused[k] = time.Now().Add(-tierRefusedFor - time.Minute)+ }+ googleState.Unlock()+ f.mu.Lock()+ f.fetches = nil+ f.mu.Unlock()+ if _, err := p.Fetch(context.Background()); err != nil {+ t.Fatal(err)+ }+ f.mu.Lock()+ if len(f.fetches) != 2 || f.fetches[0]["entitlement"] == nil {+ t.Errorf("a day on, asked %v", f.fetches)+ }+ f.mu.Unlock()++ // the list refused without a tier too is written down, once+ f.mu.Lock()+ plain = 400+ f.mu.Unlock()+ before := len(rows())+ p.Fetch(context.Background())+ var failed []string+ for _, r := range rows()[before:] {+ if r.Status != 200 {+ failed = append(failed, fmt.Sprint(r.Status, " ", r.Kind, " ", r.Endpoint))+ }+ }+ if len(failed) != 1 || failed[0] != "400 model_list /daily/v1internal:fetchAvailableModels" {+ t.Errorf("rows of the failed list %v", failed)+ }+}++// A tier refused for a reason other than a 400 (Google down) is named+// again on the next list.+func TestAntigravityTierNotRestedForOtherFailures(t *testing.T) {+ f := &fakeGoogle{load: proLoad, modelsFor: func(body map[string]any) (int, string) {+ if body["entitlement"] != nil {+ return 503, `{"error":{"code":503,"message":"The service is currently unavailable.","status":"UNAVAILABLE"}}`+ }+ return 200, geminiOnly+ }}+ googleSandbox(t, f)+ captureLog(t)+ auth := googleAuth{AccessToken: "tok", RefreshToken: "rt-503", Expiry: time.Now().Add(time.Hour).UnixMilli()}+ addGoogleLogin("antigravity", "[email protected]", "", auth)+ antigravityModelIDs(t, "antigravity")+ antigravityModelIDs(t, "antigravity")+ f.mu.Lock()+ defer f.mu.Unlock()+ if len(f.fetches) != 6 { // g1-pro-tier, standard-tier, none; twice+ t.Errorf("asked %v", f.fetches)+ }+}diff --git a/internal/provider/google.go b/internal/provider/google.goindex c40e9842f..962e19868 100644--- a/internal/provider/google.go+++ b/internal/provider/google.go@@ -39,6 +39,7 @@ import ("github.com/yetone/magpie/internal/catalog""github.com/yetone/magpie/internal/edit"+ "github.com/yetone/magpie/internal/probelog")// CodeAssist is Google's Code Assist API, which magpie only speaks@@ -315,7 +316,66 @@ var googleState = struct {tokens map[string]googleAuth // by refresh tokenprojects map[string]googleProjectflags map[string]geminiFlags // by refresh token and project-}{tokens: map[string]googleAuth{}, projects: map[string]googleProject{}, flags: map[string]geminiFlags{}}+ // when Google last refused each tier named in an account's+ // fetchAvailableModels with a 400, by refresh token, project and tier+ // (tierRefusedFor)+ refused map[string]time.Time+}{tokens: map[string]googleAuth{}, projects: map[string]googleProject{}, flags: map[string]geminiFlags{}, refused: map[string]time.Time{}}++// tierRefusedFor is how long a tier Google answered an account's+// fetchAvailableModels 400 for is left out of its next ones. A Google AI+// Pro account gets 400 INVALID_ARGUMENT with g1-pro-tier named (#1553,+// AnxForever's log) and its list only from the request without one, so+// every list, start-up's, the hourly relist's, each quota reading's, sent+// Google that 400 first, and each list's was a 400 "Model list" row on the+// Requests page (ferock4669 on Discord). Asked again after a day, in case+// Google takes it by then; a tier the account newly has is a new key.+const tierRefusedFor = 24 * time.Hour++func tierKey(rt, project, tier string) string { return rt + "\x00" + project + "\x00" + tier }++// askTiers are the tiers to name in the account's next fetchAvailableModels,+// best first, then "" (none): its entitlements less those Google refused+// it within tierRefusedFor.+func (g googleAccount) askTiers(p googleProject) []string {+ googleState.Lock()+ defer googleState.Unlock()+ var out []string+ for _, t := range p.entitlements() {+ if at, ok := googleState.refused[tierKey(g.auth.RefreshToken, p.id, t)]; ok && time.Since(at) < tierRefusedFor {+ continue+ }+ out = append(out, t)+ }+ return append(out, "")+}++// tierRefused notes that Google refused the account's fetchAvailableModels+// with tier named.+func (g googleAccount) tierRefused(p googleProject, tier string) {+ googleState.Lock()+ googleState.refused[tierKey(g.auth.RefreshToken, p.id, tier)] = time.Now()+ googleState.Unlock()+}++// codeAssistError is Code Assist's answer to a call other than 200: its+// status, and what Google said (APIError).+type codeAssistError struct {+ status int+ msg string+}++func (e *codeAssistError) Error() string { return e.msg }++// codeAssistStatus is the status Code Assist answered err with, 0 for an+// error that isn't such an answer.+func codeAssistStatus(err error) int {+ var e *codeAssistError+ if errors.As(err, &e) {+ return e.status+ }+ return 0+}type googleProject struct {id, plan string@@ -458,7 +518,7 @@ func (g googleAccount) call(ctx context.Context, base, method string, body, outdefer res.Body.Close()rb, _ := io.ReadAll(io.LimitReader(res.Body, 4<<20))if res.StatusCode != http.StatusOK {- return fmt.Errorf("%s: %s", g.app.name, APIError(rb, res.Status))+ return &codeAssistError{status: res.StatusCode, msg: fmt.Sprintf("%s: %s", g.app.name, APIError(rb, res.Status))}}if out == nil {return nil@@ -945,21 +1005,32 @@ func (g googleAccount) modelInfo(ctx context.Context) ([]googleModelInfo, error)} `json:"agentModelSorts"`}// with the account's tier named, as Antigravity asks; a tier Google- // won't take from it is left out, down to none+ // won't take from it is left out, down to none, and not named+ // again for a while (tierRefusedFor)sent := ""- tiers := append(p.entitlements(), "")+ tiers := g.askTiers(p)for i, t := range tiers {body := map[string]any{"project": p.id}+ ask := ctxif t != "" {body["entitlement"] = map[string]any{"userTier": t}+ // a step towards the list, which the request after it+ // fetches: not a row of the request log, where a+ // refused tier was a 400 "Model list" beside every list+ // that was fetched (ferock4669); the last request, with+ // none named, is written down as before+ ask = probelog.Taken(ctx)}- if err = g.call(ctx, g.app.base, "fetchAvailableModels", body, &res, nil); err == nil {+ if err = g.call(ask, g.app.base, "fetchAvailableModels", body, &res, nil); err == nil {sent = tbreak}if ctx.Err() != nil {return nil, err}+ if t != "" && codeAssistStatus(err) == http.StatusBadRequest {+ g.tierRefused(p, t)+ }switch {case t == "":log.Printf("antigravity %s: fetchAvailableModels at %s (project %q, no entitlement): %v", g.user, g.app.base, p.id, err)diff --git a/internal/provider/google_test.go b/internal/provider/google_test.goindex 591f24643..81ed5fdb5 100644--- a/internal/provider/google_test.go+++ b/internal/provider/google_test.go@@ -112,6 +112,7 @@ func resetGoogleState() {googleState.tokens = map[string]googleAuth{}googleState.projects = map[string]googleProject{}googleState.flags = map[string]geminiFlags{}+ googleState.refused = map[string]time.Time{}googleState.Unlock()antigravityVer.Lock()antigravityVer.v, antigravityVer.at = "", time.Time{}