sessions, usage: Antigravity's gemini-4-argon-d is gemini-4-argon, not a second unpriced model

oioio's Antigravity database names gemini-4-argon's generator
"gemini-4-argon-d". agAppModel took only "-n" off a gemini-* id (Google's
gemini-3.8-flash-n, b2432754e), so the Usage panel showed gemini-4-argon
twice and the -d one had no price. usage.GeminiServing had the same
"-n"-only rule, so the gateway's log would call gemini-4-argon answered
as gemini-4-argon-d a swap.

Both now ask sessions.GeminiDeployment: a gemini-* id with one lowercase
letter after its last hyphen is that model's deployment. Google's own
ids never end in a lone letter (-lite, -nano, -pro, -001, -exp), and
other makers' ids (gpt-5-d, claude-sonnet-4-5-n) stay as written. The
rule is by shape, not by the catalog: a catalog lookup at parse time
would freeze a "-d" into the kept parses whenever models.json wasn't
there yet. antigravity's parseVersions and callParseVersions go to 1,
so parses and call shards kept with gemini-4-argon-d are read again on
update; nothing else is reread.

Run (mote, at this tree):
- go test -tags nogui ./internal/sessions ./internal/usage: ok.
- go vet, GOOS=windows go vet, GOOS=linux go vet -tags nogui on both
  packages; gofmt -l prints nothing.
- Broken by hand: GeminiDeployment put back to the old -n-only rule.
  TestAntigravityAppDeploymentName failed ("gemini-4-argon-d":
  "gemini-4-argon-d", want "gemini-4-argon", fields 19, 21, 22) and
  TestSwappedGeminiServingName failed ("gemini-4-argon answered as
  gemini-4-argon-d is the model asked for"); both pass with the change.
- Full suite runs after the push (go test -tags nogui -timeout 45m ./...).

Not tried: oioio's own database (only the model name was posted), and
a real gateway request that Google answers as gemini-4-argon-d.

Reported-by: oioio (Discord)
This commit is contained in:
yetone
2026-11-07 00:22:13 +08:00
parent 54dc257f10
commit 2f660ca86b
6 changed files with 76 additions and 14 deletions
+22 -5
View File
@@ -235,11 +235,7 @@ func agAppModel(b []byte) string {
})
for _, m := range named {
if m != "" && len(m) <= 200 {
// Google names the deployment serving gemini-3.8-flash
// "gemini-3.8-flash-n", an id no request can ask for (the
// owner's real Antigravity account, b2432754e): it is that
// model, at its price
if base, ok := strings.CutSuffix(m, "-n"); ok && strings.HasPrefix(base, "gemini-") {
if base, ok := GeminiDeployment(m); ok {
return base
}
return m
@@ -248,6 +244,27 @@ func agAppModel(b []byte) string {
return ""
}
// GeminiDeployment is the Gemini model a Google deployment's name stands
// for, and whether m is such a name: a gemini-* id with one letter after
// its last hyphen. Google names the deployment serving gemini-3.8-flash
// "gemini-3.8-flash-n" (the owner's real Antigravity account, b2432754e)
// and the one serving gemini-4-argon "gemini-4-argon-d" (oioio's
// Antigravity database, 11-06): ids no request can ask for, which are that
// model, at its price. No Gemini model's own id ends in a lone letter
// (-lite, -nano, -pro, -001 and -exp are longer), and other makers' ids
// are left as written.
func GeminiDeployment(m string) (string, bool) {
i := strings.LastIndexByte(m, '-')
if i < 0 || len(m)-i != 2 || m[i+1] < 'a' || m[i+1] > 'z' {
return m, false
}
base := m[:i]
if !strings.HasPrefix(base, "gemini-") || len(base) == len("gemini-") {
return m, false
}
return base, true
}
// pbTime is a google.protobuf.Timestamp, zero when it has no seconds.
func pbTime(b []byte) time.Time {
var sec, nanos uint64
+31
View File
@@ -2,6 +2,7 @@ package sessions
import (
"database/sql"
"encoding/binary"
"encoding/hex"
"os"
"path/filepath"
@@ -184,3 +185,33 @@ func TestAntigravityAppCutRow(t *testing.T) {
t.Error("a row cut inside its model call read as a call")
}
}
// oioio's Antigravity database (#help, 11-06) names gemini-4-argon's
// generator "gemini-4-argon-d": Google's deployment of that model, as
// gemini-3.8-flash-n is 3.8 Flash's. It counts as gemini-4-argon, so Usage
// shows one model at its price. A lone letter after another maker's id, or
// a Gemini id whose last word is longer, stays as written.
func TestAntigravityAppDeploymentName(t *testing.T) {
gen := func(field int, m string) []byte {
inner := append(binary.AppendUvarint(nil, uint64(field)<<3|2), byte(len(m)))
inner = append(inner, m...)
return append([]byte{1<<3 | 2, byte(len(inner))}, inner...)
}
for in, want := range map[string]string{
"gemini-4-argon-d": "gemini-4-argon",
"gemini-3.8-flash-n": "gemini-3.8-flash",
"gemini-3.8-flash-lite": "gemini-3.8-flash-lite",
"gemini-3.8-flash-nano": "gemini-3.8-flash-nano",
"gemini-4-argon": "gemini-4-argon",
"gemini-d": "gemini-d",
"gpt-5-d": "gpt-5-d",
"claude-sonnet-4-5-n": "claude-sonnet-4-5-n",
"gemini-4-argon-D": "gemini-4-argon-D",
} {
for _, field := range []int{19, 21, 22} {
if got := agAppModel(gen(field, in)); got != want {
t.Errorf("field %d %q: %q, want %q", field, in, got, want)
}
}
}
}
+3 -1
View File
@@ -64,7 +64,9 @@ const callCacheVersion = "calls-v15"
// parent's (codex_fork.go, zcDB.copied).
// codex 2, zcode 2: only the copies are; a fork's own calls are its own
// (zcode 1 left out every call of a session holding one copy).
var callParseVersions = map[string]int{"cindy": 1, "codex": 3, "zcode": 2}
// antigravity 1: a Gemini deployment's name with any one letter after it
// (gemini-4-argon-d) is its model's (GeminiDeployment).
var callParseVersions = map[string]int{"antigravity": 1, "cindy": 1, "codex": 3, "zcode": 2}
// CallCacheVersion is callCacheVersion and callParseVersions, for a cache
// of what is made of the calls (usage's requests-v1.bin and heatmap): a
+4 -1
View File
@@ -1162,7 +1162,10 @@ const cacheVersion = 29
//
// dsh 1: the ids of the replies its own requests got (ResponseIDs), for
// the routes that carry no session id and an opening a fork copies.
var parseVersions = map[string]int{"codex": 3, "zcode": 1, "dsh": 1}
//
// antigravity 1: a Gemini deployment's name with any one letter after it
// (gemini-4-argon-d) is its model's (GeminiDeployment), not -n alone.
var parseVersions = map[string]int{"codex": 3, "zcode": 1, "dsh": 1, "antigravity": 1}
type cacheFile struct {
Version int `json:"version"`
+10 -7
View File
@@ -8,6 +8,7 @@ import (
"unicode"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/sessions"
)
// Which model answered: a vendor may serve a request with another model
@@ -270,15 +271,17 @@ var grokBuild = regexp.MustCompile(`^grok-[0-9][0-9.]*(-build)(?:-|$)`)
// GeminiServing reports whether served is the name Google's backend gives
// the deployment that serves the Gemini model sent: the model's own name
// with "-n" after it. Antigravity answers every level of gemini-3.8-flash
// (-low, -medium, -high) with modelVersion gemini-3.8-flash-n, an id no
// request can ask for (404) and fetchAvailableModels never lists, so it is
// that model, not another one swapped in (dumplings on Discord). It holds
// for Gemini models only: gpt-5 answered as gpt-5-n is still a swap, as is
// gemini-3.8-flash answered as gemini-3.8-flash-lite or gemini-3.7-flash-n.
// with one letter after it (sessions.GeminiDeployment). Antigravity
// answers every level of gemini-3.8-flash (-low, -medium, -high) with
// modelVersion gemini-3.8-flash-n, an id no request can ask for (404) and
// fetchAvailableModels never lists, so it is that model, not another one
// swapped in (dumplings on Discord); gemini-4-argon's is gemini-4-argon-d
// (oioio on Discord). It holds for Gemini models only: gpt-5 answered as
// gpt-5-n is still a swap, as is gemini-3.8-flash answered as
// gemini-3.8-flash-lite or gemini-3.7-flash-n.
func GeminiServing(sent, served string) bool {
a := squash(bareModel(provider.EffortFamily(bareModel(sent))))
b, ok := strings.CutSuffix(bareModel(served), "-n")
b, ok := sessions.GeminiDeployment(bareModel(served))
return ok && strings.HasPrefix(a, "gemini") && squash(b) == a
}
+6
View File
@@ -23,6 +23,9 @@ func TestSwappedGeminiServingName(t *testing.T) {
{"gemini-3.8-flash-medium", "gemini-3.8-flash-n"},
{"gemini-3.8-flash-high", "gemini-3.8-flash-n"},
{"gemini-3.8-flash", "models/gemini-3.8-flash-n"},
// oioio on Discord (11-06): Antigravity's name for gemini-4-argon
{"gemini-4-argon", "gemini-4-argon-d"},
{"antigravity/gemini-4-argon-high", "gemini-4-argon-d"},
} {
if Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is the model asked for", c[0], c[1])
@@ -38,6 +41,9 @@ func TestSwappedGeminiServingName(t *testing.T) {
{"gemini-3.8-flash", "gemini-3.7-flash-n"},
{"gemini-3.8-flash", "gemini-3.8-flash-nano"},
{"gemini-3.8-flash-high", "gemini-3.8-flash-low"},
{"gpt-5", "gpt-5-d"},
{"gemini-4-argon", "gemini-3.8-flash-d"},
{"gemini-4-argon", "gemini-4-argon-dx"},
} {
if !Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is another model", c[0], c[1])