provider: Antigravity's Orchestrator ids are priced as the Gemini model each is
guyng35955 on X: an Antigravity local session's calls under gemini-pro-orchestrator-argon, gemini-pro-orchestrator-carbon and the worker gemini-flash-worker-agy showed tokens and cache but cost "—". They are Orchestrator mode's role ids, which no catalog prices. pricedNamesTo now reads them as the model Antigravity's docs name (https://antigravity.google/docs/models/): Orchestrator (Argon) plans with Gemini 4 Argon, Orchestrator (Carbon) with Gemini 4 Carbon, and Gemini 4 Hydrogen does the implementation, so the worker is priced as gemini-4-hydrogen. gemini-pro-orchestrator (Carbon's id before Argon came, per the Antigravity Context Window Monitor extension 1.17.1's table) is Carbon too. Only these four ids, under a route prefix or an effort suffix; a name only like one stays unpriced. Every cost reads through this one place: the Sessions list and overview (sessions.priceOf -> PricedName), the usage ledger, its totals and per-agent view (Pricer -> ListPrice / MakerPrice). Prices are taken as rows are read, so sessions recorded before the update are priced once it is installed; nothing is re-parsed. Google publishes no rate for the role ids themselves; they are priced at the named model's models.dev list price. Run (mote, at this tree): - the three new tests red on origin/main's models.go (every role id unpriced), green with the fix; red again with argon mapped to carbon by hand - go test -tags nogui ./internal/provider ./internal/sessions ./internal/usage: sessions and usage ok; provider ok but for TestRemoveListedAccountLeavesHiddenNamesake (ZCode account removal, not reached by this change), which passes alone -count=3 with and without this change; filed as #6764 with its output - go vet, GOOS=linux and GOOS=windows go vet of those packages; gofmt -l clean Not tried: the reporter's own Antigravity database, or a real Orchestrator mode account (this Mac has no Antigravity app and the account isn't offered Argon). No GUI change. Reported-by: guyng35955 on X
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
)
|
||||
|
||||
// writeAntigravityRolesCatalog is models.dev's three Gemini 4 models and
|
||||
// another vendor's, in a sandbox HOME.
|
||||
func writeAntigravityRolesCatalog(t *testing.T) {
|
||||
t.Helper()
|
||||
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"))
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
// models.dev's prices on 2026-11-15
|
||||
os.WriteFile(catalog.CachePath(), []byte(`{
|
||||
"google":{"id":"google","models":{
|
||||
"gemini-4-argon":{"id":"gemini-4-argon","cost":{"input":2,"output":10,"cache_read":0.1}},
|
||||
"gemini-4-carbon":{"id":"gemini-4-carbon","cost":{"input":2.5,"output":12,"cache_read":0.25}},
|
||||
"gemini-4-hydrogen":{"id":"gemini-4-hydrogen","cost":{"input":1.5,"output":7.5,"cache_read":0.075}}}},
|
||||
"openai":{"id":"openai","models":{
|
||||
"gpt-5.1-codex":{"id":"gpt-5.1-codex","cost":{"input":1.25,"output":10}}}}}`), 0o644)
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
}
|
||||
|
||||
// Antigravity's Orchestrator mode records its calls under role ids, not
|
||||
// a model's: gemini-pro-orchestrator-argon, gemini-pro-orchestrator-carbon
|
||||
// and the worker gemini-flash-worker-agy showed tokens with no cost
|
||||
// (guyng35955 on X). Each is priced as the Gemini model Antigravity's
|
||||
// docs say it is, whichever provider's call names it; a name only like
|
||||
// one of them, and every other model, keeps its own price or none.
|
||||
func TestAntigravityOrchestratorIDsPricedAsTheirModel(t *testing.T) {
|
||||
t.Cleanup(AntigravityBuiltinForTest())
|
||||
writeAntigravityRolesCatalog(t)
|
||||
// carbon is given its own price here, apart from argon's, so a role
|
||||
// priced as the other model shows
|
||||
want := map[string]catalog.Price{
|
||||
"gemini-4-argon": {Input: 2, Output: 10, CacheRead: 0.1},
|
||||
"gemini-4-carbon": {Input: 2.5, Output: 12, CacheRead: 0.25},
|
||||
"gemini-4-hydrogen": {Input: 1.5, Output: 7.5, CacheRead: 0.075},
|
||||
}
|
||||
ag := Provider{ID: "antigravity", Name: "Antigravity"}
|
||||
other := Provider{ID: "some-relay", Name: "Relay"}
|
||||
for id, model := range map[string]string{
|
||||
// the reporter's three
|
||||
"gemini-pro-orchestrator-argon": "gemini-4-argon",
|
||||
"gemini-pro-orchestrator-carbon": "gemini-4-carbon",
|
||||
"gemini-flash-worker-agy": "gemini-4-hydrogen",
|
||||
// Orchestrator (Carbon) before Argon came
|
||||
"gemini-pro-orchestrator": "gemini-4-carbon",
|
||||
// spelled as a route or an effort names them
|
||||
"Gemini-Pro-Orchestrator-Argon": "gemini-4-argon",
|
||||
"google/gemini-pro-orchestrator-argon": "gemini-4-argon",
|
||||
"gemini-pro-orchestrator-carbon-high": "gemini-4-carbon",
|
||||
"gemini-flash-worker-agy-extra-high": "gemini-4-hydrogen",
|
||||
} {
|
||||
w := want[model]
|
||||
for name, price := range map[string]func(string) (catalog.Price, bool){
|
||||
"MakerPrice": MakerPrice, "antigravity ListPrice": ag.ListPrice, "relay ListPrice": other.ListPrice} {
|
||||
if pr, ok := price(id); !ok || !samePrice(pr, w) {
|
||||
t.Errorf("%s(%q) = %+v, %v; want %s's %+v", name, id, pr, ok, model, w)
|
||||
}
|
||||
}
|
||||
if got := PricedName(id); got != model {
|
||||
t.Errorf("PricedName(%q) = %q, want %q", id, got, model)
|
||||
}
|
||||
}
|
||||
// the models themselves, and another vendor's, keep their own price
|
||||
for id, w := range map[string]catalog.Price{
|
||||
"gemini-4-argon": want["gemini-4-argon"], "gemini-4-carbon": want["gemini-4-carbon"],
|
||||
"gpt-5.1-codex": {Input: 1.25, Output: 10},
|
||||
} {
|
||||
if pr, ok := MakerPrice(id); !ok || !samePrice(pr, w) {
|
||||
t.Errorf("MakerPrice(%q) = %+v, %v; want %+v", id, pr, ok, w)
|
||||
}
|
||||
}
|
||||
// a name only like a role is no role
|
||||
for _, id := range []string{"gemini-pro-orchestrator-neon", "gemini-flash-worker", "gemini-pro-orchestrator-argon-fast",
|
||||
"my-gemini-pro-orchestrator-argon", "gemini-flash-worker-agy-ultra", "orchestrator", "gpt-5.1-codex-orchestrator"} {
|
||||
if pr, ok := MakerPrice(id); ok {
|
||||
t.Errorf("MakerPrice(%q) = %+v; want unpriced", id, pr)
|
||||
}
|
||||
if pr, ok := other.ListPrice(id); ok {
|
||||
t.Errorf("relay ListPrice(%q) = %+v; want unpriced", id, pr)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3244,6 +3244,8 @@ var modelWindow = lazyre.New(`^([^@]+)@[0-9]+[km]$`)
|
||||
// grok-4.7-mini, grok-4.7-fast); a Cursor account's fast ids are priced at
|
||||
// Cursor's own fast rate (Provider.cursorFastPrice), and a Grok account's
|
||||
// grok-4.7-build-fast at twice grok-4.7's (Provider.grokFastPrice).
|
||||
// Antigravity's Orchestrator ids are priced as the Gemini model each one
|
||||
// is (antigravityRoles).
|
||||
func pricedNames(model string) []string { return pricedNamesTo(nil, model) }
|
||||
|
||||
// pricedNamesTo is pricedNames appended to dst.
|
||||
@@ -3270,9 +3272,54 @@ func pricedNamesTo(dst []string, model string) []string {
|
||||
if base, ok := effortBase(l); ok {
|
||||
out = append(out, base)
|
||||
}
|
||||
if m, ok := antigravityRole(l); ok {
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// antigravityRoles are the ids Antigravity's Orchestrator mode records its
|
||||
// calls under, by the Gemini model each one is. Antigravity's docs
|
||||
// (https://antigravity.google/docs/models/, read 2026-11-15): "Orchestrator
|
||||
// (Carbon) always plans with Gemini 4 Carbon, and Orchestrator (Argon)
|
||||
// always plans with Gemini 4 Argon", and "the fast, lightweight Gemini 4
|
||||
// Hydrogen does the implementation work". The ids are the app's own
|
||||
// (guyng35955 on X: Usage showed gemini-pro-orchestrator-argon,
|
||||
// gemini-pro-orchestrator-carbon and the worker gemini-flash-worker-agy
|
||||
// with no cost). gemini-pro-orchestrator is Orchestrator (Carbon)'s id
|
||||
// before Argon's came (MODEL_PLACEHOLDER_M667 in the Antigravity Context
|
||||
// Window Monitor extension 1.17.1, beside M681 for -argon and the shared
|
||||
// worker M669). Only these ids: no other name is read as one of them.
|
||||
var antigravityRoles = map[string]string{
|
||||
"gemini-pro-orchestrator": "gemini-4-carbon",
|
||||
"gemini-pro-orchestrator-carbon": "gemini-4-carbon",
|
||||
"gemini-pro-orchestrator-argon": "gemini-4-argon",
|
||||
"gemini-flash-worker-agy": "gemini-4-hydrogen",
|
||||
}
|
||||
|
||||
// antigravityRole is the Gemini model the lower-cased id l is the
|
||||
// Orchestrator mode role of (antigravityRoles), under a google/ or other
|
||||
// route's prefix too, and at an effort (-high).
|
||||
func antigravityRole(l string) (string, bool) {
|
||||
if !strings.Contains(l, "orchestrator") && !strings.Contains(l, "worker-agy") {
|
||||
return "", false // every model of every provider's list is priced on each poll
|
||||
}
|
||||
l = l[strings.LastIndexByte(l, '/')+1:]
|
||||
if m, ok := antigravityRoles[l]; ok {
|
||||
return m, true
|
||||
}
|
||||
if i := strings.LastIndexByte(l, '-'); i > 0 {
|
||||
switch l[i+1:] {
|
||||
case "minimal", "low", "medium", "high", "xhigh":
|
||||
base := strings.TrimSuffix(l[:i], "-extra")
|
||||
if m, ok := antigravityRoles[base]; ok {
|
||||
return m, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// mythosFable is the Fable of a Mythos id's version (claude-mythos-5.2 ->
|
||||
// claude-fable-5.2), the price of a Mythos nothing prices
|
||||
// (shangyuan0818 on X): Anthropic gives Mythos 5.1 Fable 5.1's per-token
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package sessions
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// The Sessions list and its overview price an Antigravity local session's
|
||||
// Orchestrator role ids (guyng35955 on X) as the Gemini model each is.
|
||||
func TestPriceOfAntigravityOrchestratorRoles(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"))
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
os.WriteFile(catalog.CachePath(), []byte(`{"google":{"id":"google","models":{
|
||||
"gemini-4-argon":{"id":"gemini-4-argon","cost":{"input":2,"output":10,"cache_read":0.1}},
|
||||
"gemini-4-carbon":{"id":"gemini-4-carbon","cost":{"input":2.5,"output":12,"cache_read":0.25}},
|
||||
"gemini-4-hydrogen":{"id":"gemini-4-hydrogen","cost":{"input":1.5,"output":7.5,"cache_read":0.075}}}}}`), 0o644)
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
for m, in := range map[string]float64{
|
||||
"gemini-pro-orchestrator-argon": 2, "gemini-pro-orchestrator-carbon": 2.5, "gemini-flash-worker-agy": 1.5,
|
||||
} {
|
||||
if pr, ok := priceOf(settings.Load(), m); !ok || pr.Input != in {
|
||||
t.Errorf("priceOf(%q) = %+v, %v; want input $%v", m, pr, ok, in)
|
||||
}
|
||||
}
|
||||
if pr, ok := priceOf(settings.Load(), "gemini-pro-orchestrator-neon"); ok {
|
||||
t.Errorf("priceOf(gemini-pro-orchestrator-neon) = %+v; want unpriced", pr)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package usage
|
||||
|
||||
import (
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/sessions"
|
||||
)
|
||||
|
||||
// Antigravity local-session calls recorded under its Orchestrator role
|
||||
// ids (guyng35955 on X: tokens and cache shown, cost "—") are priced in the
|
||||
// ledger's rows, its total and the agent's own view as the Gemini model
|
||||
// each id is. The price is taken as the rows are read, so calls recorded
|
||||
// before are priced too.
|
||||
func TestAntigravityOrchestratorCallsPriced(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"))
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
os.WriteFile(catalog.CachePath(), []byte(`{"google":{"id":"google","models":{
|
||||
"gemini-4-argon":{"id":"gemini-4-argon","cost":{"input":2,"output":10,"cache_read":0.1}},
|
||||
"gemini-4-carbon":{"id":"gemini-4-carbon","cost":{"input":2.5,"output":12,"cache_read":0.25}},
|
||||
"gemini-4-hydrogen":{"id":"gemini-4-hydrogen","cost":{"input":1.5,"output":7.5,"cache_read":0.075}}}}}`), 0o644)
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
|
||||
now := holdClock(t, time.Date(2026, 11, 14, 12, 0, 0, 0, time.Local))
|
||||
tok := sessions.Tokens{Input: 100000, Output: 20000, CacheRead: 400000}
|
||||
old := LogCalls
|
||||
LogCalls = func(time.Time) []sessions.Call {
|
||||
return []sessions.Call{
|
||||
{Time: now.Add(-time.Hour), Agent: "antigravity", Session: "a1", Model: "gemini-pro-orchestrator-argon", Tokens: tok},
|
||||
{Time: now.Add(-2 * time.Hour), Agent: "antigravity", Session: "a2", Model: "gemini-pro-orchestrator-carbon", Tokens: tok},
|
||||
{Time: now.Add(-3 * time.Hour), Agent: "antigravity", Session: "a2", Model: "gemini-flash-worker-agy", Tokens: tok},
|
||||
}
|
||||
}
|
||||
t.Cleanup(func() { LogCalls = old })
|
||||
|
||||
cost := func(in, out, cr float64) float64 { return (100000*in + 20000*out + 400000*cr) / 1e6 }
|
||||
want := map[string]float64{
|
||||
"gemini-pro-orchestrator-argon": cost(2, 10, 0.1),
|
||||
"gemini-pro-orchestrator-carbon": cost(2.5, 12, 0.25),
|
||||
"gemini-flash-worker-agy": cost(1.5, 7.5, 0.075),
|
||||
}
|
||||
near := func(a, b float64) bool { return math.Abs(a-b) < 1e-9 }
|
||||
rows, total, _ := Ledger(Month, Filter{})
|
||||
if len(rows) != 3 {
|
||||
t.Fatalf("rows %d", len(rows))
|
||||
}
|
||||
var sum float64
|
||||
for _, r := range rows {
|
||||
if !r.Priced || !near(r.Cost, want[r.Model]) {
|
||||
t.Errorf("%s: priced %v cost %v, want %v", r.Model, r.Priced, r.Cost, want[r.Model])
|
||||
}
|
||||
sum += want[r.Model]
|
||||
}
|
||||
if total.Unpriced != 0 || !near(total.Cost, sum) {
|
||||
t.Errorf("total: cost %v unpriced %d, want %v and 0", total.Cost, total.Unpriced, sum)
|
||||
}
|
||||
// the agent's own view
|
||||
_, agent, _ := Ledger(Month, Filter{Agent: "antigravity"})
|
||||
if agent.Unpriced != 0 || !near(agent.Cost, sum) {
|
||||
t.Errorf("antigravity: cost %v unpriced %d, want %v and 0", agent.Cost, agent.Unpriced, sum)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user