From febbf29b0fccd6aefd1244ee1b65971b1f0b2e9e Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 2 Oct 2026 02:07:58 +0800 Subject: [PATCH] =?UTF-8?q?usage:=20an=20Antigravity=20call=20at=20a=20lev?= =?UTF-8?q?el=20answered=20under=20its=20model's=20own=20name=20is=20no=20?= =?UTF-8?q?swap=20(#462:=20gemini-3.8-flash=20at=20medium=20marked=20Swapp?= =?UTF-8?q?ed,=20answered=20by=20gemini-3.8-flash)=20=E2=80=94=20on=20an?= =?UTF-8?q?=20Antigravity=20account=20a=20call=20at=20an=20effort=20goes?= =?UTF-8?q?=20out=20as=20that=20level's=20id=20(AntigravitySentID:=20gemin?= =?UTF-8?q?i-3.8-flash-medium),=20and=20Cloud=20Code's=20reply=20names=20t?= =?UTF-8?q?he=20family=20in=20modelVersion=20(gemini-3.8-flash),=20so=20Sw?= =?UTF-8?q?apped=20compared=20gemini-3.8-flash-medium=20with=20gemini-3.8-?= =?UTF-8?q?flash=20and=20the=20request=20list=20and=20the=20Routing=20view?= =?UTF-8?q?=20tagged=20the=20model=20as=20swapped=20for=20itself.=20A=20se?= =?UTF-8?q?nt=20id=20whose=20last=20word=20is=20an=20effort=20word=20(prov?= =?UTF-8?q?ider.EffortFamily:=20low,=20medium,=20high,=20xhigh,=20minimal,?= =?UTF-8?q?=20extra-low,=20extra-high)=20now=20matches=20a=20reply=20namin?= =?UTF-8?q?g=20the=20id=20without=20it;=20a=20reply=20naming=20another=20l?= =?UTF-8?q?evel,=20or=20another=20model,=20is=20still=20a=20swap.=20TestLe?= =?UTF-8?q?dgerAntigravityReplyNamingTheFamilyIsNoSwap=20fails=20without?= =?UTF-8?q?=20the=20change.=20go=20vet,=20go=20build=20-tags=20nogui=20(da?= =?UTF-8?q?rwin,=20GOOS=3Dlinux),=20GOOS=3Dwindows=20go=20build,=20go=20te?= =?UTF-8?q?st=20-tags=20nogui=20./...=20pass=20(TestClaudeRunEndsWhenTheCl?= =?UTF-8?q?ientLeaves,=20a=20load=20flake,=20passes=20alone).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/provider/antigravity_models.go | 8 ++++ internal/usage/ledger_test.go | 50 +++++++++++++++++++++++++ internal/usage/served.go | 8 +++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/internal/provider/antigravity_models.go b/internal/provider/antigravity_models.go index 08f49dbf1..13d1e3c0e 100644 --- a/internal/provider/antigravity_models.go +++ b/internal/provider/antigravity_models.go @@ -39,6 +39,14 @@ func splitAntigravityID(id string) (family, effort string) { return id, "" } +// EffortFamily is the model an id with an effort word after it is a level +// of ("gemini-3.8-flash-medium" is gemini-3.8-flash), and the id itself +// when it has none. +func EffortFamily(id string) string { + f, _ := splitAntigravityID(id) + return f +} + // antigravityNameEffort is the level a name's last words in brackets say // ("Gemini 3.7 Flash (High)" is high), and the name without them. func antigravityNameEffort(name string) (string, string) { diff --git a/internal/usage/ledger_test.go b/internal/usage/ledger_test.go index 2ca3bd240..b18d8222d 100644 --- a/internal/usage/ledger_test.go +++ b/internal/usage/ledger_test.go @@ -605,3 +605,53 @@ func TestLedgerJudgesAnAntigravityCallByTheVariantItWentOutUnder(t *testing.T) { } } } + +// Antigravity answers a call that went out as a level of a model with the +// model's own name in modelVersion (#462: gemini-3.8-flash at medium went +// out as gemini-3.8-flash-medium and the reply named gemini-3.8-flash), +// which is the model asked for at the level asked for, not another one +// swapped in; a reply naming another level still is. +func TestLedgerAntigravityReplyNamingTheFamilyIsNoSwap(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) + t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) + var raw []catalog.Model + for _, id := range []string{"flash-9-low", "flash-9-medium", "flash-9-high", "flash-9-extra-low"} { + raw = append(raw, catalog.Model{ID: id}) + } + if err := catalog.SaveLive("antigravity", "", raw); err != nil { + t.Fatal(err) + } + catalog.Reset() + t.Cleanup(catalog.Reset) + os.MkdirAll(filepath.Dir(Path()), 0o755) + now := time.Now() + for i, c := range []struct{ effort, served string }{ + {"medium", "flash-9"}, {"minimal", "flash-9"}, {"", "models/flash-9"}, {"low", "flash-9-low"}, + {"medium", "flash-9-high"}, // another level answered: a swap + } { + Append(Record{Time: now.Add(time.Duration(i) * time.Minute), Provider: "antigravity", + Host: "antigravity.example", Model: "flash-9", Effort: c.effort, + Served: c.served, Input: 10, Output: 1, Status: 200}) + } + rows, _, _ := Ledger(All, Filter{}) + page := QueryPage(All, Filter{}, 0, 100) + for _, got := range [][]Row{rows, page.Rows} { + if len(got) != 5 { + t.Fatalf("rows %d: %+v", len(got), got) + } + if !got[0].Swapped { + t.Errorf("another level answering is a swap: %+v", got[0]) + } + for _, row := range got[1:] { + if row.Swapped { + t.Errorf("flash-9 at %q answered as %q is the model asked for: %+v", row.Effort, row.Served, row) + } + } + } + if !Swapped("flash-9-medium", "flash-8") || !Swapped("flash-9-medium", "flash-9-high") { + t.Error("another model or level is still a swap") + } +} diff --git a/internal/usage/served.go b/internal/usage/served.go index 6b591f791..aeab1e377 100644 --- a/internal/usage/served.go +++ b/internal/usage/served.go @@ -42,12 +42,16 @@ func bareModel(m string) string { } // Swapped reports whether served is another model than sent: not the same -// name, however dated, pinned or prefixed. A vendor's "auto" (Copilot's, +// name, however dated, pinned or prefixed. A call that went out as one level +// of a model (an Antigravity account's gemini-3.8-flash-medium) answered +// under the model's own name is that model at that level: Antigravity's +// reply names the family, not the variant (#462). Another level is another +// model, as AntigravitySentID has it. A vendor's "auto" (Copilot's, // Cursor's) asked it to pick, so whichever answers wasn't swapped in, nor // is the member another magpie's routing group sent it to (GroupRouted). func Swapped(sent, served string) bool { a, b := bareModel(sent), bareModel(served) - return a != "" && b != "" && a != b && a != "auto" && !GroupRouted(sent, served) + return a != "" && b != "" && a != b && a != "auto" && bareModel(provider.EffortFamily(a)) != b && !GroupRouted(sent, served) } // GroupRouted reports whether sent is a routing group of another magpie