diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 5ce69c0ca..5f497d64d 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -160,8 +160,8 @@ type Agent struct { Joined func() bool // Beside reports an agent set on one of magpie's models beside its own // (Codex by the base URL beside its ChatGPT sign-in), now on one of its - // own written in by the agent: still connected, as joined, though the - // change is told as drift (#940). + // own written in by the agent: still connected, as joined (#940), and + // a pick in the agent rather than drift (#2424). Beside func() bool // OwnVia is the catalog id magpie serves one of the agent's own models // by on a sign-in of the user's, which its model field lists as its diff --git a/internal/agent/applied.go b/internal/agent/applied.go index 2a8ec01a5..0b3e01e49 100644 --- a/internal/agent/applied.go +++ b/internal/agent/applied.go @@ -182,8 +182,11 @@ func (a *Agent) Drift() *Drift { } rec := appliedOf(a.ID) // still joined, a model off magpie is one picked in the agent, beside - // magpie's in its list (dsh's /model), not a change from outside + // magpie's in its list (dsh's /model), not a change from outside; so is + // one Codex picks beside its ChatGPT sign-in, which still goes through + // magpie (#2424: the row went red with Reconnect) joined := a.Joined != nil && a.Joined() + picked := joined || a.Beside != nil && a.Beside() for _, f := range a.Fields { want, ok := rec.Fields[f.Key] // a field that reads empty while it follows another (Claude Code's @@ -195,7 +198,7 @@ func (a *Agent) Drift() *Drift { if now == "" && f.Follows != "" { now = vals[f.Follows] } - if !ok || joined || now == want || !magpieValue(a, f, want, vals) || magpieValue(a, f, now, vals) || sameGroup(want, now) { + if !ok || picked || now == want || !magpieValue(a, f, want, vals) || magpieValue(a, f, now, vals) || sameGroup(want, now) { continue } return &Drift{Kind: "replaced", Field: f.Key, Now: vals[f.Key], Want: want, diff --git a/internal/agent/codex_connected_test.go b/internal/agent/codex_connected_test.go index 7a4a3b853..ceaa03bc5 100644 --- a/internal/agent/codex_connected_test.go +++ b/internal/agent/codex_connected_test.go @@ -31,9 +31,9 @@ func TestCodexOwnPickAfterMagpieModelStaysConnected(t *testing.T) { if !cx.Wired() { t.Fatalf("Codex's own pick disconnected it:\n%s", read()) } - // told as a change from outside, the row still connected - if d := cx.Drift(); d == nil || d.Kind != "replaced" || d.Now != "gpt-6.1-sol" { - t.Fatalf("drift: %+v", d) + // a pick beside magpie's models, not a change from outside (#2424) + if d := cx.Drift(); d != nil { + t.Fatalf("drift on Codex's own pick beside its sign-in: %+v", d) } if err := cx.Disconnect(); err != nil { t.Fatal(err) diff --git a/internal/agent/codex_group_alias_test.go b/internal/agent/codex_group_alias_test.go index e5ae6c286..432490c78 100644 --- a/internal/agent/codex_group_alias_test.go +++ b/internal/agent/codex_group_alias_test.go @@ -54,15 +54,18 @@ func TestCodexGroupByItsModelName(t *testing.T) { if cx.Wired() { t.Errorf("auth %q: wired on gpt-6.1-sol with no route to magpie", auth) } - // another group's model is not what magpie set - os.WriteFile(path, []byte(strings.Replace(cfg, `model = "group/auto-gpt-6-1-sol"`, `model = "gpt-6.1"`, 1)), 0o644) - if d := cx.Drift(); d == nil || d.Kind != "replaced" || d.Now != "gpt-6.1" { - t.Errorf("auth %q: gpt-6.1, another group: %+v", auth, d) - } - // nor is one no group has - os.WriteFile(path, []byte(strings.Replace(cfg, `model = "group/auto-gpt-6-1-sol"`, `model = "gpt-5.5"`, 1)), 0o644) - if d := cx.Drift(); d == nil || d.Kind != "replaced" || d.Now != "gpt-5.5" { - t.Errorf("auth %q: gpt-5.5: %+v", auth, d) + // another group's model is not what magpie set, nor is one no group + // has; beside the ChatGPT sign-in either is a pick in Codex's /model + // that still goes through magpie, not a change from outside (#2424) + for _, m := range []string{"gpt-6.1", "gpt-5.5"} { + os.WriteFile(path, []byte(strings.Replace(cfg, `model = "group/auto-gpt-6-1-sol"`, `model = "`+m+`"`, 1)), 0o644) + d := cx.Drift() + if auth != "" && d != nil { + t.Errorf("auth %q: %s beside the sign-in: %+v", auth, m, d) + } + if auth == "" && (d == nil || d.Kind != "replaced" || d.Now != m) { + t.Errorf("no sign-in: %s: %+v", m, d) + } } } }