usage: an Antigravity call at a level answered under its model's own name is no swap (#462: gemini-3.8-flash at medium marked Swapped, answered by gemini-3.8-flash) — on an Antigravity account a call at an effort goes out as that level's id (AntigravitySentID: gemini-3.8-flash-medium), and Cloud Code's reply names the family in modelVersion (gemini-3.8-flash), so Swapped compared gemini-3.8-flash-medium with gemini-3.8-flash and the request list and the Routing view tagged the model as swapped for itself. A sent id whose last word is an effort word (provider.EffortFamily: low, medium, high, xhigh, minimal, extra-low, extra-high) now matches a reply naming the id without it; a reply naming another level, or another model, is still a swap. TestLedgerAntigravityReplyNamingTheFamilyIsNoSwap fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestClaudeRunEndsWhenTheClientLeaves, a load flake, passes alone).

This commit is contained in:
yetone
2026-10-02 02:24:48 +08:00
parent 4db035682a
commit febbf29b0f
3 changed files with 64 additions and 2 deletions
+8
View File
@@ -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) {
+50
View File
@@ -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")
}
}
+6 -2
View File
@@ -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