diff --git a/docs/reference.md b/docs/reference.md index b1ce89584..419420222 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -1607,9 +1607,8 @@ one provider serves it. `listed=no` (the group editor's **Model lists: The group alone**) keeps the models a group names, and those its patterns match, out of `magpie models`, `/v1/models` and every agent's list, so a client offers the group alone. -A signed-in subscription's own models (a ChatGPT, Claude, Copilot or plugin -account's) stay in every agent's list: the group is added on top of them, -and only a client that is no agent is given the group alone. +A signed-in subscription's models leave the lists too. Codex alone keeps its +ChatGPT sign-in's own models, which its app reaches on that sign-in. They are still served: the group routes over them, and a request naming one as `provider/model` is answered. A group in it keeps its own setting, and a group switched off keeps nothing out. `listed=yes` lists them again. To keep diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index dca22179f..b75205a12 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -254,7 +254,7 @@ recorded as a prediction failure (`noPrediction`). - A translated Chat stream's tool calls are read by `index`, not as one after another (`chatDecoder.toolCall` in [`chat.go`](../../internal/gateway/chat.go)). An upstream may send several calls' fragments by turns (index 0, 1, 0, 1…), the first of each with its id and name; read as a new call at each change of index, two calls reached Codex as six `function_call` items, the first two with `{}` and four with no name (mysterious_dove on Discord). The open call streams as it comes; a call that starts while the open one's arguments aren't yet whole JSON is held by its index and given whole, in index order, at `finish_reason` or `[DONE]`. Every translation from Chat (Responses, Messages, Gemini, a whole reply) reads the stream through it. `TestInterleavedToolCallsToResponses`, `TestInterleavedToolCallsToAnthropic`, `TestInterleavedToolCallsWhole`, `TestToolCallsNamedFirstThenArgued` in [`translate_stream_test.go`](../../internal/gateway/translate_stream_test.go). - A relayed Chat reply whose choice made calls and ended `stop` ends `tool_calls`, streamed (`chatTidy`) and whole (`chatWhole`), as the translations' collector already ends it (`collector.finish`): told it stopped, a client that reads `finish_reason` ends its turn with the calls not run (喜欢一个人 on Discord, a relay in front of deepseek-v4.1-flash). Any other reason stays as it came. `TestChatCallsEndToolCalls` in [`chattidy_finish_test.go`](../../internal/gateway/chattidy_finish_test.go). - A Chat reply's call whose function names nothing in a JSON string — no name, null, another kind — is dropped, its later fragments with it, and a finish of `tool_calls` with no call left after the drop ends `stop` (a reply that came with no calls keeps its finish), and a whole reply given as a stream numbers the calls it keeps with no gap: streamed (`chatTidy`), whole (`chatWhole`) and a whole reply given to the agent as the stream it asked for (`chatWholeEvents`), since a client that checks the shape of every frame refuses the whole reply for one — the turn not retryable, the call already in the history, the session dead, while the gateway's own log says the reply went (AricRedemption, #1475). A nameless call runs nowhere, so it is no call, as a written block naming no offered tool is; a name the client reads as a string, empty included, goes as it came. `TestNamelessCallStreamDropped`, `TestNameAbsentStreamDropped`, `TestNamelessCallBesideAGoodOne`, `TestNamelessCallWholeDropped`, `TestNamelessCallWholeAsStreamDropped`, `TestNamelessCallWithoutAnIDStaysDropped`, `TestNamelessCallBesideAGoodOneWholeAsStream`, `TestToolCallsFinishWithNoCallsStaysWhole` in [`chat_call_name_test.go`](../../internal/gateway/chat_call_name_test.go). -- Codex's model list from the backend path (`codexModels`) is the ChatGPT backend's for its sign-in and then magpie's (`provider.CodexListed`), its ETag and every reply's `X-Models-Etag` tagged with `provider.CodexListTag` so a change has Codex ask again. A Codex there only for account failover, not connected (`CodexOwnOnly`, `agent.CodexOwnOnly`; #1385), gets the backend's alone, tagged with `provider.CodexOwnListTag`; neither tag contains the other, so connecting or disconnecting has Codex fetch the list again. The user's picks on the codex provider (`provider.CodexNativePicked`) narrow the backend's listed models. They keep its hidden ones (`visibility: "hide"`), which no picker shows. One of those is `codex-auto-review`: when the list lacks it and no reviewer is set, Codex's auto-review runs on the conversation's model at low effort (#1460, `TestCodexModelListPicksKeepHidden`). The account's own models stay in it when they are kept out of other agents' lists for routing groups, by the codex provider "Only through routing groups" (`Provider.Unlisted`) or a group that unlists its members (`Group.Unlists`): Codex's own catalog (`catalogOf("codex")`, behind `ListedFor`/`CatalogFor`) keeps `CodexOwn` entries, so the Agents page shows its Codex section, its picker offers them as magpie's, and the desk file and `spawnChoices` list them. #1602 dropped them here, and the picker then still offered them through the own-models switch while the Codex app had none (士奇 on Discord, 10-28). They are hidden from Codex through Codex's list (`provider.CodexNativeHidden`, `TestCodexModelListKeepsOwnForGroups`, `TestCodexOwnModelsListedOnlyThroughGroups`). Every agent keeps a signed-in subscription's own models (`provider.SubscriptionKept`: an account's, its provider not `Unlisted`) that a group listing alone would keep out: `catalogOf(agent)` keeps them for any agent, so the Agents page, the pickers, the files magpie writes and the agent's `/v1/models` (and `/v1/models/{id}`, Desktop's aliases through `provider.CatalogOf`) still have them with the group on. Only a client that is no agent (`CatalogFor("")`, `Catalog()`) is given the group alone (#1783). a3ee00c05 had kept them for Codex alone, and Hermes Agent and WorkBuddy lost the Codex section with the group on (士奇 on Discord, 10-30; `TestSubscriptionModelsStayInEveryAgentsListWithGroupOn`). A backend answer that says the sign-in itself is revoked (`provider.SignInRevoked`, a 401 `token_revoked`; jjt on Discord, #4308) isn't passed through: the list is Codex's cached one (`codexcat.CacheEntries`) and magpie's, so the picker keeps magpie's models; any other refusal, a 401 `token_expired` among them, still is. The desk file does the same while the live list says revoked (`provider.CodexListRevoked`, `codexDesk.revoked`) (`TestCodexModelListRevokedSignIn`, `TestCodexDesktopCatalogRevokedSignIn`). +- Codex's model list from the backend path (`codexModels`) is the ChatGPT backend's for its sign-in and then magpie's (`provider.CodexListed`), its ETag and every reply's `X-Models-Etag` tagged with `provider.CodexListTag` so a change has Codex ask again. A Codex there only for account failover, not connected (`CodexOwnOnly`, `agent.CodexOwnOnly`; #1385), gets the backend's alone, tagged with `provider.CodexOwnListTag`; neither tag contains the other, so connecting or disconnecting has Codex fetch the list again. The user's picks on the codex provider (`provider.CodexNativePicked`) narrow the backend's listed models. They keep its hidden ones (`visibility: "hide"`), which no picker shows. One of those is `codex-auto-review`: when the list lacks it and no reviewer is set, Codex's auto-review runs on the conversation's model at low effort (#1460, `TestCodexModelListPicksKeepHidden`). The account's own models stay in it when they are kept out of other agents' lists for routing groups, by the codex provider "Only through routing groups" (`Provider.Unlisted`) or a group that unlists its members (`Group.Unlists`): Codex's own catalog (`catalogOf("codex")`, behind `ListedFor`/`CatalogFor`) keeps `CodexOwn` entries, so the Agents page shows its Codex section, its picker offers them as magpie's, and the desk file and `spawnChoices` list them. #1602 dropped them here, and the picker then still offered them through the own-models switch while the Codex app had none (士奇 on Discord, 10-28). They are hidden from Codex through Codex's list (`provider.CodexNativeHidden`, `TestCodexModelListKeepsOwnForGroups`, `TestCodexOwnModelsListedOnlyThroughGroups`). Every other agent, and every client of `/v1/models` (one that names no agent is `other` or its User-Agent's name, never `""`), is given `Catalog()`: a group listing alone keeps a signed-in subscription's models out of its list too. 88e6fb9cf had kept them for every agent (`SubscriptionKept`), so for a group of subscription models the option changed no list fetched over HTTP (shaoyang. on Discord, 11-03; `TestGroupAloneKeepsSubscriptionModelsOutOfEveryAgentsList`, `TestGroupAloneKeepsSubscriptionModelsOffAgentsModelList`). A backend answer that says the sign-in itself is revoked (`provider.SignInRevoked`, a 401 `token_revoked`; jjt on Discord, #4308) isn't passed through: the list is Codex's cached one (`codexcat.CacheEntries`) and magpie's, so the picker keeps magpie's models; any other refusal, a 401 `token_expired` among them, still is. The desk file does the same while the live list says revoked (`provider.CodexListRevoked`, `codexDesk.revoked`) (`TestCodexModelListRevokedSignIn`, `TestCodexDesktopCatalogRevokedSignIn`). - The Codex app and its VS Code extension read only the first 100 of that list by priority, hidden entries counted: each asks its app-server for `model/list` with `limit: 100` and never for the next page (ChatGPT.app 26.1013, openai.chatgpt 26.51021; the CLI's `/model` lists every one). So `codexcat.FitOwn` ranks the list last of all: hidden entries after every listed one, and, with more than 100 listed (`codexcat.AppList`), Codex's own listed models (the backend's entries in `codexMerged`; a ChatGPT account's `codex/…` ones, `codexcat.ChatGPTOwn`, on the other two routes) and then the models Codex used in the last 30 days (`usage.CodexUsed`, most recent first, at most 100) brought into the first 100 in the order they stood, the rest kept in theirs. The user's own order (`codexcat.Order`, #855) goes first, so an order that names only magpie's models (set while Codex's list had no Codex section, or before OpenAI added a model) no longer puts every GPT model past the 100th (maiya on Discord); the user takes one out of the app by hiding it in Codex's list. The same holds for `/v1/codex/models` (with the models that key's Codex used alone, `usage.CodexUsedBy`, before the 1 MiB cut) and the `model_catalog_json` magpie writes (`codexcat.CatalogUsed`). `codexListTag` carries a tag of the used set (`codexcat.UsedTag`), so the ETag and `X-Models-Etag` change when Codex uses a model it hadn't; `usage.CodexUsed` is read again a minute on, or at once when `Append` writes a Codex call to a model it doesn't hold (`codexUsedNew`). `TestCodexModelListKeepsUsedModelsInTheAppsHundred`, `TestCodexCatalogKeepsTheKeysUsedModelsFirst`, `TestFitKeepsUsedModelsWhereTheCodexAppReads`, `TestCodexUsed`, `TestCodexModelListKeepsOwnModelsInTheAppsHundred`, `TestFitOwnKeepsCodexsOwnInTheAppsHundred` and `TestCatalogUsedKeepsChatGPTOwn` cover it (@ZhenLuoTTAWDTT on X). - Reasoning state goes through magpie's translation as the vendor wrote it when the agent and the upstream speak the same API (#1445, XYenon): a non-streaming Messages request to a stream-only account, web search on the agent's own API, a plugin, failover. The IR carries it sealed (`Part.Sealed`, `SealedBy`; events `KThinkStart`, `KSealed`, `KTextSig` in [`ir.go`](../../internal/gateway/ir.go)), so each thinking block or reasoning item stays apart, whole or streamed, and a seal is written only for its own API (`sealedBy`). Anthropic's `redacted_thinking` goes back raw (to DeepSeek as a thinking block, below), and a thinking block signed with no text keeps its signature (`aBlock` still writes `"thinking": ""`, #1447), on Claude's subscription too. A Responses reasoning item keeps its id, summary and `encrypted_content`, and goes back to a Responses upstream as it came when it has no reasoning text (`sealedReasoning`; text, another vendor's, is still left out for OpenAI, #1411). Gemini's `thoughtSignature` stays on the call it signed and on text; a later call of a signed step goes without one, and only an unsigned step or Claude on Antigravity gets `skip_thought_signature_validator`. Another API's agent gets the call's signature in its id, as on chat (#687), with its length in the mark (`__ts__`), so an id a client shortened carries no signature and the call goes as unsigned (#1536); it gets no one else's seal. The signature itself is kept in magpie's folder, `gemini-signatures/`, named by its hash (`keepSignature` in [`gemini_sigstore.go`](../../internal/gateway/gemini_sigstore.go)), and the id carries only the key (`__tsk16__`), so an id stays under 64 characters however long the step's signature (#2411: LobeHub's PostgreSQL index turned away a 3KB id). A key magpie no longer has, or whose file doesn't hash to it, reads as no signature; one not read for 90 days is removed. Where the folder can't be written, the id carries the signature as before. Across APIs, only Claude's reasoning is carried to a Responses client, below. - A Responses upstream reads only the reasoning it sealed itself (`encrypted_content`). When one answers that it can't read the sealed reasoning or compaction it was sent (`foreignReasoning` in [`affinity.go`](../../internal/gateway/affinity.go): OpenAI's and Codex's "could not be verified", xAI's "Could not decrypt", Azure's "invalid encrypted summary", a relay's compaction-blob refusal), `serve` asks once more without it and remembers its hashes for that conversation (`stickKey`) and key or account (`candidate.vendor`, `refusedSeals`), so the conversation's later turns there go without it the first time; the try is `fail: foreign`. A Responses client's own items go first (`withoutReasoning`, `withoutRefused`), then OpenAI's compaction (`withoutCompaction`). A Chat, Messages or Gemini client holds a Responses upstream's sealed reasoning in its calls' ids instead (`__rk__`, `carryReasoning` and `unreasonCalls` in [`reasoning_carry.go`](../../internal/gateway/reasoning_carry.go), 9da9bfabd), and every later turn of its history sends it again, so a conversation that moved to another Responses upstream or account (Grok to Codex after a 402, and back) was refused on that turn and every one after it (#4798, zane668, ZanderH-code). Such a refusal is asked again once too: `refuseCarried` remembers what the request's calls carried as refused by that key or account, and `translate` leaves those items out of this and every later request to it (`withoutRefusedCarry`, scoped to the try's provider through `withSealScope`). The calls, their arguments and results and the text go as the client wrote them, under the calls' own ids; the one that sealed an item, and every other key or account, is still given it. As for a Responses client, all the reasoning the request carried goes, the upstream's own earlier items among them; what it seals next goes along. `TestForeignSealAcrossGroupMembers`, `TestForeignCarriedReasoningAskedAgainWithout`. diff --git a/internal/gateway/codex_backend_test.go b/internal/gateway/codex_backend_test.go index 45a8d66af..3148358b1 100644 --- a/internal/gateway/codex_backend_test.go +++ b/internal/gateway/codex_backend_test.go @@ -848,6 +848,92 @@ func TestCodexModelListKeepsOwnForGroups(t *testing.T) { } } +// A group listing alone (Group.Unlists, 成员模型不单独列出) keeps a signed-in +// subscription's models out of /v1/models for an agent's key too, not only +// for a client that is no agent (shaoyang. on Discord, 11-03: the list +// fetched still had every model of the group). Codex keeps its own +// ChatGPT models, by name too (/v1/models/{id}); with its models listed too +// they are listed again. +func TestGroupAloneKeepsSubscriptionModelsOffAgentsModelList(t *testing.T) { + codexSignedIn(t) + if err := provider.Save(provider.Provider{ID: "codex", Models: []string{"gpt-6-sol", "gpt-5.5"}}); err != nil { + t.Fatal(err) + } + var refs []string + for _, e := range provider.Catalog() { + if provider.CodexOwn(e) { + refs = append(refs, e.ID) + } + } + if len(refs) != 2 { + t.Fatalf("the account's models: %v", refs) + } + h := New().Handler() + list := func(key string) map[string]bool { + t.Helper() + rec := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/v1/models", nil) + if key != "" { + req.Header.Set("x-api-key", key) + } + h.ServeHTTP(rec, req) + if rec.Code != 200 { + t.Fatalf("%s: %d %s", key, rec.Code, rec.Body) + } + var got struct { + Data []struct { + ID string `json:"id"` + } `json:"data"` + } + json.Unmarshal(rec.Body.Bytes(), &got) + out := map[string]bool{} + for _, m := range got.Data { + out[m.ID] = true + } + return out + } + found := func(key, id string) bool { + rec := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/v1/models/"+id, nil) + req.Header.Set("x-api-key", key) + h.ServeHTTP(rec, req) + return rec.Code == 200 + } + g := provider.Group{ID: "mine", Name: "Mine", Members: refs, Unlists: true} + if err := provider.SaveGroup(g); err != nil { + t.Fatal(err) + } + for _, key := range []string{"", Token, Token + "-hermes", Token + "-claude", Token + "-opencode"} { + got := list(key) + if !got["group/mine"] { + t.Errorf("%q: the group isn't listed: %v", key, got) + } + for _, ref := range refs { + if got[ref] { + t.Errorf("%q: %s listed beside the group listing alone", key, ref) + } + } + } + if found(Token+"-hermes", refs[0]) { + t.Errorf("/v1/models/%s found for Hermes", refs[0]) + } + if got := list(Token + "-codex"); !got[refs[0]] || !got[refs[1]] { + t.Errorf("Codex lost its own models: %v", got) + } + if !found(Token+"-codex", refs[0]) { + t.Errorf("/v1/models/%s not found for Codex", refs[0]) + } + g.Unlists = false + if err := provider.SaveGroup(g); err != nil { + t.Fatal(err) + } + for _, key := range []string{"", Token + "-hermes"} { + if got := list(key); !got[refs[0]] || !got[refs[1]] || !got["group/mine"] { + t.Errorf("%q, its models too: %v", key, got) + } + } +} + // A reply's X-Models-Etag carries magpie's list too: Codex refetches its // model list on a new one, and only on the backend's it never would when a // provider was added. diff --git a/internal/gateway/desktop.go b/internal/gateway/desktop.go index f41da8946..23cb736cf 100644 --- a/internal/gateway/desktop.go +++ b/internal/gateway/desktop.go @@ -455,9 +455,7 @@ func aliased(id string) (string, bool) { if len(number) != 10 { return "", false } - // the catalog Desktop and Science are listed from: a signed-in - // subscription's model a group listing alone keeps out of Catalog - // is still theirs (provider.SubscriptionKept) + // the catalog Desktop and Science are listed from for _, e := range provider.CatalogOf("claude-desktop") { if aliasNumber(e.ID) == number { return e.ID, true diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 2682ebef9..e0fc8281a 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -1567,9 +1567,9 @@ func (s *Server) models(w http.ResponseWriter, r *http.Request) { func (s *Server) model(w http.ResponseWriter, r *http.Request) { id := unprefixed(r.PathValue("id")) - // the catalog the agent asking is listed from (/v1/models): a signed-in - // subscription's model a group listing alone keeps out of Catalog is - // still in an agent's list, and found here too + // the catalog the agent asking is listed from (/v1/models): Codex's + // own ChatGPT models a group listing alone keeps out of Catalog are + // still in Codex's, and found here too shown := keyAllowed(r, provider.CatalogOf(agentOf(r))) for _, e := range shown { if e.ID == id || e.Group != "" && provider.SameRef(e.ID, id) { diff --git a/internal/gui/agent_models_codex_group_test.go b/internal/gui/agent_models_codex_group_test.go index 41d19c1f0..898bb0136 100644 --- a/internal/gui/agent_models_codex_group_test.go +++ b/internal/gui/agent_models_codex_group_test.go @@ -108,10 +108,9 @@ func codexSignedInSandbox(t *testing.T) []string { return ids } -// The codex provider "Only through routing groups" (只通过路由分组使用) keeps -// the ChatGPT account's models out of other agents' lists but in Codex's -// own, and a group that lists itself alone keeps them in every agent's -// (士奇 on Discord, 10-28: "开启路由组以后,agent 设置页面,模型列表里就是丢失 codex 供应商和对应模型,在下拉 +// The codex provider "Only through routing groups" (只通过路由分组使用), or a +// group that lists itself alone, keeps the ChatGPT account's models out of +// other agents' lists but in Codex's own (士奇 on Discord, 10-28: "开启路由组以后,agent 设置页面,模型列表里就是丢失 codex 供应商和对应模型,在下拉 // 选项中虽然能显示 codex 模型但是实际codex 应用中是没有的"). Codex's list // has its Codex section, so its picker offers them as magpie's and there is // no own-models switch to show them by. @@ -159,10 +158,9 @@ func TestCodexOwnModelsListedOnlyThroughGroups(t *testing.T) { if err := provider.SaveGroup(provider.Group{ID: "mygpt", Name: "MyGPT", Members: []string{"codex/gpt-5.5", "codex/gpt-5.4"}, Unlists: true}); err != nil { t.Fatal(err) } - // a group listing alone no longer keeps a subscription's models from - // any agent (TestSubscriptionModelsStayInEveryAgentsListWithGroupOn): - // Claude Code lists them too - check("group lists itself alone") + // a group listing alone keeps them from every other agent + // (TestGroupAloneKeepsSubscriptionModelsOutOfEveryAgentsList) + check("group lists itself alone", "codex/gpt-5.5", "codex/gpt-5.4") p, err := provider.Find("codex") if err != nil { t.Fatal(err) @@ -179,15 +177,19 @@ func TestCodexOwnModelsListedOnlyThroughGroups(t *testing.T) { check("only through routing groups", all...) } -// A group that lists itself alone (Group.Unlists) keeps its models out -// of a client's /v1/models (#1783), but a signed-in subscription's models -// stay in every agent's list with it switched on: the group is added on -// top (士奇 on Discord, a third time: with the group on, Hermes Agent's and -// WorkBuddy's lists lost the Codex section and every GPT model, and off -// they were back; a3ee00c05 kept them in Codex's list alone). Every agent -// is checked, its Agents-page list and its model pickers, so a fix for one -// agent can't pass for all. -func TestSubscriptionModelsStayInEveryAgentsListWithGroupOn(t *testing.T) { +// A group that lists itself alone (Group.Unlists, the routing editor's +// the group alone, its card's 成员模型不单独列出) keeps its models out of +// every agent's list, a signed-in subscription's too (shaoyang. on +// Discord, 11-03: with it on, the list fetched still had every model of +// the group). 88e6fb9cf kept a subscription's models in every agent's +// list, so for a group of them, as most groups are, the option changed +// nothing an agent was listed. Codex alone keeps its ChatGPT sign-in's own +// (TestCodexOwnModelsListedOnlyThroughGroups). With its models listed too, every +// agent lists them beside the group (士奇 on Discord: a group switched on +// takes nothing from the lists then). Every agent is checked, its +// Agents-page list, what it is written and /v1/models gives it, and its +// model pickers, so a fix for one agent can't pass for all. +func TestGroupAloneKeepsSubscriptionModelsOutOfEveryAgentsList(t *testing.T) { ids := codexSignedInSandbox(t) var refs []string for _, id := range ids { @@ -200,8 +202,25 @@ func TestSubscriptionModelsStayInEveryAgentsListWithGroupOn(t *testing.T) { } return out } - // the group names every one of them, as the reporter's took all five - if err := provider.SaveGroup(provider.Group{ID: "mygpt", Name: "MyGPT", Members: refs, Unlists: true}); err != nil { + picks := func(a *agent.Agent) []string { + var out []string + for _, f := range agentFields(a, a.Values()) { + if f.Key != "model" { + continue + } + for _, o := range f.Options { + out = append(out, o.Value) + } + } + return out + } + // a picker's value is the ref, or the ref after a prefix of the agent's + member := func(v string) bool { + return slices.ContainsFunc(refs, func(r string) bool { return v == r || strings.HasSuffix(v, "/"+r) }) + } + // the group names every one of them + g := provider.Group{ID: "mygpt", Name: "MyGPT", Members: refs, Unlists: true} + if err := provider.SaveGroup(g); err != nil { t.Fatal(err) } checked := 0 @@ -210,30 +229,23 @@ func TestSubscriptionModelsStayInEveryAgentsListWithGroupOn(t *testing.T) { if !got["group/mygpt"] { continue // an agent shown no models of magpie's (or no groups) } + if strings.EqualFold(a.ListsFor(), "codex") { + continue // its own sign-in's models stay (catalogOf) + } checked++ for _, ref := range refs { - if !got[ref] { - t.Errorf("group on: %s not in %s's list %v", ref, a.ID, got) + if got[ref] { + t.Errorf("the group alone: %s in %s's list", ref, a.ID) } } - if shown, _ := provider.CatalogFor(a.ListsFor()); !slices.ContainsFunc(shown, func(e provider.Entry) bool { return e.ID == refs[0] }) { - t.Errorf("group on: %s not in what %s is written and /v1/models gives it", refs[0], a.ID) + if shown, _ := provider.CatalogFor(a.ListsFor()); slices.ContainsFunc(shown, func(e provider.Entry) bool { return slices.Contains(refs, e.ID) }) { + t.Errorf("the group alone: a member in what %s is written and /v1/models gives it", a.ID) } - var picks []string - for _, f := range agentFields(a, a.Values()) { - if f.Key != "model" { - continue - } - for _, o := range f.Options { - picks = append(picks, o.Value) - } - } - if slices.ContainsFunc(picks, func(v string) bool { return strings.HasSuffix(v, "group/mygpt") }) && - !slices.ContainsFunc(picks, func(v string) bool { return v == ids[0] || strings.HasSuffix(v, refs[0]) }) { - t.Errorf("group on: %s's picker offers the group but not %s: %v", a.ID, refs[0], picks) + if p := picks(a); slices.ContainsFunc(p, member) { + t.Errorf("the group alone: %s's picker offers a member: %v", a.ID, p) } } - for _, id := range []string{"hermes", "workbuddy", "claude", "codex"} { + for _, id := range []string{"hermes", "workbuddy", "claude"} { a, err := agent.Find(id) if err != nil { t.Fatal(err) @@ -245,36 +257,30 @@ func TestSubscriptionModelsStayInEveryAgentsListWithGroupOn(t *testing.T) { if checked < 10 { t.Errorf("only %d agents' lists checked", checked) } - // a client that is no agent is still given the group alone (#1783) for _, e := range provider.Catalog() { if slices.Contains(refs, e.ID) { t.Errorf("the gateway's /v1/models for a client lists %s, kept for the group", e.ID) } } - if shown, _ := provider.CatalogFor(""); slices.ContainsFunc(shown, func(e provider.Entry) bool { return slices.Contains(refs, e.ID) }) { - t.Error("a client that is no agent is listed the group's models") - } - // the picker's "kept for routing groups" note doesn't name a model the - // agents are offered - for _, m := range unlistedModels() { - if slices.Contains(refs, m.ID) { - t.Errorf("%s said kept for routing groups, while every agent lists it", m.ID) + // the picker's "kept for routing groups" note names them + for _, ref := range refs { + if !slices.ContainsFunc(unlistedModels(), func(m unlistedJSON) bool { return m.ID == ref }) { + t.Errorf("%s not said kept for routing groups", ref) } } - // the codex provider kept for routing groups itself still keeps them - // out of the other agents' lists: the user's own switch, which a group - // switched off doesn't bring back - p, err := provider.Find("codex") - if err != nil { + + // its models too: every agent lists them beside the group + g.Unlists = false + if err := provider.SaveGroup(g); err != nil { t.Fatal(err) } - q := *p - q.Unlisted = true - if err := provider.Save(q); err != nil { - t.Fatal(err) - } - hermes, _ := agent.Find("hermes") - if got := listed(hermes); got[refs[0]] { - t.Errorf("codex used only through routing groups: Hermes lists %s", refs[0]) + for _, id := range []string{"hermes", "workbuddy", "claude", "codex"} { + a, _ := agent.Find(id) + got := listed(a) + for _, ref := range refs { + if !got[ref] || !got["group/mygpt"] { + t.Errorf("its models too: %s's list %v lacks %s or the group", id, got, ref) + } + } } } diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index 14dfc0ce8..87f357ffb 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -5207,7 +5207,7 @@ function routingPage(part) { const LIST_OPTS = [["", "Its models too"], ["unlists", "The group alone"]]; const LIST_HINT = { "": "Agents' model lists and the gateway's /v1/models show the group and each of its models.", - unlists: "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.", + unlists: "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered.", }; const SINK_HINT = { "": "One rate limited while it still has quota rests as long as the vendor asks, then takes its place in the order again.", diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.js index f14cf807b..010ffd015 100644 --- a/internal/gui/assets/plugins/routing/i18n.js +++ b/internal/gui/assets/plugins/routing/i18n.js @@ -189,7 +189,7 @@ magpie.strings({ "The group alone": "只列出本组", "Its models unlisted": "成员模型不单独列出", "Agents' model lists and the gateway's /v1/models show the group and each of its models.": "Agent 的模型列表和网关的 /v1/models 会列出本组,也列出组里的每个模型。", - "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.": "Agent 的模型列表和网关的 /v1/models 只列出本组,不列出它点名的模型和模式匹配到的模型:这些模型通过本组使用。已登录订阅的模型仍留在 Agent 的列表里。直接点名其中一个模型的请求仍会被应答。", + "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered.": "Agent 的模型列表和网关的 /v1/models 只列出本组,不列出它点名的模型和模式匹配到的模型:这些模型通过本组使用。Codex 仍列出它所登录的 ChatGPT 账号自己的模型。直接点名其中一个模型的请求仍会被应答。", "Slow to start": "迟迟不出字", "Every member busy": "成员全都忙", "When every member has failed with an error that may pass — overloaded, unavailable, rate limited for a moment — and nothing of the reply has reached the agent, each is asked again after a pause, longer each time and never shorter than the vendor asks, for up to {n} more. A streaming agent is kept waiting meanwhile.": "每个成员都因暂时性错误(过载、暂不可用、短暂限流)失败,而回复还一点都没到智能体时,过一会儿依次再问一遍每个成员,间隔一次比一次长,也不短于厂商要求的等待,最多再等 {n}。流式请求的智能体在此期间会一直被保持等待。", @@ -854,7 +854,7 @@ magpie.strings({ "The group alone": "只列出本組", "Its models unlisted": "成員模型不單獨列出", "Agents' model lists and the gateway's /v1/models show the group and each of its models.": "Agent 的模型清單和閘道的 /v1/models 會列出本組,也列出組裡的每個模型。", - "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.": "Agent 的模型清單和閘道的 /v1/models 只列出本組,不列出它點名的模型和模式比對到的模型:這些模型透過本組使用。已登入訂閱的模型仍留在 Agent 的清單裡。直接點名其中一個模型的請求仍會被回應。", + "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered.": "Agent 的模型清單和閘道的 /v1/models 只列出本組,不列出它點名的模型和模式比對到的模型:這些模型透過本組使用。Codex 仍列出它所登入的 ChatGPT 帳號自己的模型。直接點名其中一個模型的請求仍會被回應。", "Slow to start": "遲遲不出字", "Every member busy": "成員全都忙", "When every member has failed with an error that may pass — overloaded, unavailable, rate limited for a moment — and nothing of the reply has reached the agent, each is asked again after a pause, longer each time and never shorter than the vendor asks, for up to {n} more. A streaming agent is kept waiting meanwhile.": "每個成員都因暫時性錯誤(過載、暫不可用、短暫限流)失敗,而回覆還一點都沒到智慧體時,過一會兒依序再問一遍每個成員,間隔一次比一次長,也不短於廠商要求的等待,最多再等 {n}。串流請求的智慧體在此期間會一直被保持等待。", @@ -1497,7 +1497,7 @@ magpie.strings({ "The group alone": "グループだけ", "Its models unlisted": "メンバーは一覧に出さない", "Agents' model lists and the gateway's /v1/models show the group and each of its models.": "エージェントのモデル一覧とゲートウェイの /v1/models に、グループとその各モデルが並びます。", - "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.": "エージェントのモデル一覧とゲートウェイの /v1/models にはグループだけが並び、指定したモデルやパターンに合うモデルは出ません。これらはグループを通して使われます。サインイン済みのサブスクリプションのモデルはエージェントの一覧に残ります。モデルを名指しするリクエストには引き続き応答します。", + "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered.": "エージェントのモデル一覧とゲートウェイの /v1/models にはグループだけが並び、指定したモデルやパターンに合うモデルは出ません。これらはグループを通して使われます。Codex にはサインインしている ChatGPT アカウント自身のモデルが残ります。モデルを名指しするリクエストには引き続き応答します。", "Slow to start": "応答開始が遅いとき", "Every member busy": "全メンバーが混雑", "When every member has failed with an error that may pass — overloaded, unavailable, rate limited for a moment — and nothing of the reply has reached the agent, each is asked again after a pause, longer each time and never shorter than the vendor asks, for up to {n} more. A streaming agent is kept waiting meanwhile.": "すべてのメンバーが一時的なエラー(過負荷、利用不可、短時間のレート制限)で失敗し、応答がまだエージェントに何も届いていないときは、少し待ってから各メンバーに順に聞き直します。待ち時間は回ごとに長くなり、ベンダーが求める待ち時間より短くはなりません。さらに最大 {n} まで続けます。ストリーミングのエージェントはその間待たせたままにします。", @@ -2152,7 +2152,7 @@ magpie.strings({ "The group alone": "Nur die Gruppe", "Its models unlisted": "Modelle nicht gelistet", "Agents' model lists and the gateway's /v1/models show the group and each of its models.": "Die Modelllisten der Agenten und /v1/models des Gateways zeigen die Gruppe und jedes ihrer Modelle.", - "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.": "Die Modelllisten der Agenten und /v1/models des Gateways zeigen die Gruppe, nicht die Modelle, die sie nennt oder deren Muster passen: Sie werden über die Gruppe genutzt. Die Modelle eines angemeldeten Abos bleiben in den Listen der Agenten. Eine Anfrage, die eines davon nennt, wird weiter beantwortet.", + "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered.": "Die Modelllisten der Agenten und /v1/models des Gateways zeigen die Gruppe, nicht die Modelle, die sie nennt oder deren Muster passen: Sie werden über die Gruppe genutzt. Codex behält die eigenen Modelle seiner ChatGPT-Anmeldung. Eine Anfrage, die eines davon nennt, wird weiter beantwortet.", "Slow to start": "Langsamer Start", "Every member busy": "Alle Mitglieder ausgelastet", "When every member has failed with an error that may pass — overloaded, unavailable, rate limited for a moment — and nothing of the reply has reached the agent, each is asked again after a pause, longer each time and never shorter than the vendor asks, for up to {n} more. A streaming agent is kept waiting meanwhile.": "Sind alle Mitglieder mit einem vorübergehenden Fehler gescheitert – überlastet, nicht verfügbar, kurz ratenbegrenzt – und hat den Agenten noch nichts von der Antwort erreicht, wird jedes nach einer Pause erneut gefragt, jedes Mal länger und nie kürzer, als der Anbieter verlangt, bis zu {n} lang. Ein streamender Agent wird so lange hingehalten.", diff --git a/internal/gui/tests/group-unlists.test.cjs b/internal/gui/tests/group-unlists.test.cjs index 2621e14da..ca74fb466 100644 --- a/internal/gui/tests/group-unlists.test.cjs +++ b/internal/gui/tests/group-unlists.test.cjs @@ -52,7 +52,7 @@ function serve(lang, posts) { } const H0 = "Agents' model lists and the gateway's /v1/models show the group and each of its models."; -const H1 = "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. A signed-in subscription's models stay in agents' lists. A request naming one is still answered."; +const H1 = "Agents' model lists and the gateway's /v1/models show the group, not the models it names or its patterns match: they are used through it. Codex keeps its ChatGPT sign-in's own models. A request naming one is still answered."; const KEYS = ["Model lists", "Its models too", "The group alone", "Its models unlisted", H0, H1, "Edit", "Save"]; const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); diff --git a/internal/provider/models.go b/internal/provider/models.go index 46732ef0a..2e8846dbb 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -2823,29 +2823,27 @@ type Entry struct { // provider not kept unlisted. A provider switched off has none in it. func Catalog() []Entry { return catalogKeeping(nil) } -// catalogOf is the catalog agent's lists start from: Catalog, with the -// models of the user's signed-in subscriptions (SubscriptionKept) that a -// group listing alone (Group.Unlists) keeps out of it. A group is added -// on top of what the agents had: switching one on that names a ChatGPT -// account's GPT models took its Codex section out of every agent's list, -// Hermes Agent's and WorkBuddy's among them, and switched off they were -// back (士奇 on Discord, a third time: a3ee00c05 kept them in Codex's list -// alone). The gateway's /v1/models for a client that is no agent ("") -// still lists the group alone, as #1783 asked. +// catalogOf is the catalog agent's lists start from: Catalog, and for +// Codex the ChatGPT accounts' own models as well when they are kept out +// of the lists, the codex provider used only through routing groups +// (Provider.Unlisted) or a group listing alone (Group.Unlists). Codex +// reaches those on its own sign-in, its app lists them from the ChatGPT +// backend, and keeping them for routing groups is about magpie's offer to +// the other agents and /v1/models: Codex's list kept no Codex section, so +// the app lost GPT while Codex's picker still offered it (士奇 on +// Discord). The user takes them out of Codex's list there (HiddenModels, +// PickedModels), which the gateway follows (CodexNativeHidden). // -// For Codex, the ChatGPT accounts' own models are kept too when the -// codex provider is used only through routing groups (Provider.Unlisted): -// Codex reaches those on its own sign-in, its app lists them from the -// ChatGPT backend, and the codex provider's switch is about magpie's -// offer to the other agents and /v1/models. The user takes them out of -// Codex's list there (HiddenModels, PickedModels), which the gateway -// follows (CodexNativeHidden). +// Every other agent is given Catalog: a group listing alone keeps a +// signed-in subscription's models out of its list too, as the option +// says. 88e6fb9cf kept them for every agent, so for a group made of +// subscription models, as most are, listing the group alone changed nothing +// an agent was listed (shaoyang. on Discord, 11-03). func catalogOf(agent string) []Entry { - if agent == "" { + if !strings.EqualFold(agent, "codex") { return Catalog() } - codex := strings.EqualFold(agent, "codex") - return catalogKeeping(func(e Entry) bool { return SubscriptionKept(e) || codex && CodexOwn(e) }) + return catalogKeeping(CodexOwn) } // CatalogOf is the catalog agent's lists start from, before its @@ -2853,15 +2851,6 @@ func catalogOf(agent string) []Entry { // be given by name. func CatalogOf(agent string) []Entry { return catalogOf(agent) } -// SubscriptionKept reports whether e is one of a signed-in subscription's -// own models (a ChatGPT, Claude, Copilot or plugin account's) that only a -// group listing alone could keep out: such a group doesn't take it from -// the agents' lists. A provider the user keeps for routing groups itself -// (Provider.Unlisted, "Only through routing groups") still keeps it out. -func SubscriptionKept(e Entry) bool { - return e.Group == "" && e.Provider.Account != nil && !e.Provider.Unlisted -} - // catalogKeeping is Catalog with the unlisted models keep says, too. func catalogKeeping(keep func(Entry) bool) []Entry { entries := providerEntries() @@ -2908,8 +2897,7 @@ func unlistedByGroups(entries []Entry) map[string][]string { // GroupKept is the models, by "provider/model", that a group listing // alone (Group.Unlists) keeps out of agents' lists, with those groups' // names: a provider's editor names them, as a model its own switch put -// back for agents is still left out by them. A signed-in subscription's -// models, which agents keep (SubscriptionKept), aren't among them. +// back for agents is still left out by them. // Held as MemberGroups is: shared, only for reading. func GroupKept() map[string][]string { return heldFrom("group-kept", providerEntries(), groupKeptIn) @@ -2922,7 +2910,7 @@ func groupKeptIn(entries []Entry) map[string][]string { } out := map[string][]string{} for _, e := range entries { - if gs := kept[e.ID]; len(gs) > 0 && !SubscriptionKept(e) { + if gs := kept[e.ID]; len(gs) > 0 { out[e.ID] = slices.Clone(gs) } } @@ -2942,14 +2930,13 @@ func Served() []Entry { // Unlisted are the models Served has and agents aren't offered: those of // the providers kept for routing groups (Provider.Unlisted), and those a -// group keeps out of the lists (Group.Unlists) but a signed-in -// subscription's, which agents keep (SubscriptionKept). +// group keeps out of the lists (Group.Unlists). func Unlisted() []Entry { var out []Entry entries := providerEntries() kept := unlistedByGroups(entries) for _, e := range entries { - if e.Provider.Unlisted || len(kept[e.ID]) > 0 && !SubscriptionKept(e) { + if e.Provider.Unlisted || len(kept[e.ID]) > 0 { out = append(out, e) } }