agent: a model picked in Codex's /model beside its ChatGPT sign-in is not drift (#2424)
Connected beside the ChatGPT sign-in (openai_base_url to magpie), Codex picking one of its own models in /model still goes through magpie, but Drift() called it "replaced" and the Agents row went red with Reconnect, which reads as a broken gateway (Essaim8, #2424). Joined agents already treated such a pick as one made in the agent; Beside now does too, for Codex and StepCode alike. Wired() already counted both as connected. Without a sign-in a model off magpie is still told as replaced. Run: - TestCodexOwnPickAfterMagpieModelStaysConnected and TestCodexGroupByItsModelName red on the old applied.go (drift "replaced" on gpt-6.1-sol / gpt-6.1 / gpt-5.5 beside the sign-in), green after. - go test ./internal/agent ./internal/gui ok; gofmt clean; go vet -tags nogui for darwin, linux, windows ok on agent, gui, gateway. Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok, every package (at this batch head).
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user