What changed: the beside wiring of a Codex takeover took the top-level model_provider down silently whenever a magpie model was picked beside the ChatGPT sign-in — a provider of the user's (CC Switch's custom, an older takeover's) went with it, and every Codex thread saved with that provider stopped resuming (modelProviderMismatch: Codex falls back to its built-in openai, the threads name the provider they were started on, #4347). The wiring now steps beside only from a provider magpie puts back itself (its own, none, CC Switch's mirror of OpenAI, as Join already has it); over a provider of the user's the takeover names magpie instead and keeps the user's spelling in the stash, for Unwire to put back, as any takeover does. A reset leaves the line where the user put it too: it takes magpie's keys out, not theirs. Run: go test -tags nogui -run 'TestCodexTakeoverKeepsUserProvider|TestCodexResetKeepsUserProvider' ./internal/agent/ (both fail on the parent, pass here); go test -tags nogui ./internal/agent/ passes. Generated-by: GLM-5.3-Flash (ZCode)
52 lines
2.2 KiB
Go
52 lines
2.2 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A Codex of the user's own provider (CC Switch's custom, an older
|
|
// takeover's): model_provider at the top and its table. Picking a magpie
|
|
// model beside the ChatGPT sign-in took the line down silently, and every
|
|
// thread saved with the user's provider stopped resuming
|
|
// (modelProviderMismatch, #4347). magpie goes by the provider instead,
|
|
// the user's spelling kept in the stash, and stepping out puts it back.
|
|
func TestCodexTakeoverKeepsUserProvider(t *testing.T) {
|
|
home, read := codexHome(t, chatGPTAuth,
|
|
"model = \"gpt-5.5\"\nmodel_provider = \"custom\"\n\n[model_providers.custom]\nname = \"Custom\"\nbase_url = \"http://127.0.0.1:9/v1\"\nwire_api = \"responses\"\n")
|
|
cx := codex(home)
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cfg := read()
|
|
if !strings.Contains(cfg, `model_provider = "magpie"`) || !strings.Contains(cfg, `model = "fake/m1"`) ||
|
|
!strings.Contains(cfg, "[model_providers.custom]") || !strings.Contains(cfg, "[model_providers.magpie]") {
|
|
t.Fatalf("a magpie model over the user's provider:\n%s", cfg)
|
|
}
|
|
// and stepping out puts the user's provider back
|
|
if err := cx.Disconnect(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg = read(); !strings.Contains(cfg, `model_provider = "custom"`) || strings.Contains(cfg, "openai_base_url") {
|
|
t.Fatalf("disconnected, the user's provider not put back:\n%s", cfg)
|
|
}
|
|
}
|
|
|
|
// A reset takes magpie's keys out, not the user's: a provider of the
|
|
// user's at the top stays, and Codex goes on resuming the threads it
|
|
// saved with (#4347).
|
|
func TestCodexResetKeepsUserProvider(t *testing.T) {
|
|
home, read := codexHome(t, "",
|
|
"model = \"fake/m1\"\nmodel_provider = \"custom\"\nmodel_catalog_json = \"/x/list.json\"\n\n[model_providers.custom]\nname = \"Custom\"\nbase_url = \"http://127.0.0.1:9/v1\"\nwire_api = \"responses\"\n")
|
|
cx := codex(home)
|
|
if err := cx.Fields[0].Set(""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cfg := read()
|
|
if !strings.Contains(cfg, `model_provider = "custom"`) || !strings.Contains(cfg, "[model_providers.custom]") ||
|
|
strings.Contains(cfg, "model_catalog_json") || strings.Contains(cfg, `[model = "fake/m1"]`) {
|
|
t.Fatalf("reset over the user's provider:\n%s", cfg)
|
|
}
|
|
_ = home
|
|
}
|