agent: Codex's own models are drawn by their names in its picker, as every other list's are (nb5p on Discord)
nb5p's screenshot of the Agents page: Codex's model picker drew each of
Codex's own models by its slug (gpt-6-astra · 经 magpie · GPT-6-Astra in
grey). Every other list in magpie, magpie's catalog included, draws the
model's name. options() gives a model its name only as the grey note;
Codex's own were the one list built straight from it, and on magpie API or
with magpie Codex's provider the label was set to the slug outright.
codexNamed gives each of Codex's own models its name (the display_name
Codex lists it by) as the label, for the picker of this machine's Codex
and of a WSL distro's (wsl.go, both of its lists), and the magpie-API
branch no longer writes the slug over it. The value is the slug, as
before: what Codex is set to and sends is unchanged (codex/gpt-… on
magpie API, gpt-… otherwise). The Codex app's own picker was not the
cause: magpie's catalog file already gives it the names.
Test: TestCodexOwnModelsNamedInPicker (beside the ChatGPT sign-in, and
magpie the provider) checks each own model is labelled by its name and
valued by its slug. TestCodexAPIKeepsMagpieOnOwnModel and
TestCodexProviderOwnModelSaysItsPath now check the name too.
Run on mote at this tree: go test ./internal/agent ok (176s); go vet for
darwin, linux -tags nogui and windows on internal/agent; go build ./...;
gofmt -l clean.
Broken by hand: codexNamed left without the label, all three tests red
("gpt-6-astra is offered as "" ... want it named "GPT-6-Astra"").
Not tried: the GUI suite (no GUI file changed; the picker already draws
a label when there is one), a real Codex in WSL.
This commit is contained in:
+18
-3
@@ -1419,9 +1419,9 @@ func codexIn(at place) *Agent {
|
||||
return own
|
||||
}
|
||||
if p != "" && p != magpieID && !isCCSwitchMirror(p) {
|
||||
own = say(group(p, options(catalog.Codex(), "")))
|
||||
own = say(group(p, codexNamed(catalog.Codex())))
|
||||
} else {
|
||||
own = codexInMagpie(say(group("OpenAI", options(ownCodex(), ""))))
|
||||
own = codexInMagpie(say(group("OpenAI", codexNamed(ownCodex()))))
|
||||
// with magpie Codex's provider (magpie API, or a magpie model
|
||||
// picked with no ChatGPT sign-in beside it), Codex's own models
|
||||
// are reached through magpie on a ChatGPT account there: picked
|
||||
@@ -1431,7 +1431,7 @@ func codexIn(at place) *Agent {
|
||||
if api() || asProvider() {
|
||||
for i, o := range own {
|
||||
if id := codexOwnViaMagpie(o.Value); id != "" {
|
||||
own[i].Label, own[i].Value, own[i].Ref = o.Value, id, id
|
||||
own[i].Value, own[i].Ref = id, id
|
||||
} else if !api() {
|
||||
own[i].Via, own[i].Direct = false, "OpenAI"
|
||||
}
|
||||
@@ -2391,6 +2391,21 @@ func ownCodex() []catalog.Model {
|
||||
return out
|
||||
}
|
||||
|
||||
// codexNamed is Codex's own models as its picker offers them, each under
|
||||
// its name, as every model of magpie's is (viaMagpie): the picker drew
|
||||
// the slug (gpt-6-astra) in front and the name after it in grey, the
|
||||
// only list in magpie that did (nb5p on Discord). The value stays the
|
||||
// slug Codex is set to.
|
||||
func codexNamed(ms []catalog.Model) []Option {
|
||||
out := options(ms, "")
|
||||
for i, m := range ms {
|
||||
if m.Name != "" {
|
||||
out[i].Label = m.Name
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// codexInMagpie marks Served those of Codex's own models that magpie's list
|
||||
// shows Codex on a ChatGPT account of the user's (codex/gpt-5.5): its
|
||||
// pickers leave out magpie's codex/… as only a hop (codexViaMagpieFor), so these
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestCodexAPIKeepsMagpieOnOwnModel(t *testing.T) {
|
||||
// the picker offers Codex's own as they are set, under their names
|
||||
found := false
|
||||
for _, o := range model.Options(nil) {
|
||||
if o.Group == "OpenAI" && o.Value == "codex/gpt-b" && o.Label == "gpt-b" {
|
||||
if o.Group == "OpenAI" && o.Value == "codex/gpt-b" && o.Label == "B" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// nb5p on Discord: Codex's picker drew each of Codex's own models by its
|
||||
// slug (gpt-6-astra · via magpie · GPT-6-Astra), the only list in magpie
|
||||
// that did; every other one is drawn by the model's name. Each is drawn
|
||||
// by its name now, and picked as the slug Codex is set to.
|
||||
func TestCodexOwnModelsNamedInPicker(t *testing.T) {
|
||||
cache := []byte(`{"models":[
|
||||
{"slug":"gpt-6-astra","display_name":"GPT-6-Astra","priority":1},
|
||||
{"slug":"gpt-6.1-terra","display_name":"GPT-6.1 Terra","priority":2}]}`)
|
||||
want := map[string]string{"gpt-6-astra": "GPT-6-Astra", "gpt-6.1-terra": "GPT-6.1 Terra"}
|
||||
for _, c := range []struct{ name, auth string }{
|
||||
{"beside the ChatGPT sign-in", `{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`},
|
||||
{"magpie the provider", `{"OPENAI_API_KEY":"sk-x"}`},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
home, _ := codexHome(t, c.auth, "")
|
||||
os.WriteFile(filepath.Join(home, ".codex", "models_cache.json"), cache, 0o644)
|
||||
if err := codex(home).Fields[0].Set("fake/m1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := map[string]string{}
|
||||
for _, o := range codex(home).Fields[0].Options(nil) {
|
||||
if o.Group == "OpenAI" {
|
||||
got[o.Value] = o.Label
|
||||
}
|
||||
}
|
||||
for slug, name := range want {
|
||||
if l, ok := got[slug]; !ok || l != name {
|
||||
t.Errorf("%s is offered as %q (in the list: %v), want it named %q: %v", slug, l, ok, name, got)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ func TestCodexProviderOwnModelSaysItsPath(t *testing.T) {
|
||||
ownOf := func(a *Agent) []Option {
|
||||
var out []Option
|
||||
for _, o := range a.Fields[0].Options(nil) {
|
||||
if o.Group == "OpenAI" && (o.Label == "gpt-a" || o.Value == "gpt-a") {
|
||||
if o.Group == "OpenAI" && (o.Value == "gpt-a" || o.Value == "codex/gpt-a") {
|
||||
out = append(out, o)
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func TestCodexProviderOwnModelSaysItsPath(t *testing.T) {
|
||||
t.Fatalf("magpie isn't Codex's provider:\n%s", cfg)
|
||||
}
|
||||
own := ownOf(codex(home))
|
||||
if len(own) != 1 || own[0].Value != "codex/gpt-a" || !own[0].Via {
|
||||
if len(own) != 1 || own[0].Value != "codex/gpt-a" || own[0].Label != "A" || !own[0].Via {
|
||||
t.Fatalf("Codex's own gpt-a, served by magpie: %+v", own)
|
||||
}
|
||||
if err := codex(home).Fields[0].Set(own[0].Value); err != nil {
|
||||
|
||||
@@ -441,9 +441,9 @@ var wslKinds = []wslKind{
|
||||
// over several accounts magpie routes, so they are
|
||||
// offered via magpie too, as on a live Codex (#1603)
|
||||
if codexFailover() {
|
||||
return withVia(group("OpenAI", options(ownCodex(), "")), "codex", "")
|
||||
return withVia(group("OpenAI", codexNamed(ownCodex())), "codex", "")
|
||||
}
|
||||
own := codexInMagpie(group("OpenAI", options(ownCodex(), "")))
|
||||
own := codexInMagpie(group("OpenAI", codexNamed(ownCodex())))
|
||||
return append(own, codexViaMagpieFor(own)...)
|
||||
}
|
||||
case "effort":
|
||||
|
||||
Reference in New Issue
Block a user