search: a Codex account searches with its cheap model, not the flagship its list starts with
lucy_85908 (Discord #feedback, v0.1.2682) ran a third-party model in Codex
and found each web search magpie ran for it logged as Anthropic -> Responses
on gpt-6.1-sol, 10,532 tokens in, through the Codex account. The searcher
was picked right (a Codex account searches for models that can't), but its
model was not. smallCands ranks a provider's models by small-tier name
(haiku/mini/flash), then m.Price. A subscription's list has no prices, and
GPT-6 has no mini, so every Codex model ranked equal and the first listed
(gpt-6.1-sol) was used for every search and every AutoVision description.
Now a model with no price on the list is ranked by its list price
(Provider.ListPrice, the price the Usage page counts it at). "luna" is a
small-tier word beside mini, for when no catalog is loaded yet (the same
rule warmPick has used since #604). codex-auto-review is left out: it is
free only for the reviews it runs. A searcher or model named in Settings
-> Web search still wins (namedSearcher is unchanged). The fix is in the
pool AutoVision shares, so a Codex account's image descriptions now go to
the cheap model too.
Not changed: Codex's web_search = "cached" (external_web_access:false)
is still dropped when magpie searches for a model that can't; filed as
#5018.
Run at the pushed head (mote-run):
- go test ./internal/gateway -run TestCodexSearchesWithItsCheapModel
(new), and with Search|Searcher|Vision|Small|TestRankSmall|TestAutoVision:
ok.
- go test -timeout 45m ./internal/gateway at the pushed head (rebased on
06944e065): ok (714s). ./internal/gui (before the rebase, which touched
no gui file): ok but TestMainWindowCorners/macOS_26_SDK, red alone too,
open as #3949 (mote is macOS 27).
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok; gofmt -l
clean.
Broken by hand: with search.go as on main, the test is red
("searcher = codex/gpt-6.1-sol with no catalog, want codex/gpt-6-luna").
With the list-price fill alone turned off, it is red at the priced
no-luna list (gpt-6.1-sol, want gpt-6-sol).
Not tried: a real search on a Codex account with gpt-6-luna. Its
models.json entry has web_search_tool_type text_and_image and
use_responses_lite, the same as gpt-6.1-sol.
This commit is contained in:
@@ -602,6 +602,21 @@ func smallCands(p provider.Provider, keep func(catalog.Model) bool) []smallCand
|
||||
continue
|
||||
}
|
||||
}
|
||||
if m.ID == provider.CodexAutoReview {
|
||||
// Codex's reviewer, priced free for the reviews it runs, not
|
||||
// a model to ask anything else of
|
||||
continue
|
||||
}
|
||||
if m.Price == nil {
|
||||
// a subscription's list carries no prices: Codex's starts
|
||||
// with its flagship, gpt-6.1-sol, which every search and
|
||||
// every image was asked of while gpt-6-luna sat below it
|
||||
// (lucy_85908 on Discord). Its list price, as the Usage
|
||||
// page counts it, says which is the cheap one
|
||||
if pr, ok := p.ListPrice(m.ID); ok {
|
||||
m.Price = &pr
|
||||
}
|
||||
}
|
||||
ms = append(ms, m)
|
||||
}
|
||||
return rankSmall(ms)
|
||||
@@ -628,6 +643,10 @@ func keptSmallCands(p provider.Provider, kind string, keep func(catalog.Model) b
|
||||
return smallKept.get(k, func() []smallCand { return smallCands(p, keep) })
|
||||
}
|
||||
|
||||
// smallWords name a vendor's small tier: GPT-6's is Luna, the list has
|
||||
// no mini (#604).
|
||||
var smallWords = []string{"haiku", "mini", "flash", "luna"}
|
||||
|
||||
// rankSmall is ms in the order smallModel picks them, each one's pick of
|
||||
// those after it: on a router, a model of the big vendors first; then a
|
||||
// small one; then the cheaper; then the one listed first.
|
||||
@@ -648,7 +667,7 @@ func rankSmall(ms []catalog.Model) []smallCand {
|
||||
}
|
||||
rs[i] = ranked{smallCand{m.ID, cost},
|
||||
ok && !slices.Contains([]string{"anthropic", "openai", "google", "x-ai"}, v),
|
||||
!strings.Contains(l, "haiku") && !strings.Contains(l, "mini") && !strings.Contains(l, "flash")}
|
||||
!slices.ContainsFunc(smallWords, func(w string) bool { return strings.Contains(l, w) })}
|
||||
}
|
||||
slices.SortStableFunc(rs, func(a, b ranked) int {
|
||||
if c := falseFirst(a.router, b.router); c != 0 {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// A Codex account searches for a model that can't with its cheap model,
|
||||
// not the flagship its list starts with: lucy_85908 (Discord, v0.1.2682)
|
||||
// saw every search for a third-party model in Codex go to gpt-6.1-sol,
|
||||
// 10,532 tokens in, on the Codex account's allowance. The list carries no
|
||||
// prices, so the first was picked; the list price models.dev gives the
|
||||
// models says gpt-6-luna is the cheap one. Without a catalog at all, a
|
||||
// luna is GPT-6's small tier, as a mini is. A model the user names in
|
||||
// Settings is still the one asked.
|
||||
func TestCodexSearchesWithItsCheapModel(t *testing.T) {
|
||||
codexSignedIn(t)
|
||||
list := []catalog.Model{{ID: "gpt-6.1-sol"}, {ID: "gpt-6-astra"}, {ID: "gpt-6-sol"}, {ID: "gpt-6-luna"}, {ID: "gpt-5.6-sol"}, {ID: provider.CodexAutoReview}}
|
||||
if err := catalog.SaveLive("codex", provider.CodexBase, list); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pick := func() (string, string) {
|
||||
p, m, ok := searcher()
|
||||
if !ok {
|
||||
t.Fatal("no searcher with a Codex account signed in")
|
||||
}
|
||||
return p.ID, m
|
||||
}
|
||||
|
||||
// no catalog: by the name
|
||||
catalog.Reset()
|
||||
if id, m := pick(); id != "codex" || m != "gpt-6-luna" {
|
||||
t.Fatalf("searcher = %s/%s with no catalog, want codex/gpt-6-luna", id, m)
|
||||
}
|
||||
|
||||
// priced: the cheapest, whatever its name
|
||||
writeCatalog(t, `{"openai":{"id":"openai","models":{
|
||||
"gpt-6.1-sol":{"id":"gpt-6.1-sol","cost":{"input":5,"output":30}},
|
||||
"gpt-6-astra":{"id":"gpt-6-astra","cost":{"input":10,"output":50}},
|
||||
"gpt-6-sol":{"id":"gpt-6-sol","cost":{"input":2.5,"output":15}},
|
||||
"gpt-6-luna":{"id":"gpt-6-luna","cost":{"input":0.25,"output":2}},
|
||||
"gpt-5.6-sol":{"id":"gpt-5.6-sol","cost":{"input":1.25,"output":10}},
|
||||
"gpt-5.6-luna":{"id":"gpt-5.6-luna","cost":{"input":0.1,"output":0.4}}}}}`)
|
||||
if id, m := pick(); id != "codex" || m != "gpt-6-luna" {
|
||||
t.Fatalf("searcher = %s/%s priced, want codex/gpt-6-luna", id, m)
|
||||
}
|
||||
// a list with no small tier: the cheapest by its price, not the first
|
||||
if err := catalog.SaveLive("codex", provider.CodexBase, list[:3]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if id, m := pick(); id != "codex" || m != "gpt-6-sol" {
|
||||
t.Fatalf("searcher = %s/%s priced with no luna, want the cheapest, codex/gpt-6-sol", id, m)
|
||||
}
|
||||
|
||||
// the user's own pick wins
|
||||
st := settings.Load()
|
||||
st.Searcher = "codex/gpt-6.1-sol"
|
||||
if err := settings.Save(st); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if id, m := pick(); id != "codex" || m != "gpt-6.1-sol" {
|
||||
t.Fatalf("searcher = %s/%s, want the one Settings names, codex/gpt-6.1-sol", id, m)
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ func TestRankSmallIsPickSmall(t *testing.T) {
|
||||
}
|
||||
small := slices.DeleteFunc(slices.Clone(ms), func(m catalog.Model) bool {
|
||||
l := strings.ReplaceAll(strings.ToLower(m.ID), "gemini", "")
|
||||
return !strings.Contains(l, "haiku") && !strings.Contains(l, "mini") && !strings.Contains(l, "flash")
|
||||
return !strings.Contains(l, "haiku") && !strings.Contains(l, "mini") && !strings.Contains(l, "flash") && !strings.Contains(l, "luna")
|
||||
})
|
||||
if id := cheapest(small); id != "" {
|
||||
return id
|
||||
@@ -285,7 +285,7 @@ func TestRankSmallIsPickSmall(t *testing.T) {
|
||||
}
|
||||
r := rand.New(rand.NewPCG(1, 2))
|
||||
vendors := []string{"", "anthropic/", "openai/", "google/", "x-ai/", "meta/", "qwen/"}
|
||||
names := []string{"claude-haiku-5", "gpt-6-mini", "gemini-3-flash", "gemini-3-pro", "big", "o9", "llama"}
|
||||
names := []string{"claude-haiku-5", "gpt-6-mini", "gemini-3-flash", "gemini-3-pro", "gpt-6-luna", "big", "o9", "llama"}
|
||||
for range 2000 {
|
||||
var ms []catalog.Model
|
||||
for i := range r.IntN(8) + 1 {
|
||||
|
||||
Reference in New Issue
Block a user