Codex's side calls ask for one of Codex's own models by its bare name
whatever the conversation is on: a subagent goes on the model the lead
names in spawn_agent, memories on gpt-5.6-luna/terra, auto-review on
codex-auto-review. With Codex signed in to ChatGPT and the conversation
routed onto one of magpie's models, each of those went to the ChatGPT
account instead (cybercaius: "can't pick follow the main model").
- gateway (codexFollowTo, codexLeads): a collab_spawn or memory call
that asks for a bare model, with nothing set for it (no magpie
subagent model, no [agents] default_subagent_model, no [memories]
extract/consolidation_model in Codex's config), goes on the model its
conversation's own turns go on (parent thread, own thread, else the
key's last turn), when that is a magpie model the key may use. A task
the ChatGPT backend sealed stays on ChatGPT. The trace shows a
subagent's pick as {asked -> to}.
- agent.CodexSideSet reads Codex's config.toml for those keys; an
unreadable config counts as set (leave as sent).
- Auto-review gets "Same as the session" (settings value "session"):
codexcat writes each magpie entry's own id as its
auto_review_model_override. Not the default: codex-auto-review runs
free on a ChatGPT sign-in (#1593).
- GUI: the option in all languages; Memories' default text says it
follows the session. app.js stays under its budget by folding five
identical writingPrefs then/catch chains into prefWrite.
Ran (sandbox HOME, -tags nogui -count=1 -timeout 45m):
- go test ./internal/gateway ./internal/agent ./internal/codexcat
./internal/settings ./internal/cli ./internal/gui: ok.
./internal/provider: FAIL with "close of synctest channel from outside
bubble" in filememo.Forget (TestUnreadLoginsWriteErrorsKeepCredentials),
which is #3632 on main; this change touches nothing there.
- TestCodexSubagentFollowsTheSession and TestCodexMemoriesFollowTheSession
go red with codexFollowTo returning "" (broken by hand).
TestCodexSideCallsKeepTheConfigsModel, TestCodexSideCallsStayOnChatGPT,
TestCodexSideSet, TestCodexAutoReviewFollowsTheSession pass.
- GUI (playwright 1.62.0, chromium + webkit): codex-auto-review (en, zh,
zh-TW, ja, de), codex-memories, codex-memories-settings, codex-titles,
codex-predictions, codex-descriptions, settings-general, agent-prefs,
i18n-keys: 120/120 pass. TestCoreScriptBudget passes, budget unchanged.
- gofmt -l clean; go vet -tags nogui for linux, windows and darwin ok.
Again after rebasing on origin/main 49f15d124 (25341b4ca on top touches
only internal/redact; rebuilt): nogui builds (darwin, linux,
windows), TestCoreScriptBudget, the tests above, and the GUI files 120/120.
Not tried: a real Codex with a real ChatGPT account and a relay model.
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// SideModel is the model of magpie's Codex is on beside its ChatGPT
|
|
// sign-in, which the gateway answers the Codex app's titles, descriptions
|
|
// and summaries on (atom_Ray on X): none on one of Codex's own models, and
|
|
// none with magpie Codex's provider, where those requests reach magpie's
|
|
// own API on the model Codex asks for.
|
|
func TestCodexSideModel(t *testing.T) {
|
|
home, _ := codexHome(t, `{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`, "model = \"gpt-a\"\n")
|
|
os.WriteFile(filepath.Join(home, ".codex", "models_cache.json"),
|
|
[]byte(`{"models":[{"slug":"gpt-a","display_name":"A","priority":1}]}`), 0o644)
|
|
cx := codex(home)
|
|
if got := cx.SideModel(); got != "" {
|
|
t.Fatalf("not connected: %q", got)
|
|
}
|
|
if ok, err := cx.Join(); err != nil || !ok {
|
|
t.Fatalf("join: %v %v", ok, err)
|
|
}
|
|
if got := cx.SideModel(); got != "" {
|
|
t.Fatalf("joined on Codex's own model: %q", got)
|
|
}
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := cx.SideModel(); got != "fake/m1" {
|
|
t.Fatalf("a magpie model beside the sign-in: %q", got)
|
|
}
|
|
if err := cx.Field("login").Set("api"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := cx.SideModel(); got != "" {
|
|
t.Fatalf("magpie Codex's provider: %q", got)
|
|
}
|
|
}
|
|
|
|
// CodexSideSet says whether Codex's config names the model for its
|
|
// subagents or its memories itself, the gateway then leaving those calls
|
|
// as Codex sent them; a config it can't read counts as naming one.
|
|
func TestCodexSideSet(t *testing.T) {
|
|
home, _ := codexHome(t, `{}`, "model = \"gpt-a\"\n")
|
|
if CodexSideSet("subagent") || CodexSideSet("memories") {
|
|
t.Fatal("nothing set")
|
|
}
|
|
config := filepath.Join(home, ".codex", "config.toml")
|
|
os.WriteFile(config, []byte("[agents]\ndefault_subagent_model = \"gpt-b\"\n[memories]\nextract_model = \"gpt-c\"\n"), 0o644)
|
|
if !CodexSideSet("subagent") || !CodexSideSet("memories") {
|
|
t.Fatal("both set")
|
|
}
|
|
os.WriteFile(config, []byte("[agents]\ndefault_subagent_model = \"gpt-b\"\n"), 0o644)
|
|
if !CodexSideSet("subagent") || CodexSideSet("memories") {
|
|
t.Fatal("the subagents' alone")
|
|
}
|
|
os.WriteFile(config, []byte("[agents\n"), 0o644)
|
|
if !CodexSideSet("memories") {
|
|
t.Fatal("an unreadable config counts as set")
|
|
}
|
|
}
|