ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.
What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
public one). Every old form is still accepted as input forever:
provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
gateway (validateModel), keys, stats, affinity and usage, so both ids
route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
(allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
exists, found groups are listed by their old id (AutoRefsOn) and
auto/<x> means that provider's model. Documented in
docs/subsystems/gateway-routing.md.
Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).
Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.
Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
gateway, whose failures were the tests' expected ids (updated here)
and two regressions now fixed (bare ids; desktop models hiding groups
by prefix). Every failing test passes on rerun. Load average was
~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
agent failed four tests that still expected the old ids
(TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
Reseat bug above. After the fix, go test -count=1 -timeout 120m
./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
the routing files pass, except routing-bodies, routing-model-rest,
routing-keys-fold and routing-request-metrics, which fail the same with
33dbdcc52's JS.
Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.
Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
203 lines
7.6 KiB
Go
203 lines
7.6 KiB
Go
package codexcat
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// Codex's own models, routed through magpie, keep what Codex knows of them
|
|
// — image input, context window, tools — under magpie's id; a third-party
|
|
// model gets the generic entry.
|
|
func TestCodexCatalogKeepsOwnEntries(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
os.MkdirAll(filepath.Join(home, ".codex"), 0o755)
|
|
os.WriteFile(filepath.Join(home, ".codex", "models_cache.json"), []byte(`{"models":[
|
|
{"slug":"gpt-5.5","display_name":"GPT-5.5","priority":3,"visibility":"list","input_modalities":["text","image"],
|
|
"context_window":272000,"upgrade":{"model":"gpt-6"},"availability_nux":{"message":"new"}}]}`), 0o644)
|
|
|
|
var got struct {
|
|
Models []map[string]any `json:"models"`
|
|
}
|
|
if err := json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "deepseek/deepseek-chat", Name: "deepseek-chat · DeepSeek"},
|
|
{ID: "codex/gpt-5.5", Name: "GPT-5.5 · Codex", Efforts: []string{"low", "high"}},
|
|
}), &got); err != nil || len(got.Models) != 2 {
|
|
t.Fatalf("%v %v", err, got)
|
|
}
|
|
third, own := got.Models[0], got.Models[1]
|
|
if third["slug"] != "deepseek/deepseek-chat" || third["base_instructions"] != Prompt || len(third["input_modalities"].([]any)) != 1 {
|
|
t.Errorf("third-party entry: %v", third)
|
|
}
|
|
if own["slug"] != "codex/gpt-5.5" || own["display_name"] != "GPT-5.5 · Codex" || own["priority"] != float64(2) ||
|
|
own["context_window"] != float64(272000) || len(own["input_modalities"].([]any)) != 2 {
|
|
t.Errorf("own entry: %v", own)
|
|
}
|
|
if own["base_instructions"] != Prompt {
|
|
t.Error("own entry without base_instructions")
|
|
}
|
|
if _, ok := own["upgrade"]; ok {
|
|
t.Error("upgrade prompt kept")
|
|
}
|
|
if _, ok := own["availability_nux"]; ok {
|
|
t.Error("start-up notice kept")
|
|
}
|
|
}
|
|
|
|
// A model that takes images says so, and Codex lets images be attached.
|
|
func TestCodexCatalogImages(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
var got struct {
|
|
Models []struct {
|
|
Modalities []string `json:"input_modalities"`
|
|
} `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "a/text", Name: "text"},
|
|
{ID: "a/vision", Name: "vision", Images: true},
|
|
}), &got)
|
|
if len(got.Models) != 2 || len(got.Models[0].Modalities) != 1 || len(got.Models[1].Modalities) != 2 || got.Models[1].Modalities[1] != "image" {
|
|
t.Errorf("%+v", got.Models)
|
|
}
|
|
}
|
|
|
|
// A model magpie describes has Codex search its MCP tools rather than send
|
|
// every one in each request (#258), with its prompt, context window, and
|
|
// neither code mode nor Responses Lite. A window above the working window
|
|
// is told as that, the whole one as its max, unless settings.FullContext.
|
|
func TestCodexCatalogToolSearch(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(os.Getenv("HOME"), ".config"))
|
|
var got struct {
|
|
Models []map[string]any `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "group/auto-gemini-3-8-flash", Name: "auto", Context: 996147, Efforts: []string{"low", "medium", "high"}, Images: true},
|
|
}), &got)
|
|
if len(got.Models) != 1 {
|
|
t.Fatalf("%v", got)
|
|
}
|
|
e := got.Models[0]
|
|
if e["supports_search_tool"] != true || e["base_instructions"] != Prompt || e["context_window"] != float64(settings.WorkingWindow) || e["max_context_window"] != float64(996147) {
|
|
t.Errorf("entry: %v", e)
|
|
}
|
|
if err := settings.Save(settings.Settings{FullContext: true}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var full struct {
|
|
Models []map[string]any `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "group/auto-gemini-3-8-flash", Name: "auto", Context: 996147},
|
|
}), &full)
|
|
if e := full.Models[0]; e["context_window"] != float64(996147) || e["max_context_window"] != nil {
|
|
t.Errorf("full context: %v", e)
|
|
}
|
|
for _, off := range []string{"tool_mode", "use_responses_lite", "multi_agent_version", "model_messages"} {
|
|
if v, ok := e[off]; ok {
|
|
t.Errorf("%s = %v", off, v)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Codex 0.147 refuses a catalog whose entries don't say whether a model
|
|
// takes parallel tool calls (#298), and later Codex ask for them anyway.
|
|
func TestCodexCatalogParallelToolCalls(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
var got struct {
|
|
Models []map[string]any `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{{ID: "fake/m1", Name: "m1"}, {ID: "group/auto", Name: "auto"}}), &got)
|
|
if len(got.Models) != 2 {
|
|
t.Fatalf("%v", got)
|
|
}
|
|
for _, e := range got.Models {
|
|
if e["supports_parallel_tool_calls"] != true {
|
|
t.Errorf("%v: supports_parallel_tool_calls = %v", e["slug"], e["supports_parallel_tool_calls"])
|
|
}
|
|
}
|
|
}
|
|
|
|
// Fast mode is offered for a ChatGPT account's GPT models, with Codex's own
|
|
// tiers when it lists the model, and for no one else's.
|
|
func TestCodexCatalogServiceTiers(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
os.MkdirAll(filepath.Join(home, ".codex"), 0o755)
|
|
os.WriteFile(filepath.Join(home, ".codex", "models_cache.json"), []byte(`{"models":[
|
|
{"slug":"gpt-6-astra","display_name":"GPT-6 Astra","service_tiers":[{"id":"priority","name":"Fast","description":"2x speed, increased usage"}]}]}`), 0o644)
|
|
|
|
var got struct {
|
|
Models []struct {
|
|
Slug string `json:"slug"`
|
|
Tiers []struct {
|
|
ID string `json:"id"`
|
|
Description string `json:"description"`
|
|
} `json:"service_tiers"`
|
|
} `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "codex/gpt-6-astra", Name: "GPT-6 Astra · Codex"},
|
|
{ID: "codex/gpt-6-sol", Name: "GPT-6 Sol · Codex"},
|
|
{ID: "copilot/gpt-6-sol", Name: "GPT-6 Sol · Copilot"},
|
|
{ID: "openrouter/openai/gpt-6-sol", Name: "GPT-6 Sol · OpenRouter"},
|
|
}), &got)
|
|
if len(got.Models) != 4 {
|
|
t.Fatalf("%+v", got.Models)
|
|
}
|
|
if ts := got.Models[0].Tiers; len(ts) != 1 || ts[0].ID != "priority" || ts[0].Description != "2x speed, increased usage" {
|
|
t.Errorf("own entry tiers: %+v", ts)
|
|
}
|
|
if ts := got.Models[1].Tiers; len(ts) != 1 || ts[0].ID != "priority" {
|
|
t.Errorf("uncached account model tiers: %+v", ts)
|
|
}
|
|
for _, m := range got.Models[2:] {
|
|
if m.Tiers == nil || len(m.Tiers) != 0 {
|
|
t.Errorf("%s offers tiers: %+v", m.Slug, m.Tiers)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Codex turns a pasted image away for a model without "image" itself, so
|
|
// /model says such a model is text-only and where that is changed, and the
|
|
// entry still reads as magpie's (KimYx0207 on X).
|
|
func TestCodexCatalogSaysTextOnly(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
var got struct {
|
|
Models []struct {
|
|
Slug string `json:"slug"`
|
|
Description string `json:"description"`
|
|
Modalities []string `json:"input_modalities"`
|
|
} `json:"models"`
|
|
}
|
|
json.Unmarshal(Catalog([]catalog.Model{
|
|
{ID: "probe/text", Name: "Text"},
|
|
{ID: "probe/sees", Name: "Sees", Images: true},
|
|
{ID: "group/words", Name: "Words"},
|
|
{ID: "auto/found", Name: "Found"}, // a group magpie found, as it is listed
|
|
}), &got)
|
|
if len(got.Models) != 4 {
|
|
t.Fatalf("%+v", got.Models)
|
|
}
|
|
text, sees, group, found := got.Models[0], got.Models[1], got.Models[2], got.Models[3]
|
|
if !strings.Contains(text.Description, "text only") || !strings.Contains(text.Description, "Names & levels") || !catalog.MagpieAdded("", text.Slug, text.Description) {
|
|
t.Errorf("text-only model: %q", text.Description)
|
|
}
|
|
if sees.Description != "Sees via magpie" || group.Description != "Words via magpie" || found.Description != "Found via magpie" {
|
|
t.Errorf("a model that sees, a group and a found one: %q, %q, %q", sees.Description, group.Description, found.Description)
|
|
}
|
|
}
|