diff --git a/docs/reference.md b/docs/reference.md index cff86e868..f1ce2f652 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -1526,6 +1526,9 @@ 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. 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 6f7c410b1..6ea4ae0b5 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -234,7 +234,7 @@ recorded as a prediction failure (`noPrediction`). - A relayed Chat stream's tool call fragment with no `index` (none, or null) is given its call's (`streamCallIndexes` in [`chattidy.go`](../../internal/gateway/chattidy.go), #3386). Gemini's OpenAI-compatible API sends its calls with none, where the OpenAI contract has one on every fragment: the AI SDK's OpenAI provider (Cursor's Private Inference) turned the chunk away ("expected number, received undefined" at `tool_calls[0].index`), and OpenAI's node SDK's stream helper kept no call at all. A fragment with an id other than the open call's, or after the first in its delta, is the next call; any other goes on with the open one. So two calls in chunks of their own are 0 and 1, never both 0, which that helper merges into one call. A fragment with an index keeps it. `TestChatTidyGivesCallsAnIndex` in [`chattidy_test.go`](../../internal/gateway/chattidy_test.go), `TestGeminiCompatRelayedCallsHaveAnIndex` in [`gemini_compat_cut_test.go`](../../internal/gateway/gemini_compat_cut_test.go). - 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). -- 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`). 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 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`). - 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. - Claude signs a thinking block for the conversation and the account it was made in. When an Anthropic upstream answers 400 that a block's signature is invalid, "bound to a different conversation" or "not created in this conversation" (`boundRefusal`: a conversation moved between accounts or providers, or a relay that serves Claude from several accounts of its own; ferock on Discord, through Command Code's plugin), `forward` asks once more without the block it names (`messages..content.`) and every thinking block after it, whose signatures cover it, and remembers those signatures for that provider and account (`refuseBoundThinking`, `withoutRefusedThinking` in [`thinking_bound.go`](../../internal/gateway/thinking_bound.go)), so the conversation's later turns go without them the first time. Every route to an Anthropic upstream (relayed, translated, a plugin's fetch, count_tokens) passes there. Blocks before it, other providers and accounts, and every other refusal (DeepSeek's wanting its thinking back among them) are left as they are. magpie doesn't send the `thinking-binding-controls` beta's `drop_block` for an agent. `TestBoundThinkingLeftOut`, `TestPluginBoundThinkingLeftOut`, `TestOtherRefusalKeepsThinking`. diff --git a/internal/gateway/desktop.go b/internal/gateway/desktop.go index bae4086bf..022180201 100644 --- a/internal/gateway/desktop.go +++ b/internal/gateway/desktop.go @@ -425,7 +425,10 @@ func aliased(id string) (string, bool) { if len(number) != 10 { return "", false } - for _, e := range provider.Catalog() { + // 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) + 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 469576d44..4eaaecbbb 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -1339,7 +1339,10 @@ 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")) - shown := keyAllowed(r, provider.Catalog()) + // 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 + shown := keyAllowed(r, provider.CatalogOf(agentOf(r))) for _, e := range shown { if e.ID == id || e.Group != "" && provider.SameRef(e.ID, id) { if agentOf(r) == ScienceID { diff --git a/internal/gui/agent_models_codex_group_test.go b/internal/gui/agent_models_codex_group_test.go index 5e1e3fbcd..41d19c1f0 100644 --- a/internal/gui/agent_models_codex_group_test.go +++ b/internal/gui/agent_models_codex_group_test.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "slices" + "strings" "testing" "time" @@ -107,10 +108,10 @@ func codexSignedInSandbox(t *testing.T) []string { return ids } -// 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 供应商和对应模型,在下拉 +// 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 供应商和对应模型,在下拉 // 选项中虽然能显示 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. @@ -158,7 +159,10 @@ 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) } - check("group lists itself alone", "codex/gpt-5.5", "codex/gpt-5.4") + // 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") p, err := provider.Find("codex") if err != nil { t.Fatal(err) @@ -174,3 +178,103 @@ 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) { + ids := codexSignedInSandbox(t) + var refs []string + for _, id := range ids { + refs = append(refs, "codex/"+id) + } + listed := func(a *agent.Agent) map[string]bool { + out := map[string]bool{} + for _, m := range agentModelList(a) { + out[m.ID] = true + } + 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 { + t.Fatal(err) + } + checked := 0 + for _, a := range agent.All() { + got := listed(a) + if !got["group/mygpt"] { + continue // an agent shown no models of magpie's (or no groups) + } + checked++ + for _, ref := range refs { + if !got[ref] { + t.Errorf("group on: %s not in %s's list %v", ref, a.ID, got) + } + } + 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) + } + 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) + } + } + for _, id := range []string{"hermes", "workbuddy", "claude", "codex"} { + a, err := agent.Find(id) + if err != nil { + t.Fatal(err) + } + if !listed(a)["group/mygpt"] { + t.Errorf("%s's list wasn't checked: it has no group/mygpt", id) + } + } + 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 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 { + 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]) + } +} diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index 01b5ee098..9f5b38851 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -4816,7 +4816,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 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. A signed-in subscription's models stay in agents' lists. 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 885f6e346..040668899 100644 --- a/internal/gui/assets/plugins/routing/i18n.js +++ b/internal/gui/assets/plugins/routing/i18n.js @@ -169,7 +169,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 request naming one is still answered.": "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 的列表里。直接点名其中一个模型的请求仍会被应答。", "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}。流式请求的智能体在此期间会一直被保持等待。", @@ -772,7 +772,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 request naming one is still answered.": "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 的清單裡。直接點名其中一個模型的請求仍會被回應。", "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}。串流請求的智慧體在此期間會一直被保持等待。", @@ -1353,7 +1353,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 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. A signed-in subscription's models stay in agents' lists. A request naming one is still answered.": "エージェントのモデル一覧とゲートウェイの /v1/models にはグループだけが並び、指定したモデルやパターンに合うモデルは出ません。これらはグループを通して使われます。サインイン済みのサブスクリプションのモデルはエージェントの一覧に残ります。モデルを名指しするリクエストには引き続き応答します。", "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} まで続けます。ストリーミングのエージェントはその間待たせたままにします。", @@ -1946,7 +1946,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 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. 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. 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.", "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 73946dd01..a89a18935 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 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. A signed-in subscription's models stay in agents' lists. 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 2cfae4e96..c63376a0b 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -2546,21 +2546,43 @@ 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, 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). +// 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. +// +// 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). func catalogOf(agent string) []Entry { - if !strings.EqualFold(agent, "codex") { + if agent == "" { return Catalog() } - return catalogKeeping(CodexOwn) + codex := strings.EqualFold(agent, "codex") + return catalogKeeping(func(e Entry) bool { return SubscriptionKept(e) || codex && CodexOwn(e) }) +} + +// CatalogOf is the catalog agent's lists start from, before its +// visibility and picks narrow it (CatalogFor): every model that agent may +// 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. @@ -2612,15 +2634,16 @@ func Served() []Entry { }) } -// Unlisted are the models Served has and Catalog doesn't: those of the -// providers kept for routing groups (Provider.Unlisted), and those a group -// keeps out of the lists (Group.Unlists), which agents aren't offered. +// 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). func Unlisted() []Entry { var out []Entry entries := providerEntries() kept := unlistedByGroups(entries) for _, e := range entries { - if e.Provider.Unlisted || kept[e.ID] { + if e.Provider.Unlisted || kept[e.ID] && !SubscriptionKept(e) { out = append(out, e) } }