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.
39 lines
1.7 KiB
Go
39 lines
1.7 KiB
Go
package gateway
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// unknownModel is what a request for a model magpie doesn't know is told
|
|
// (MOMO on Discord: "Zen-Space-Bunny" got a 404 that said neither how a
|
|
// model is named nor which one was meant): the ids nearest to it, the
|
|
// ways a model can be named, then every id there is. what is "" for a
|
|
// chat, or what the model was for (" to draw with"). A group magpie found
|
|
// that is gone with its model is said so, with what to do (GoneAutoGroup).
|
|
func unknownModel(asked, what string) string {
|
|
if provider.GoneAutoGroup(asked) {
|
|
// a conversation saved on a group magpie found whose model no
|
|
// provider serves now (canlee886 on X): what to do, not every id
|
|
msg := fmt.Sprintf("magpie no longer serves %q%s: it was the routing group magpie found for a model, and no provider in magpie serves that model now", asked, what)
|
|
if near := provider.Closest(asked, 3); len(near) > 0 {
|
|
msg += " (nearest now: " + strings.Join(near, ", ") + ")"
|
|
}
|
|
return msg + "; pick another model for this conversation in the agent (in Codex, the model menu under the message box), or add back a provider that serves it"
|
|
}
|
|
msg := fmt.Sprintf("magpie knows no model %q%s", asked, what)
|
|
if near := provider.Closest(asked, 3); len(near) > 0 {
|
|
msg += "; did you mean " + strings.Join(near, ", ") + "?"
|
|
}
|
|
msg += " Name a model as provider/model (as /v1/models lists it), a routing group's id or name, or a bare model id" +
|
|
" (one served by several providers goes to the group magpie found for it, else to the first of them in the Providers order)"
|
|
if ids := provider.IDs(); len(ids) > 0 {
|
|
msg += "; it has " + strings.Join(ids, ", ")
|
|
} else {
|
|
msg += "; add a provider in magpie first"
|
|
}
|
|
return msg
|
|
}
|