A third-party model in Codex (DeepSeek, MiniMax, ...) had its web searches made by asking gpt-6-luna on the Codex account to search through /responses. A ChatGPT account now searches by the ChatGPT backend's /alpha/search, the request Codex's web.run sends by itself with no model turn (codex-rs ext/web-search): one search_query, the account's small model in "model", allowed_callers ["direct"], and external_web_access from the client's web_search tool (#5018: Codex's "cached" sends false; live by default). The output's pages are read by their 80-dash rule and ref_id; the private-use citation marks are dropped. Measured on a real Plus account (2026-11-03, token not refreshed): 151 alpha/search calls left the 5h window at the same percent, ~1.5-2.2s each; 51 searches by gpt-6-luna took 0% -> 1% of it, 7-15s each, ~9-17k tokens in (40 of them: 414,585 in, 10,313 out). The backend answered the same for any "model" (deepseek-v4 too) and any max_output_tokens. - Automatic (and searchInTurn) picks the backend's search for a ChatGPT account; Settings > Web search offers "<id>/@search" as "its web search". "<id>" and "<id>/<model>" saved before still search by that model, so a user's pick is unchanged. - When the backend's search fails, the account's small model searches (codexSearchBy). - Codex web.run's own search for a non-ChatGPT model (alphaSearchHere) and a Responses request's web_search tool pass their mode on. Run at this head (rebased on origin/main), on mote: - go test ./internal/gateway/... ./internal/gui/ ./internal/agent/ -timeout 45m: gateway and agent ok; gui red only on TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote). After the rebase: the gateway's search tests again ok. - searcher-pick.test.cjs: 22/22, chromium + webkit, en/zh (+ the label is in zh, zh-TW, ja, de). - gofmt -l clean; GOOS=linux go vet gateway, provider; GOOS=windows go vet gateway, gui. - Whole GUI suite on the Linux box (wsl-run): not finished when pushed; its reds so far are WebKit pages this doesn't touch (add-provider, API key palette, Routing headers, click-scroll, Codex resets). Broken by hand, each red: the Automatic switch (TestCodexSearchesWith ItsCheapModel, TestChatGPTAccountSearchesByItsWebSearch), the responses.go mode (TestResponsesWebSearchModeKept), the body's mode, the fallback, and the picker option (searcher-pick). Not tried: a real search through magpie in a sandbox (the request shape was tried by hand against the backend); an account out of its allowance (does alpha/search still answer?); the model fallback still searches live when Codex asked cached. Suggested by lucy_85908 on Discord.
70 lines
2.8 KiB
Go
70 lines
2.8 KiB
Go
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)
|
|
}
|
|
// magpie's own pick searches by the backend's search (search_codex.go);
|
|
// the cheap model is what it falls back on, and what "codex" names
|
|
pick := func() (string, string) {
|
|
p, m, ok := searcher()
|
|
if !ok || m != codexSearchModel {
|
|
t.Fatalf("searcher = %s/%s %v, want codex by its web search", p.ID, m, ok)
|
|
}
|
|
return p.ID, searcherModel(p)
|
|
}
|
|
|
|
// 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 p, m, _ := searcher(); p.ID != "codex" || m != "gpt-6.1-sol" {
|
|
t.Fatalf("searcher = %s/%s, want the one Settings names, codex/gpt-6.1-sol", p.ID, m)
|
|
}
|
|
}
|