Files
magpie/internal/usage/served_grok_test.go
T
yetone 18d87fc51a usage: grok-4.7 answered as grok-4.7-build is the model asked for, not a swap (#1455, cybershape)
xAI answers a request for grok-4.7 with model grok-4.7-build (the
reporter's requests log; two relays' notes say the same for grok-4.6 ->
grok-4.6-build). Its own list (SuperGrok's, cached 2026-10-02) offers
grok-4.7 and grok-4.7-build-fast and no grok-4.7-build to ask for, so the
-build name is xAI's name for the build serving the model.

GrokServing reads past "-build" after a Grok model's version and joins
GeminiServing under ServingName, which Swapped, a kept requests-log row and
a kept route's try all use. Only names starting with grok count, and only
the same variant: grok-4.7 answered by grok-4.7-build-fast, grok-4.6-build
or grok-4.7-mini is still a swap, as is gpt-5 answered as gpt-5-build.

Run:
- TestSwappedGrokServingName, TestKeptRowGrokServingNameNotSwapped,
  TestRouteKeptGrokServingNameNotSwapped (new). With ServingName reduced to
  GeminiServing the usage tests fail ("grok-4.7 answered as grok-4.7-build
  is the model asked for", "serving name true, fast variant true").
- go test -tags nogui ./internal/agent ./internal/usage ./internal/gateway
  ok; gofmt -l clean; go vet for darwin, linux, windows clean.
- Not tried against xAI itself: no request was sent from the owner's Grok
  account; the served name is the reporter's.
2026-10-10 18:10:18 +08:00

50 lines
1.7 KiB
Go

package usage
import "testing"
// xAI answers a request for grok-4.7 as grok-4.7-build (#1455, cybershape's
// requests log): its name for the build serving the model, not another
// model. The fast variant, another version, another Grok model and another
// vendor's "-build" are still swaps.
func TestSwappedGrokServingName(t *testing.T) {
for _, c := range [][2]string{
{"grok-4.7", "grok-4.7-build"},
{"grok/grok-4.7", "grok-4.7-build"},
{"Grok-4.7", "grok-4.7-build"},
{"grok-4.6", "grok-4.6-build"},
{"grok-4.7-build-fast", "grok-4.7-build-fast"},
{"grok-4.7-fast", "grok-4.7-build-fast"},
} {
if Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is the model asked for", c[0], c[1])
}
}
for _, c := range [][2]string{
{"grok-4.7", "grok-4.7-build-fast"},
{"grok-4.7-build-fast", "grok-4.7-build"},
{"grok-4.7-fast", "grok-4.7-build"},
{"grok-4.7", "grok-4.6-build"},
{"grok-4.7", "grok-4.7-mini"},
{"grok-4.7", "grok-4.7-builder"},
{"gpt-5", "gpt-5-build"},
{"claude-sonnet-4-5", "claude-sonnet-4-5-build"},
} {
if !Swapped(c[0], c[1]) {
t.Errorf("%s answered as %s is another model", c[0], c[1])
}
}
}
// A row kept marked swapped before is read back as not swapped when xAI
// named the build serving it; a real swap stays one.
func TestKeptRowGrokServingNameNotSwapped(t *testing.T) {
c := &rowChunk{}
c.add(Row{Record: Record{Model: "grok-4.7", Served: "grok-4.7-build"}, Swapped: true}, "", 0, false)
c.add(Row{Record: Record{Model: "grok-4.7", Served: "grok-4.7-build-fast"}, Swapped: true}, "", 1, false)
for _, chunk := range []*rowChunk{c, c.pack().unpack()} {
if chunk.row(0).Swapped || !chunk.row(1).Swapped {
t.Fatalf("serving name %v, fast variant %v", chunk.row(0).Swapped, chunk.row(1).Swapped)
}
}
}