canlee886 on X (2122660479411855365): a Codex App thread saved on group/auto-gpt-6-1-sol failed every turn with 404 "magpie knows no model", followed by every id magpie has, after azure-fte2-sea's gpt-6.1-sol went away; other threads were fine, and switching the thread's model did not help. The user patched the thread over Codex's app-server RPC. Cause: a group magpie finds needs two providers serving the model (autoGroups). When one is removed, or its list no longer has the model, the group is gone. Reseat moves an agent's config off it, but a Codex thread keeps the model it was saved with and names it on every turn. provider.AutoStandIn sent a gone found group's id to its model only while found groups were off, or when a provider kept out of them took it away; any other way of losing the group was a hard 404, even with a provider still serving the very same model. Fix: - AutoStandInFor: with found groups on, a found group's id (group/auto-… or auto/<model>) that is no group now, and that the user neither changed nor removed (no providers.json record), goes to its model from a provider that serves it (the agent's own subscription first, then one not kept out, then the first). It is the same model, never another; a group the user removed stays a 404. - With no provider serving the model, the request is still 404, but unknownModel says the model is gone and to pick another for the conversation (Codex: the model menu under the message box), with the three nearest ids, not every id (provider.GoneAutoGroup). - Codex's compaction on the model a thread is leaving (model_downshift) already compacts locally when that model 404s (2768f04f9); TestCodexLeavingGoneGroupCompactsLocally pins it for a gone group. - docs/subsystems/gateway-routing.md says when a found group can go and what a request for it gets. Siblings: the stand-in is in serve's model resolution, so Claude Code and every other agent saving the id are covered, as are key limits, count_tokens, budget and Codex's own-v1 path, which already ask AutoStandIn. Run (mica/mote via mica-run/mote-run, at this tree): - TestFoundGroupGoneGoesToItsModel: red on the old code (404 "magpie knows no model ... it has ..." with b still serving gpt-6.1-sol), green now. TestAutoGroupSkip's "group/auto-y" case (b's model alone) now expects the stand-in b/y; group/auto-nothing still none. - go test ./internal/provider, ./internal/gateway -run of the group/stand-in/Codex compaction tests: ok. - Full suite at 473de21fa (this change on fefe3f658's parent base) on mote, mote-run: gofmt -l nothing; GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go vet ./...: ok. go test -timeout 45m -count=1 ./...: 101 packages ok, internal/gateway (1035s), agent, provider, gui, cli, budget among them. Two reds, neither touched here: internal/plugin's TestHostOnUnstartableBunSaysWhy (62s deadline, #5878) and internal/redact, whose tests passed and whose TestMain then hung 46m in testenv.RemovePrograms on stand-in warm-ups (#5267, SIGQUIT at 47m); both commented with the output. - After the rebase onto origin/main (fefe3f658, which changed internal/provider/bare.go and internal/gateway), on mica: gofmt -l internal nothing; go test ./internal/provider ./internal/gateway: ok (149s, 1004s). On mote: ./internal/plugin ./internal/redact alone: ok. - Rebased again onto05d46f42e(gateway advisor, agy move; no file shared): go vet and go test -run "FoundGroup|Gone|AutoGroup|StandIn|Advisor|Unknown|Compact|Group" of ./internal/gateway ./internal/provider on mote: ok. Not tried: the reporter's real Codex App thread and Azure providers; the fixture removes the model from a provider's list rather than reproducing why azure-fte2-sea's list lost it.
98 lines
3.4 KiB
Go
98 lines
3.4 KiB
Go
package provider
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// A provider can be kept out of the groups magpie finds (chenxiang0010 on
|
|
// Discord: auto/kimi-k3.1-pro took in a provider they didn't want there):
|
|
// its models are in no found group, a model one other provider serves is
|
|
// no group, a request still naming that group goes to the model from a
|
|
// provider not kept out, the groups the user made or changed keep it, and
|
|
// it follows the provider's rename. Let back in, the groups are as before.
|
|
func TestAutoGroupSkip(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", t.TempDir())
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
for _, id := range []string{"a", "b", "c"} {
|
|
models := []string{"kimi-k3", "x"}
|
|
if id == "c" {
|
|
models = []string{"kimi-k3", "glm-5.3"}
|
|
}
|
|
if id == "b" {
|
|
models = []string{"kimi-k3", "x", "glm-5.3", "y"}
|
|
}
|
|
if err := Save(Provider{ID: id, Name: id, Key: "k", Chat: "http://127.0.0.1:1/v1", Models: models}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
// a found group the user changed is theirs, and keeps b
|
|
if err := SaveGroup(Group{ID: "auto-x", Name: "X", Members: []string{"b/x", "a/x"}, Routing: Ordered}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
members := func(id string) []string {
|
|
for _, g := range Groups() {
|
|
if g.ID == id && !g.Hidden {
|
|
return g.Members
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
if got := members("auto-kimi-k3"); !slices.Equal(got, []string{"a/kimi-k3", "b/kimi-k3", "c/kimi-k3"}) {
|
|
t.Fatalf("before: %v", got)
|
|
}
|
|
if err := SetAutoGroupSkip([]string{" B ", "b"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := AutoGroupSkip(); !slices.Equal(got, []string{"b"}) {
|
|
t.Fatalf("skip: %v", got)
|
|
}
|
|
if got := members("auto-kimi-k3"); !slices.Equal(got, []string{"a/kimi-k3", "c/kimi-k3"}) {
|
|
t.Fatalf("b kept out: %v", got)
|
|
}
|
|
if got := members("auto-glm-5-3"); got != nil {
|
|
t.Fatalf("a model only c serves besides b is still a group: %v", got)
|
|
}
|
|
if got := members("auto-x"); !slices.Equal(got, []string{"b/x", "a/x"}) {
|
|
t.Fatalf("the user's own found group lost b: %v", got)
|
|
}
|
|
// a request for the group skipping took away goes to c's, not b's
|
|
for in, want := range map[string]string{"group/auto-glm-5-3": "c/glm-5.3", "auto/glm-5.3": "c/glm-5.3"} {
|
|
if got, ok := AutoStandIn(in); !ok || got != want {
|
|
t.Fatalf("%s: %q %v, want %s", in, got, ok, want)
|
|
}
|
|
}
|
|
// none for a group there is, or one gone for another reason
|
|
if _, ok := AutoStandIn("group/auto-kimi-k3"); ok {
|
|
t.Fatal("a stand-in for a group there is")
|
|
}
|
|
// y, b's alone, is no group: its group's id still reaches it there, as
|
|
// a group gone for want of a second provider does (canlee886 on X)
|
|
if got, ok := AutoStandIn("group/auto-y"); !ok || got != "b/y" {
|
|
t.Fatalf("group/auto-y: %q %v, want b/y", got, ok)
|
|
}
|
|
if _, ok := AutoStandIn("group/auto-nothing"); ok {
|
|
t.Fatal("a stand-in for a model no provider serves")
|
|
}
|
|
// kept out under its new id
|
|
if err := Rename("b", "bee"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := AutoGroupSkip(); !slices.Equal(got, []string{"bee"}) {
|
|
t.Fatalf("after rename: %v", got)
|
|
}
|
|
if got := members("auto-kimi-k3"); !slices.Equal(got, []string{"a/kimi-k3", "c/kimi-k3"}) {
|
|
t.Fatalf("renamed, back in: %v", got)
|
|
}
|
|
if err := SetAutoGroupSkip(nil); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := members("auto-glm-5-3"); !slices.Equal(got, []string{"bee/glm-5.3", "c/glm-5.3"}) {
|
|
t.Fatalf("let back in: %v", got)
|
|
}
|
|
if _, ok := AutoStandIn("group/auto-glm-5-3"); ok {
|
|
t.Fatal("a stand-in once nothing is kept out")
|
|
}
|
|
}
|