Commit Graph
138 Commits
Author SHA1 Message Date
yetone fdabddeb41 catalog: a list fetched again as it was tells no agent
The magpie serving the gateway fetches each signed-in account's list
again once it is 45 minutes old (KeepAccountsListed), and saveLive
called Touched after every save: Changed ran SyncCatalog, which built
and compared every agent's model lists, and Forget moved the stamp
dsh's rounds build magpie's models by, so they built them again too.
For a list that came back the same, all of it was for nothing.

Now saveLive compares what it is about to write with the file there,
but for the fetch time. The same list is written (the new time keeps
the next relist 45 minutes away) and its next read looks at the file
(filememo.Look, also under a request's hold); nothing else is told. A
list that differs in a model, a part (Sides) or what it was asked as
is told as before.

Measured on mote with a copy of the owner's real config and accounts,
network blocked, the claude account's list set 2h old so the relist
falls in the window (acidle.sh, alloc_space from 60s to 180s idle):
  v0.1.3416 (t5): 42.8 MB, SyncCatalog 27.7 MB, buildModels 8.9 MB
  first cut, Forget kept (t6): 28.8 MB, dsh rounds' buildModels 12.1 MB
  this (t7): 14.1 MB (4.7 MB of it the heap profile's own write),
    neither SyncCatalog nor buildModels in the profile; the claude
    list's fetched moved to the relist's time (06:18:52)
Without a relist due, idle was 7.8 MB before and after.

Test: TestLiveSavedAgainSameTellsNoAgent. Broken by hand: always
Touched (red: "changed 2, forgot 2; want 1, 1"), and no
filememo.Look (red: the held read keeps the old fetch time).

Run at this head on mote: go test -count=1 ./internal/catalog/
./internal/provider/ ./internal/agent/ ./internal/filememo/ ok; go vet
of internal/catalog native, GOOS=linux and GOOS=windows ok; gofmt -l
clean.

Not tried: an account whose list really changed in a running magpie
(the test covers a model, a window, a part and the asked version).
2026-11-09 22:26:48 +08:00
yetone 88b541a25c images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.

Run in the tree with this change and the rest of the audit's fixes
(mote, base cd0ba05c2):
- go vet ./internal/gui ./internal/gateway ./internal/agent
  ./internal/provider ./internal/settingsapi: ok
- go test -run 'Image|Draw|Video|Hidden|Group|Settings' ./internal/gui
  ./internal/gateway ./internal/settingsapi: ok; ./internal/imagemcp,
  ./internal/library, ./internal/catalog: ok
- GUI: i18n-keys, i18n-en-no-cjk, image-models-hide,
  library-browser-setup: pass in Chromium and WebKit
- gofmt -l: nothing
Not tried: a real agent reading the new MCP instructions (text only).
2026-11-09 21:51:53 +08:00
yetone 2b8ff0fbeb routing: an account's model list older than the model is unknown, not a plan without it
wudao_85256 on Discord: two ChatGPT Plus accounts on the Codex
subscription, each serving gpt-6.1-sol alone. With both on, Routing said
of the second "its plan doesn't list gpt-6.1-sol", and once the first ran
out of its allowance nothing failed over: an unlisted account is asked
only after a listing one refuses the model as unserved, never after a 429.
Re-adding the account and refreshing changed nothing.

Cause: the second account's own list (models/codex@<user>.json) was the
evidence, and it was stale. The ChatGPT backend lists gpt-6.1-sol only to
Codex 0.161.0 and later (dd12c75bf), and a saved account's list is asked
once a day, one account a look, for whatever codexVersion() was then (the
0.159.0 fallback before a Codex client has come through). Codex's own
account is asked every hour, so it gained the model and the saved one kept
a list without it for up to a day, every day the race went that way. A
refresh asks the saved lists only when they are a day old, and removing an
account leaves its list behind, so re-adding found the same list.

Fix, for every subscription that keeps each account's own list in the
catalog (Codex, Antigravity):
- catalog: a kept list records Since, when each model was first in it
  (carried from save to save; a list saved before counts from its fetch),
  and Asked, what it was asked as (LiveSince, LiveAsked, SaveLiveAsked).
- provider.AccountsFor: an account whose list lacks the model is left out
  only when that list can know the model: fetched after, or within
  listRound (10 minutes, one look) before, another account's list first
  had it, and, for ChatGPT, asked for the Codex magpie speaks
  as now (codexListBehind; a list with no version kept is behind). Else
  it is unknown, and routed over at its own place in the order
  (Account.listLags). A Free account's list fetched after the Plus one had
  the model still leaves it out (#520).
- codexFetchSaved asks a behind list at once, as one with no list, and
  one fetched more than listRound before another account's list first
  had a model (catalog.LiveNewest); either waits an hour after a failed
  try. Both Codex lists are kept with the version asked.

Not covered: plugin accounts (pluginLists) and Claude's entitlements keep
their lists elsewhere and are unchanged; API keys' per-key lists
(KeysFor) are unchanged. After the update every Codex list saved before
counts as behind until it is asked again (within the hour), so a Free
account beside a Plus one may be asked a Plus-only model in that time
and refuse it, as an unknown list should be.

Tested: TestStaleAccountListIsNotAPlanWithoutTheModel (two Plus accounts,
the second's list asked for 0.159.0 / with no version / fetched before the
first listed the model / the first's list from before Since: both routed;
fetched since, or in the same look, for this version: left out) is red
on the old AccountsFor, 4 of 6 subtests; its same-look subtest is red
with listRound taken out. TestBehindListAskedAgain is red with the behind
branch of codexFetchSaved taken out by hand, and
TestListOlderThanAnothersModelAskedAgain with the LiveNewest rule taken
out. TestLiveSinceCarriesOver. Without listRound,
TestCodexProviderListsEveryAccountsModels and
TestAntigravityPoolRoutesDiscoveredModels went red (a Free list fetched
moments before the Pro one counted as older than the model).
gofmt -l; go vet ./internal/catalog ./internal/provider ./internal/gateway
for darwin, linux and windows; go test ./internal/catalog ./internal/provider
ok on mote; go test -run 'Unlisted|Codex|Pool|Antigravity|Account'
./internal/gateway ok on mote.
Not tried: a real pair of ChatGPT accounts against the backend; the
version gating is the one dd12c75bf read from the backend's error.

Reported-by: wudao_85256 (Discord)
2026-11-09 18:13:08 +08:00
yetone 08a42c40ff provider: a Remote magpie's cards are passed on down a chain of magpies
yuyong_id (Discord) chains three magpies through Remote: magpie1 has a
Codex subscription, magpie2 uses magpie1, magpie3 uses magpie2. magpie2
showed magpie1's Codex card; magpie3 showed none.

Cause: since 8c71cd27f a magpie told only its own cards
(CachedCards kept From == "") and the receiver skipped any card it was
told with a From (remoteCards). So no card from a remote, of any
provider, reached a third magpie; Codex wasn't special. Antigravity and
DeepSeek showing at magpie3 means magpie2 has those accounts itself
(not checked with the reporter).

Fix:
- CachedCards passes on the cards it already holds from each Remote
  magpie (passedOnCards, from the 30s cache: it asks no remote, and a
  held remote's cards stay home).
- Each card told carries Via, the magpies (catalog.Self) it passed
  through; a receiver leaves out a card that comes back to it or has
  passed more than MaxVia magpies (catalog.Loops, the same rule as
  magpie_via for models).
- Refresh on a passed-on card ("m1/codex" at magpie2) goes to
  RefreshUsage, which asks that remote again, instead of a 400.
- Sibling: the status line (KeptQuotaReport, /v1/magpie/quotas?kept=1)
  read CachedCards too, so a magpie's own Remote cards were missing
  from it; now there.
- A held key still sees only own cards (quotaScope unchanged).
- Codex's resets stay with the magpie next door only, as before.
- catalog.Self becomes a func with SetSelfForTest, so one test process
  can play magpie2 and then magpie3.

Run on mote at b9cdac0c6 (rebased on origin/main 8a7f77cb7):
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build ./...: ok.
- New TestRemoteChainPassesOnCards (magpie1 fake -> this gateway as
  magpie2 -> magpie3 reading it: Codex, Antigravity, GLM plan and a
  DeepSeek balance arrive, named "Codex · M1 · M2", Via [m1 m2],
  refresh reaches magpie1, a looped card is dropped),
  TestKeptReportHasRemoteCards and the updated TestRemoteMagpieCards,
  with TestRemoteMagpie*, TestRemoteSelf, Quota* and TestCachedCards:
  ok; -race -count=3 on the new and changed ones: ok.
- On origin/main with only these tests (and the Via field / Self func
  they compile against): all three FAIL. magpie3 gets just the
  "nothing read on that magpie yet" stand-in for magpie2, the kept
  report is empty, and the third magpie's card is nil.
- Full suite (-tags nogui -timeout 45m ./... under the suite lock):
  cut short when mote closed the connection, before any package
  reported. Rerunning at the pushed head.
- Rebased again onto origin/main e0f6eda64 (gateway changed): go vet
  of gateway, provider and catalog and the same targeted tests: ok on
  Linux (wsl-run magpie-desktop, -tags nogui); mote was refusing ssh.

Not tried: three real magpies on separate machines.
Not changed: a passed-on card's quota history (#5747).

Reported-by: yuyong_id (Discord)
2026-11-09 12:47:12 +08:00
yetone bca122bf90 catalog: a router's id (auto, free, default) is no one model
models.dev lists several vendors' routers under one bare id: openrouter/auto,
model-oracle-ai's auto, trustedrouter/auto, kilo-auto/free, openrouter/free…
bareID merged them into one "auto" and voted their levels, images and
window onto it, so every provider's own "auto" borrowed them. The 豆包工作
plugin's auto (Doubao picks the model) got reasoning_levels
none/low/medium/high, and pi's models.json a thinkingLevelMap for it.

vote now skips auto, default and free. A provider's own list (ListedBy)
still says what its router does. fast and balanced are routers too
(trustedrouter, Kilo) but stay voted: a vendor may name a real model so,
and TestNamedAvoidsCollisions / TestPickedNamesAvoidCollisions hold such
a "fast".

Run (mote, at 4f3ec591a + this):
- go test ./internal/catalog/ ./internal/provider/: ok (final set).
- go test ./internal/agent/ ./internal/gateway/ -timeout 45m: ok, with
  fast and balanced still in the set; not run again after narrowing it.
- GOOS=linux / GOOS=windows go vet ./internal/catalog/: ok. gofmt clean.
- Broken by hand (`if false && routerIDs[who]`):
  TestRenameNeverTakesAModelForAnother red, "auto took a router's:
  efforts [none minimal low medium high xhigh max], context 2000000,
  images true".
- Sandbox HOME with doubao-work 0.1.1 signed in: /v1/models has
  doubao-work/auto with reasoning_levels [], and `magpie pi
  doubao-work/auto` writes it to pi's models.json with no thinkingLevelMap.
Not tried: the full ./... suite, the GUI suite.
2026-11-09 07:32:58 +08:00
yetone 30b7a17326 codex: a relay's dated or renamed GPT id keeps its xhigh, max and Ultra levels
Found while looking into maomao_00001's report on Discord: the Windows
Codex app offered no xhigh or Ultra for a relay's model. Their relay
(vip.aipro.love, ids from its public /api/pricing) names its 31 models
plainly, and every one already got its full levels in
magpie-models.json before this change and gets the same after it, so
this is not their fix. Exact ids (gpt-6.1-sol, openai/gpt-6.1-sol)
were fine; two spellings other relays use were not:

- OpenAI's dated snapshot id (gpt-6.1-sol-2026-09-29) was unknown to
  the catalog, so it got the low/medium/high fallback. borrowedEfforts
  now drops a dated suffix and takes the base model's levels.
- A relay's rename (codex-gpt-6.1-sol, "[A] gpt-6.1-sol", an id the
  user marked the same as gpt-6.1-sol) got the levels up to max but no
  Ultra, because OffersUltra matched exact ids only. It now matches
  through catalog.IsOneOf, the lookup ContextOf and EffortsOf use.

Only known models change: a dated id whose base is unknown
(model-x-2026-01-01) keeps low/medium/high, a dated Luna gets its own
levels without Ultra, and glm-5.3-flash keeps [low high max].

Not changed: a dashed-date id's window and price are still unknown,
because catalog.SameModel doesn't strip that date form (#5643).

Run:
- TestCodexCatalogRelaysKnownModelsLevels red on the old code (the
  dated Sol and Luna at [low medium high], three renames without
  ultra), green with the fix.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and builds on mote.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/agent ./internal/codexcat on mote: all ok.
- The relay's 31 ids put through codex's Set with the real
  models.dev file (a probe, not committed): the same levels on
  origin/main and with this change.
- Full suite: not finished. My probe runs reused the suite's copy
  on mote, so it was stopped; it runs again after the push.

Refs: maomao_00001 (Discord)
2026-11-08 02:37:42 +08:00
yetone 37c1bc043b agent: a group whose members all serve Responses, one best there, is asked on Responses
zyh6036 on X: several subscriptions that all serve the Responses API were
asked on Chat once they were put in a routing group. Pi, OmO, omp, StepCode,
droid, dsh, Hermes, Grok CLI and the live agents ask each model on the one
API catalog.Model.APIs names, and a group had Responses only when every
member's Native was Responses (allResponses, #1594). A relay that serves
Chat and Responses, best on Chat (no Base URL API given, not OpenAI's own
host), counts as Chat there, so one such member put the whole group on
Chat, and the gateway then translated Chat to Responses for the ChatGPT,
Copilot GPT or Responses-relay members. Found groups (auto-<slug>) hit this
without the user doing anything: a new relay that also lists gpt-5.5 moved
auto/gpt-5.5 from openai-responses to Chat (pi_api_test shows it).

provider.GroupAPI now gives Responses when one member is best on Responses
and every other takes a Responses request as it is (Responses among the
APIs it relays), or translates every request anyway (a Claude Code
subscription). So no member is translated that Chat would have relayed,
and the ones best on Responses are relayed, not translated from Chat. The
gateway already relays a /v1/responses request to each member that serves
it (usable), so nothing changes there.

Mixed groups: a member that Responses doesn't reach (a Chat-only key, a
Messages-only Claude) keeps the group on Chat, where that member is
relayed; picking Responses there would translate it on every turn. A
Messages-only group stays on Chat as before (#1594's reason: a Claude
member's thinking is known by its own model id, not the group's).

An agent plugin's connect is told a group's native_endpoints now
(provider.GroupEndpoints: the APIs every member relays), where it had
none. /v1/models still leaves them out for a group:
TestRemoteMagpieNativeAPI holds that a remote magpie sends a group's
request on in the client's API for the other side to pick per member.

No setting added: the group's API follows from its members.

Run (mote, through mote-run):
- go test ./... -timeout 45m at 65780f04f on 49c9491b7, under the shared
  lock: every package ok except three reds, all filed and not in this
  change's path: internal/gateway TestBurstTellsNoSpeed/
  responses_from_chat_burst (passes 3 of 3 alone; #2719, commented),
  internal/gui TestMainWindowCorners/macOS_26_SDK (#3949), internal/provider
  TestRenewLoginsKeepsClaudeReading (red alone too; #5481, on main).
- After rebasing on fcc0daa23: go test ./internal/agent ./internal/catalog,
  ./internal/provider -run 'TestGroupAPI|TestNative|Group',
  ./internal/gateway -run 'Group|RemoteMagpie'; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; gofmt -l
  empty.
- Broken by hand: GroupAPI put back to "every member best on Responses":
  TestGroupAPI red (one best there plus one serving it too; the same
  second), TestPiModelsAskedOnTheirNativeAPI red (group/subs, and
  auto/gpt-5.5 once a Chat-first relay serves gpt-5.5).
- New: TestGroupAPI (provider), TestGroupOfResponsesServersRelaysOnResponses
  (gateway: the Chat-first member is asked on /responses, relayed).

Not tried: the reporter's own providers (not known: which subscriptions,
which agent); a real Pi or dsh run against a real mixed-API group; the GUI
(unchanged).
2026-11-06 19:07:15 +08:00
yetone f86dd7910a openrouter: list every image model from its Image API, and draw them there
iwinux on Discord: the OpenRouter image picker listed only Nano Banana,
GPT-5.4 Image 2, GPT-5 Image and GPT-5 Image Mini, and asked whether the
protocol was the reason. It wasn't. OpenRouter's GET /api/v1/models lists
only models whose output includes text (454 rows on 2026-11-06, 13 of them
with image output), and that was the only list magpie read. The models
that answer in images alone (FLUX, Seedream, Riverflow, Recraft, GPT
Image, Krea, MAI Image, Qwen Image, Grok Imagine, Hunyuan, Muse) are at
its Image API's GET /api/v1/images/models (63 rows, no key needed), and
every one of them is served by POST /api/v1/images, which magpie already
spoke for FLUX/Seedream/GPT Image ids.

- catalog: openrouter.ai's public drawer list is /images/models; each row
  becomes a drawer with its output modalities, release date, name without
  the "Vendor: " prefix, and image input when it takes one.
- gateway: a model that answers in images only goes to /images, so
  Recraft, Riverflow, Krea, MAI, Muse and Hunyuan (ids ImagesAPI doesn't
  know) no longer go to chat completions. A pixel size is sent as
  aspect_ratio plus resolution (2K/4K by the long side), since no
  /images endpoint lists size and Riverflow refuses one: a real request
  with "size":"1024x1024" got 400 "Sourceful V2 does not support explicit
  pixel sizes. Use resolution and aspect_ratio instead." A ratio goes as
  aspect_ratio; anything else (auto) as size.
- Recraft's vector models answer image/svg+xml: saved as .svg in the
  gateway and in the image MCP (its sibling extOf).

Not listed: openrouter/auto (a router that may answer with an image).
krea/k3-edit is listed but only edits. Image prices are not imported
(OpenRouter prices per image per endpoint). Existing users see the new
models after their next model-list fetch.

Run (mote, at this tree):
- go test -count=1 ./internal/provider/ ./internal/catalog/ ./internal/imagemcp/: ok
- go test -count=1 -run 'Draw|Image|OpenRouter|ViaFor|Aspect|Drawer' ./internal/gateway/: ok
- gofmt -l internal: nothing; go vet of the four packages for darwin,
  GOOS=linux and GOOS=windows: ok
- Real: the worktree's binary in a sandbox HOME (magpie-wt/orimg-scratch,
  only the owner's OpenRouter provider copied in), serve on 127.0.0.1:3471,
  magpie sync: "openrouter (405)" and 63 drawers in its live list,
  Riverflow, Recraft, FLUX, Krea, MAI among them. POST
  /v1/images/generations openrouter/sourceful/riverflow-v2-fast at
  1024x1024: a 1024x1024 WebP back (27KB, 4175 output tokens).

Broken by hand: without the /images/models catalog entry,
TestOpenRouterImageModelsComeFromItsImageAPI fails ("/images/models asked
0 times"); sending size as given, TestOpenRouterImageOnlyModelsDrawAtItsImageAPI
fails (size 1024x1024 sent, aspect_ratio missing).

Not tried: a real draw with Recraft vector (SVG), Krea, xAI or MAI
through magpie; the GUI picker itself with the longer list; Windows and
Linux runs of the tests (vet only).

Reported-by: iwinux
2026-11-06 11:58:35 +08:00
yetone e17c6976b2 provider: Voyage AI preset, its embedding and rerank models (heatonz on Discord)
heatonz on Discord asked for Voyage AI, its embeddings and rerank. The
gateway already had /v1/embeddings and /v1/rerank; what was missing was
a way to add Voyage and have its models found there.

- presets.go: `voyage`, a vendor with an API key at
  https://api.voyageai.com/v1 (docs.voyageai.com, keys at
  dashboard.voyageai.com). Voyage has no /models, so it is NoList and
  the preset names its models in two new PresetDef fields, Embeddings
  (voyage-4-large, -4, -4-lite, code-4, finance-2, law-2, 3-large, 3.5,
  3.5-lite, code-3, code-2) and Rerankers (rerank-3, -3-lite, 2.5,
  2.5-lite), as Voyage's docs list them on 11-06. Region gets
  Rerankers too.
- models.go: planMedia marks each plan model with what it serves
  (catalog.Model.Serves), falls back to the preset's own lists when the
  provider has no region, and PlanRerankers / PlanRetrieval(kind) sit
  beside PlanEmbeddings. A NoList provider's ListAll has them too,
  marked, so catalog.Chat keeps them out of agents' lists, keys and
  Routing's chat pickers.
- gateway: resolveRetrievalModel and servesKind look up the kind asked
  for (PlanRetrieval(kind)) and not only embeddings. Before this, a plan's
  embedding model named on /v1/rerank was sent there, and a plan's
  reranker was never found.
- catalog.ServesOf: `voyage-*` is an embedding model (its ids have no
  "embed"), so Test, detection and a relay serving voyage ids know it.
- test.go / gui providers.go: the retrieval-only Test fallback and the
  editor's "retrieval" count read PlanRetrieval as well.
- docs/reference.md: a new "Embeddings and rerank" section with both
  routes' bodies (OpenAI's for embeddings; the Cohere/Jina/Voyage shape
  for rerank, top_n or top_k) and the Voyage preset. READMEs and the
  import docs pages (en, ja, zh) list it.

Not served: Voyage's contextualized and multimodal embeddings (their own
endpoints). A Voyage 4xx comes back as its raw {"detail": ...} body with
its status (errorSaid has no "detail" reader).

Tests (no network; a fake built from Voyage's documented request and
reply shapes): TestVoyageEmbeddingsAndRerank (bare and provider ids,
input_type/output_dimension and top_k/return_documents passed on, usage
total_tokens recorded), TestVoyageModelsStayOnTheirRoutes,
TestVoyageRefusalSaysWhy, TestVoyagePreset,
TestVoyageTestAsksItsRetrievalAPIs, TestServesOf's voyage cases.

Run on mote: go test -count=1 -timeout 45m ./internal/provider
./internal/catalog ./internal/gui ./internal/gateway. provider, catalog
and gateway ok. gui has one red, TestMainWindowCorners/macOS_26_SDK,
which is #3949 (red on macOS 27); this change doesn't touch AppKit.
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... ok. gofmt -l clean.

Broken by hand:
- resolveRetrievalModel/servesKind back on PlanEmbeddings:
  TestVoyageEmbeddingsAndRerank red (rerank-3: 404 "magpie knows no
  model"), TestVoyageModelsStayOnTheirRoutes red (voyage-4 on /v1/rerank
  answered 200).
- the voyage- prefix out of ServesOf: TestServesOf and TestVoyagePreset
  red.

Not tried: against the real API. No Voyage key was available, so the
endpoints, auth and shapes come from Voyage's docs alone. Not tried in
the GUI's Add sheet by hand, and not on Windows or Linux beyond vet.
2026-11-06 10:17:08 +08:00
ggbdpq 72e09cc019 catalog: a list's sora ids are video models, made at its OpenAI-shaped videos API (#4954)
What changed: a fetched model list keeps an id naming a video model the
way it keeps one that draws (FilmsID: sora-2, sora-2-pro). OpenAI's list
marks no kind, and textModel counts sora out of the chat models, so a
Sora model was never listed at all: the provider editor could not mark
it a video model, and startVideo answered 400 "can't make videos". A
sora id now reaches the list as Films - a video model of the provider,
asked at its OpenAI-shaped videos API, which the gateway already speaks
- and is still no chat model. The other video families keep the faces
their own APIs are asked on: Ark's Seedance at its tasks, a MiniMax
key's H3, and a model the user says makes videos (#1399).

Run:
- go test ./internal/gateway -run TestOpenAIKeySoraMakesVideos -count=1
  RED before (videomakers [] - the list carried no sora model), green
  after: sora-2 and sora-2-pro are the provider's video models, a video
  is started, polled and fetched at its /v1/videos, and neither id is
  among the chat models.
- TestCustomProviderMakesVideos, TestCustomProviderVideoNeedsTheListsWord,
  TestCustomProviderVideoTheUserMarks green, the last two with the
  fixture's unmarked model renamed to agnes-video-2.5-flash (#1399's own
  case): a name alone still makes no video model, even one with "video"
  in it.
- go test ./internal/catalog, the video family with -race, gofmt,
  go vet -tags nogui, builds (darwin, linux, windows): clean.

Reviewed and ported (on origin/main 1b0340fdb, cherry-picked clean;
main's Seedance-at-Ark commits 93060c98d and 5bd1aee63 cover Ark's
Domain/modalities faces only, and nothing on main lists sora):
- mote: TestOpenAIKeySoraMakesVideos, TestCustomProviderMakesVideos,
  TestCustomProviderVideoNeedsTheListsWord and
  TestCustomProviderVideoTheUserMarks green. With catalog.go and
  live.go put back to main, TestOpenAIKeySoraMakesVideos is red:
  "video_sora_test.go:70: videomakers []".
- The two existing tests' "sora-like-2" fixture is renamed to
  agnes-video-2.5-flash, since a sora id is now a video model by name;
  they still hold that a name alone makes no video model.
- mote: go test -tags nogui ./internal/catalog ok; -timeout 45m
  ./internal/gateway ok; vet darwin/linux/windows ok; gofmt -l clean.
Not tried: a real OpenAI key's Sora video (the upstream is httptest).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Generated-by: GLM-5.3-Flash (ZCode)
2026-11-05 18:31:17 +08:00
yetone a732f3c493 gateway: models of one API other than chat are grouped by id on their route (#5339)
XYenon (Discord) has the same embedding model at several providers and
asked why it isn't grouped the way chat models are. It wasn't even
listed: a fetched list dropped every embedding, rerank, speech and
transcription model, so "embed-1" on /v1/embeddings was a 404 unless a
hand-made group named it.

- catalog: a fetched list keeps those models, tagged with their API
  (Model.Serves, read from the id by ServesOf: rerank, embed/bge-,
  whisper/transcribe, tts-/-tts). Chat() and Live() leave them out, so
  agents' model lists, gateway keys and Routing's chat pickers never
  see them; LiveServing(id, kind) reads them. The live file says
  "kinded": true; a list fetched before this is fetched again once a
  run (autolist), with no schedule needed.
- provider: KindGroup(kind, ref) is made per request, never stored, so
  it is in neither Groups() nor Catalog(). Its id is
  auto-<kind>:<model> ("group/auto-embedding:embed-1"); its members are
  the providers that serve exactly that id for that API, in the order
  they were added, none off, decide-only, serving none, or with the
  model disabled.
- gateway: embeddings, rerank, speech, transcriptions and videos pick
  the group by route (mediaMembers): a bare id is a kind group when
  more than one provider serves it, the group's own id always; a
  hand-made group still works through offChatList. A group is of its
  own API: an embedding model's id on /v1/rerank is a 404.

Run at bd0f33828 + this change, on WSL magpie-desktop (mote was
running another session's full suite):
- go test -tags nogui -count=1 -timeout 45m ./internal/catalog
  ./internal/provider ./internal/gateway: ok, ok, ok (594s). The first
  run was red in three tests that held a fetched list to leaving its
  embedding model out (TestFetchArkMarksVideoModels,
  TestNvidiaModelScopeLiveList, TestTencentTokenHubList); they now hold
  it kept, tagged embedding, and out of catalog.Chat.
- 22 GUI files over the model lists and Routing pickers, both engines,
  every language (group-pick-drawers image-models-hide video-models-hide
  model-kind routing-kind agent-models agent-models-picker
  agent-model-groups agent-models-only-picked gateway-key-models
  gateway-key-groups group-from-model-add unlisted-models
  models-select-all-api provider-add-models provider-detect-models
  routing-rule-models panel-routing-pick fallback-group group-unlists
  settings-groups i18n-keys): 229 of 244 pass. The 15 reds are in six
  files that a control run of those six at bd0f33828 has red the same
  (14 of 56): #4389, #4964, #5332, #4616 and, new, #5357
  (routing-rule-models webkit 390). agent-models webkit zh's opacity
  0.998 was red here only, a fixed 250ms wait: #5358. No GUI asset is
  changed here; the GUI tests stub /api.
- on mote: TestProviderListBeforeSave (internal/gui; the add form's
  list keeps an embedding model out) and
  TestPiModelsAskedOnTheirNativeAPI (internal/agent), ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of catalog,
  provider and gateway on mote at this head, ok.

Rebased then on origin/main d620ff6b5 (one commit, internal/agent and
internal/sessions only), and b63b28958 (one mover min line) after; at
d620ff6b5 + this on mote: go build ./..., go vet
of catalog, provider, gateway, agent and sessions, go test
./internal/catalog and -run 'Kind|Fetch|Nvidia|Tencent|Serving' of
provider and gateway: ok.

Red on the old code: TestKindGroupsServeEachAPIByRoute (embed-1 404)
and TestVideoKindGroupByTheModelsID (404).
Broken by hand, each red, then restored:
- the fetch dropping serves != "" again: TestFetchKeepsModelsOfOtherAPIs;
- the once-a-run refetch forced off: TestKindlessListFetchedOnce;
- KindGroup's disabled-model check removed:
  TestKindGroupHoldsTheExactModel;
- LiveServing asked with "" (any kind): the rerank-by-embedding-id
  check gets 200 instead of 404.

Known gaps, not done here:
- The Routing group editor still offers only chat and image models, so
  a new hand-made group of different ids (bge-m3 / BAAI/bge-m3) can't
  pick kind models: #5352.
- A bare id whose every member is disabled is a 404, not a 403.
- Rerank, Qwen3-Embedding and bge models that sat among a provider's
  chat models before (textModel's words missed them) leave agents'
  lists now. A hand-made group naming one keeps serving.
- /v1/models lists no kind model; the Routing live view may show the
  raw kind id.
Not tried: real vendors' lists and routes; the full ./... suite at this
head (queued on mote after another session's run; reds get issues).
2026-11-05 16:22:31 +08:00
yetone 0e55a75936 remote magpie: a request that goes round magpies pointing at each other stops after 8, and a remote that is this magpie lists its models once
Follows c2c991a5b (cdredfox's two magpies each the other's remote).
hanslin1666 (Discord) has the sibling: device B uses device A through
a Remote magpie provider, and S3 sync carried that provider to A too,
so A has a Remote magpie pointing at itself. Sync carries every
provider (backup.Collect, provider.Mirror), a Remote magpie included.

Two holes c2c991a5b left:
- A remote that is this magpie lists this magpie's own models through
  this one alone ([self]); c2c991a5b kept any via of only self, so
  rem/own/m1, rem/rem/own/m1, ... still grew a level a fetch until
  MaxVia. A via naming this magpie is now taken only when it is
  exactly [self]: the remote's own models, once (what the gateway's
  in-process remote tests need, and what hanslin1666 sees today).
- Nothing stopped a request at request time: a list fetched from a
  magpie older than magpie_via, or one cached before the update,
  could still route round. Each request magpie passes to a Remote
  magpie now says how many magpies it went through (X-Magpie-Hops:
  the count it came with + 1, 1 for an agent's own); one that arrives
  having passed catalog.MaxVia (8) is answered 508 Loop Detected with
  what to turn off, before any vendor or remote is asked. The count is
  read only from a magpie's request (its User-Agent, which needs the
  key anyway), and taken off every request as it arrives, so no vendor
  is sent it. It goes on every path that already passes the caller on
  (passOnCaller: chat, decide, draw, embeddings, video).

Run (mote, at this tree on c2c991a5b):
- go test -timeout 45m ./internal/catalog ./internal/provider
  ./internal/gateway -count=1 on Linux (wsl-run, magpie-desktop):
  catalog ok, gateway ok (590s), provider red only in
  TestClaudeAccountServesModelsListedSinceItsFetch, #3174, which this
  doesn't touch.
- go vet, GOOS=linux and GOOS=windows go vet of catalog and gateway
  (mote): ok. gofmt -l clean.
- The full suite at c2c991a5b (mote, -timeout 45m ./...): 86 packages
  ok, internal/gui red only in TestMainWindowCorners (#3949).

Broken by hand:
- the via rule back to c2c991a5b's: TestFetchLeavesOutWhatCameFromHere
  red (rem/own/m2 through [self self] taken).
- no hops set in passOnCaller and no check in withCaller:
  TestRemoteMagpieRequestLoopStops red (the remote told [ ] passes,
  200 not 508 at 8, the vendor asked).

Not tried:
- hanslin1666's or cdredfox's own machines.
- Paths to a remote that don't go through passOnCaller (the Codex
  socket and native passthrough) don't count hops; a loop through
  them is still cut by the lists.
- Hiding a Remote magpie that is this magpie, or keeping it out of
  sync on the machine it names: not done here (a third machine that
  syncs may want it); it now costs one extra local pass per request
  to it, and its models show twice.
2026-11-05 10:52:06 +08:00
yetone c2c991a5b3 remote magpie: two magpies each the other's remote no longer list each other's models back without end
cdredfox (Discord) saw 100-200% CPU while magpie used a remote magpie
over Tailscale, gone with the remote off. Their providers mask anyway
and their agent asks auto/ ids, so the earlier unmasked-group lead
doesn't explain it. What does: when A and B are each other's remote,
A's /v1/models (to another magpie) lists rem/<B's models>, B fetches it
as back/rem/..., lists that back to A, and so on: one level deeper on
every 10-minute fetch, without end. Each level is another member of
the found auto/ group and another route round the two machines, masked
again on each pass. On mote, two sandbox magpies in that setup went
from A: [auto/m1 own/m1 rem/auto/m1 rem/up/m1 rem/back/own/m1] to
[... rem/back/rem/back/own/m1, rem/back/rem/auto/m1 ...] after one
more scheduled fetch, and B had back/rem/back/own/m1. A request on the
loop route (rem/back/own/m1) cost A 1.07s CPU over 10 turns against
0.69s for own/m1.

The list a magpie gives another magpie now names, as magpie_via, the
magpies each model passes through, itself last. Each process has a
random id (catalog.Self). A fetched list leaves out a model whose via
has this magpie and another one (it left here and came back), or more
than 8 magpies. A remote that is this magpie itself (via only this id,
as the in-process tests set up) is kept. A magpie older than this sends
no via, and its list is taken as before: both machines need the update.
Stamped on every list a magpie gives: models(), its deciders, and the
drawer and video lists. A routing group's via is its members'
together, so A's auto/m1 holding B's auto/m1 (which holds A's) is left
out at B, and requests no longer go A -> B -> A through groups.
What a user of A loses: B's own auto/ group of a model when it holds
A's model (it reaches A again); B's own models stay listed at A one by
one, and A's group of the model holds them. The cached list keeps Via, so a model a remote served
through others keeps its path in this magpie's list too.

Run (mote, at this tree on 6abacd46c = origin/main):
- go test -timeout 45m ./internal/catalog ./internal/provider
  ./internal/gateway -count=1: ok (catalog 0.7s, provider 120s,
  gateway 670s).
- go vet those three; GOOS=linux and GOOS=windows go vet: ok. gofmt -l
  clean.
- Two sandbox magpies (CLI, nogui build) each the other's remote:
  after two scheduled fetches (18:14, 18:24/18:25) A lists auto/m1,
  own/m1, rem/up/m1 and B auto/m1, up/m1, back/own/m1, each fetch
  taking 1 model; the old build in the same setup went 3 -> 5 models
  on B's second fetch and kept growing (rem/back/rem/back/own/m1).
- go test ./internal/gateway again after the group change: ok (715s).

Broken by hand:
- the loops check in live.go off: TestFetchLeavesOutWhatCameFromHere
  red (back/own/m1 with [self peer] and a 9-magpie model taken), and
  TestRemoteMagpieListLoopsNoMore red (the remote's back/own/m1 taken).
- models() without the magpie_via line: TestRemoteMagpieListLoopsNoMore
  red (own/m1 and rem/up/m1 listed through []).
- viaOf giving a group nil: red (auto/m1 listed through [self], not
  [peer self]).

Not tried:
- cdredfox's own two machines; it isn't confirmed yet that their remote
  also has this machine as its remote. If it doesn't, this isn't their
  cause.
- A loop through a magpie older than this one (no via: still grows
  until both are updated).
- The full suite (runs once after the push).
2026-11-05 10:26:14 +08:00
yetone 78128b5101 provider: a plugin's thinking model listed as, or the same as, another takes that model's levels (axelburks)
axelburks on Discord: a plugin's model that thinks and declares no
variants, set the same as and listed as claude-opus-5.5, took Claude Opus
5.5's price but showed its reasoning levels unknown, none ticked.

Cause: pluginCatalog borrowed levels for the plugin's own model id
(borrowedEfforts(m.ID)), which no catalog knows, so it got none; the
rename to the id the user lists it by (localIDs.list) then kept that
empty list. The price is looked up by the listed/same-as id, which is why
only the levels were missing.

Fix: a model whose levels were borrowed (catalog.Model.EffortsBorrowed,
set only in pluginCatalog's borrow) borrows them again for the id it is
listed by, which also follows the user's same-as. Levels the plugin's
own variants give stay first, and the levels the user kept narrow the
borrowed ones as before (effortsKept).

Test: TestPluginModelListedAsBorrowsLevels (listed as and same as one
id, listed by a name of the user's own, a model with variants of its
own, the price, and kept levels narrowing them).

Red on the old code: with the localid.go hunk reverted it fails with
"claude-opus-5.5 listed with levels [] ... want [low medium high xhigh
max]", the same for the gateway's p.Efforts and for my-opus.
Broken by hand: dropping the EffortsBorrowed set in plugins.go turns it
red (4 "want [low" errors). TestPluginThinkingModelBorrowsEfforts and
TestClinePluginBorrowsEfforts stay green.

Run on mote at this tree (on 7dd2434d3): go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...: ok. go test -count=1
-timeout 45m ./internal/catalog ./internal/provider ./internal/settings
./internal/cli: ok. ./internal/gui: two reds in files this change
doesn't touch, both filed: TestCoreScriptBudget (#5139, app.js budget;
no asset changed here) and TestMainWindowCorners/macOS_26_SDK on mote's
macOS 27 (#3949). No GUI file changes, so no GUI suite run.

Not tried: a real plugin account with such a model in the editor, and
the full suite before the push.
2026-11-04 19:16:10 +08:00
yetone 1a1ca0351b Revert "catalog: a listed model its id names a video model is one (agnes-video-2.5)"
This reverts commit b5b6cc573. It broke a rule #1399 set on purpose: a
model's name alone makes no video model, since magpie would then send
videos requests to a relay that may not serve them. A relay's video model
stays in the chat list until its list says "kind": "video" or the user
marks it Video in the provider editor, which needs the row there. The
full suite at b5b6cc573 (mote, go test -timeout 45m ./...) was red in
internal/gateway on TestCustomProviderMakesVideos,
TestCustomProviderVideoNeedsTheListsWord and
TestCustomProviderVideoTheUserMarks: sora-like-2, unmarked, became a
video maker and a /v1/videos request went out for it. I ran only
catalog, provider, agent and gui before pushing, not gateway.

Agnes's agnes-video-2.5 and -flash therefore stay among its chat models,
and the user marks them Video, as #1399 designed.

Run (mote, at this tree): go test ./internal/catalog and
go test -run 'TestCustomProvider' ./internal/gateway.
2026-11-04 18:38:32 +08:00
yetone b5b6cc5739 catalog: a listed model its id names a video model is one (agnes-video-2.5)
glorious_rabbit_30894 on Discord (#help): models of a custom provider
pointed at Agnes AI (apihub.agnes-ai.com/v1) "can't be added to an
agent". Agnes runs new-api; its /v1/models rows carry only id,
owned_by "custom" and supported_endpoint_types ["openai"], no kind,
domain or modalities. Nothing but the id tells agnes-video-2.5 and
agnes-video-2.5-flash from its chat models, and magpie had a name check
for image models (DrawsID) but none for video, so both were offered to
every agent as chat models, and never as video models.

FilmsID is DrawsID for videos (video, sora, veo, kling, seedance,
hailuo, vidu, runway, *-t2v/i2v/r2v; veo and kling only as a word of
their own, so inkling still chats). fetchPage marks a row a video model
by it when the list says no kind, no domain, no text output and the id
isn't an image model's. mendKinds applies the same to a list saved
before, so a fetched Agnes list is fixed on the first read, not the next
fetch. A model whose list says it answers in text is never moved.

Checked FilmsID against every id in models.dev's cache (~/.cache/magpie
models.json, 2026-11-04): every id it matches outputs video and no text,
except nvidia/synthetic-video-detector (a classifier, text out); video
models it misses are named for nothing it could know (ray2, minimax-h3,
gemini-omni), and their lists' modalities or a user's kind still mark
them.

Not the cause of the report, as far as can be told: with Agnes's real
list (testdata, fetched 2026-11-04) and models.dev's real cache, a
custom provider at .../v1, at the bare host, Anthropic or Responses
protocol, reaches Available, Exposed and Catalog with all four chat
models, and every agent's picker (claude, codex, opencode, pi, omp,
... 75 fields) lists them beside a relay's. The reporter says (#help 09:52) dsh, VS Code and Codex can't pick them,
with no error; that is not reproduced here and is asked for.

Run (mote):
- at this tree on origin/main 69eb93e0a: go test ./internal/catalog ok;
  go vet ./internal/catalog ./internal/provider for darwin, linux and
  windows ok; gofmt -l clean
- at the same change on 9595a503a: go test ./internal/provider
  ./internal/agent ok; ./internal/gui red only in TestCoreScriptBudget
  (#5139) and TestMainWindowCorners/macOS_26_SDK (#3949), both filed,
  neither in a file this touches
- sandbox HOME, Agnes's real list + models.dev's cache: Picks, Spell,
  Apply and Drift for codex, dsh, vscode, claude, opencode take
  agnes/agnes-2.5-flash with no error, and magpieModels for each lists
  the four chat models and, with this change, no video model
Broken by hand: live.go at HEAD with FilmsID kept: both Agnes tests red
(video models [] and listed as chat, saved list's too); green with it.
Not tried: a real Agnes key (none here); Agnes's video models asked at
/v1/videos (magpie's video path for a base URL) — whether Agnes serves
them there is unknown.
2026-11-04 18:10:35 +08:00
yetone 92d2ed74f9 providers: an Ark key's Seedance models are under Video models in its editor, each to tick
axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没
有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor listed its
Seedream models under Image models, to tick, and had its Seedance models
among the chat models or nowhere.

Cause, two parts:
- The editor had no video section at all: video models had no list and no
  hidden set (gateway-routing.md said "Video models aren't listed in the
  editor, so there is nothing to hide there").
- catalog's live parse read only "kind" and modalities.input/output. Ark's
  /api/v3/models marks no kind: it says domain "VideoGeneration" /
  "ImageGeneration" and modalities.input_modalities/output_modalities. So
  Seedance came back as a chat model, and 3D models (output 3d, no text)
  as chat models too.

Change:
- catalog: a live row with no kind is a video model when its domain is
  VideoGeneration or it outputs video without text, an image model for
  ImageGeneration or image without text; Ark's input_modalities /
  output_modalities are read when input/output aren't there, so a model
  that gives no text (Ark's 3D) is left out of the chat list.
  TestFetchArkMarksVideoModels runs on a captured Ark list
  (testdata/volcengine-ark-models-2026-11-03.json, fetched read-only
  with GET /api/v3/models, no key in it).
- provider: HiddenVideomakers beside HiddenDrawers, VideomakerHidden.
- gateway: VideomakersOf (Videomakers on a given list, for the editor),
  OfferedVideomakers = Videomakers less the unticked ones, read by
  AutoVideomaker, videomakerObjects (another magpie's list) and
  mediaModels(true) (generate_video). A hidden one still makes its video
  when named: bareVideomaker, videosCreate and arkFilms read Videomakers.
- gui: the editor's Video models section (renderVideomakers), filmIds and
  hiddenVideomakers on /api/providers, kept on save as hiddenDrawers is;
  i18n for every language. app.js comments cut to stay under
  TestCoreScriptBudget, which this change reached; no raise.
- docs: gateway-routing.md's Hidden image models section.

Old data: an Ark list fetched before keeps Seedance among its chat models
until its list is fetched again;
customVideomakers already counts any Seedance id an Ark key lists or picks
as a video model, so it makes videos and shows under Video models now.

Run on mote, this change and the next (/v1/models ?kind=, gateway and
docs only) rebased on f4c664a09; this commit's own tree, on 17f2387e1,
gave the same Go results with Linux and Windows vet of ./internal/...
clean:
- go test -count=1 -timeout 45m ./internal/catalog ./internal/provider
  ./internal/gateway ./internal/gui: catalog, provider and gateway ok;
  gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- GUI (at the next commit's tree, which adds no GUI file or script): the 51 provider-*, drawers, image-models, i18n and
  video-models-hide files, both engines, every language, wide and narrow:
  1161 of 1188 ok. The 27 reds are 5 files that are red the same 27 at
  origin/main d1cdce130 run alone: provider-fetch-again (#3292/#5057),
  provider-models-rest (#4396), provider-picks-stay (#4397),
  provider-levels-scroll (#4395), provider-typed (#4673).
  video-models-hide: 22 of 22 ok.
- The whole GUI suite (all files) ran earlier at this change on 8af751987,
  347 of 19153 red at load 100 to 200; the 66 files with a red, run again
  alone, are red in the same tests at origin/main 17f2387e1 (all filed:
  #4388, #4391, #4398, #4320, #4541/#5013, #2564, #4244, #4304 and the
  above).
Rebased again onto d1cdce130 (sessions, Cursor mover, library and routing
plugins, group-unlists; nothing this change touches but gateway.go,
which merged clean) and run there: TestCoreScriptBudget and internal/gui's
new tests, the gateway's ?kind= and video tests, internal/provider and
internal/catalog, video-models-hide 22 of 22: ok.

Broken by hand, each red, then put back:
- the domain/output check in catalog's live parse:
  TestFetchArkMarksVideoModels red
- OfferedVideomakers returning Videomakers whole:
  TestHiddenVideomakerLeavesListsButStillFilms red
- the editor's filmIds left empty: TestVideoModelsHidden red
- a save without hiddenVideomakers dropping the old ones:
  TestVideoModelsHidden red
- renderVideomakers' call in the editor left out: video-models-hide
  22 of 22 red
- a chip's click not changing the draft: video-models-hide 22 of 22 red

Not tried: no real Ark video was made (no money spent); the list parse was
checked on a real Ark list fetched read-only. The editor was not opened in
the real app, only in the GUI tests' fake API.

Credit: axelburks on Discord.
2026-11-03 18:34:19 +08:00
ggbdpq d97e52aea5 draw: Loomy's Hy-Image generators draw on the images API (#4913)
iFlytek's Loomy gateway serves three image generators, each listed in
its /v1/models with type "image": Hy-Image-3.5-preview,
doubao-seedream-5-lite, qwen-image-3.0-pro. An OpenAI-compatible plugin
in front of it lists all three, and the reporter measured all three
answering a normal OpenAI-shaped draw on the images API with a 200 and
a URL each.

qwen-image and seedream match catalog.ImagesAPI's words, so those two
reach Settings' image generation picker and draw. hy-image matches only
DrawsID's "image", so Hy-Image-3.5-preview stayed a chat model with no
way to pick it for drawing — the same reason WorkBuddy's Hy-Image
models need their wbDrawers path.

Add "hy-image" to ImagesAPI's words: the model is then a drawer on the
plugin's row like the other two, and the gateway asks it on the images
API instead of chat. No other model's answer changes — every id the new
word catches was already a drawer by DrawsID's broader "image"; only
where it is asked moves.

Test: TestLoomyPluginDraws (internal/gateway) installs a fake Loomy
plugin listing the three generators beside a chat model, checks Drawers
lists all three, and draws Hy-Image-3.5-preview (images API, image
back, chat never asked). Broken by hand: without "hy-image" it is red
(drawers [doubao-seedream-5-lite qwen-image-3.0-pro], the Hy-Image one
missing).

Review: applied as ggbdpq posted it (patch sha256 checked against the
issue's). Broken by hand at the reviewed head: catalog.go reverted to
its parent, TestLoomyPluginDraws red; restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
yetone 9d08993c8b routing: Cheapest first prices Ollama Cloud's DeepSeek models at double from 12:00 to 18:00 UTC on weekdays (hayden4608)
hayden4608 on Discord asked that time-of-day routing use the gap
between peak and off-peak prices, citing https://ollama.com/pricing.
That page (read live on 11-01) gives Off-Peak rows for two models
only, deepseek-v4.1-flash ($0.30/$1.20 peak, $0.15/$0.60 off-peak) and
deepseek-v4-pro ($1.32/$3.96 peak, $0.66/$1.98), and says off-peak is
"outside 12:00 and 18:00 UTC on weekdays and all day on weekends".
models.dev's ollama-cloud catalog lists the off-peak prices, so magpie
priced Ollama Cloud's peak hours at half.

- catalog: a new Peak kind, PeakOllama. Its hours are 12:00 to 18:00
  UTC, Monday to Friday, with no holidays. PeakFactor (2) matches the
  page for both models, cache reads included.
- provider: a peakBill for ollama.com (preset/catalog ollama-cloud)
  that names the two models. Dated tags (deepseek-v4-pro:1017) count
  as their model; the bare name before ':' is compared without
  allocating. Every other model there (glm-5.3, gpt-oss...) and every
  other vendor stays flat. A local Ollama, a relay that names itself
  ollama-cloud, and an ollama.com.evil host are not matched.
- GUI: a model's price tooltip names Ollama's hours for peak "ollama".
  The Cheapest first and rate-window texts no longer say that only
  DeepSeek's hours count, in en, zh, zh-TW, ja and de.
- docs/reference.md, site docs (en, zh, ja) and the gateway-routing
  and providers-accounts subsystem pages say the same.

Run (on mote through mote-run, at this tree rebased on ef3e74a07):
- go test for ./internal/catalog ./internal/provider ./internal/gateway
  for the new and changed tests, under TZ=UTC, Pacific/Kiritimati,
  Pacific/Pago_Pago and Asia/Kathmandu: ok. The tests check 11:59,
  12:00, 17:59, 18:00, 00:00 and 23:59 on weekdays, a Chinese holiday
  Monday, Saturday and Sunday, at +14, -11 and +0545 instants.
- gofmt -l internal: empty. go vet ./..., GOOS=linux go vet -tags
  nogui ./... and GOOS=windows go vet ./...: ok.
- GUI (Chromium and WebKit): model-price-edit, provider-rate-windows,
  routing-cheapest-first, i18n-keys, gui-de, gui-ja, gui-zh-tw.
- go test -count=1 -timeout 45m ./... (one suite on mote): every
  package ok except internal/gui. TestCoreScriptBudget was 7 bytes
  over, so this commit drops a comment from the app.js change rather
  than raise the budget; it passes now. TestMainWindowCorners/
  macOS_26_SDK (the window's toolbar taken off) is red on mote and
  touches nothing here: it is red
  the same way at origin/main ef3e74a07 alone, and is #3949 (macOS 27).

Broken by hand (each red, then restored):
- the peak hours ending at 17:00: TestOllamaPeakHours red.
- the Ollama bill removed: TestPeakOf, TestOllamaCloudOffPeakPrice red.
- tagged false: the dated-tag rows red.
- Ollama's hours used for every Peak kind: TestPeakHours,
  TestPriceOfPeak and TestCheapestFirstGroupFollowsPeakHours red.

Not tried: a real Ollama Cloud account or bill; a local Ollama's
":cloud" models (sent through the local server, so not priced here);
other vendors' off-peak schedules; the site is not deployed.
2026-11-01 19:02:59 +08:00
yetone 21882a68dc providers: a model's list price skips Grok's two name patterns unless it names grok-
/api/providers prices every model of every provider on each poll, and
pricedNames ran grokWindow and grokEffort over each id, lowercasing it
twice. Both patterns need "grok-" in the lowercased id, so any other id
now returns before them; what a Grok id is priced as is unchanged.
pricedOnce's memo key is sized once instead of growing by doublings.

Run (on mote unless named):
- go test -count=1 -timeout 45m ./internal/provider ok (103.8s),
  ./internal/catalog ok; GOOS=linux and windows go vet of both ok;
  gofmt clean (here).
- Broken by hand: the guard narrowed to "grokx-" turns
  TestGrokEffortListPrice, TestCursorGrokFastPrice and
  TestGrokWindowWithoutKListPrice red, so the Grok aliases are covered.
- Here, 200 GET /api/providers on the sandbox with the real config
  copy (offline, proxy :9), against v0.1.2548's tree: pricedNames
  0.28s -> 0.02s, ListPrice 0.63s -> 0.40s; process CPU 4.62s ->
  4.24s, median 20.4ms -> 19.0ms. pricedOnce stayed ~0.20s: its cost
  is the key's bytes, not the growth.

Not run: the full ./... suite; GUI tests (the JSON is the same).
2026-11-01 13:52:21 +08:00
yetone 8ac1c7a563 catalog: a model's list price is looked for once a catalog load
The GUI's provider list prices every model of every provider on each
request of /api/providers: ListPrice asks catalog.PricedBy and
MakerPriced by every spelling of the id across every maker's catalog,
and a model none of them lists (most of a relay's) went through all of
them each time. In a CPU profile of the GUI's polls (drift, state,
providers, 40 rounds, a real-account sandbox) ListPrice was 14% of the
process's CPU, PricedBy and makerListPrice most of it.

What PricedBy and MakerPriced find depends on the loaded catalog, the
providers asked and the id, and nothing else, so pricedOnce keeps it by
those for the load's Reset count (gen), as priceIndexOf and AtEndpoint
keep what they build. A Reset (a new catalog synced) starts it again; it
holds at most 32,768 answers and starts again past that. find runs
without the memo's lock, as PricedBy calls itself for a renamed id.

Run on mote (macOS 27, Go 1.26.8) at this tree:
- gofmt clean; go vet ./internal/catalog on darwin, GOOS=windows and
  GOOS=linux ok.
- TestPricedOnceALoad 3 of 3 alone, and with -race beside
  TestPricedBy*/TestMakerPriced*: ok.
- Broken by hand: the memo never answering, TestPricedOnceALoad red
  ("looked for 20 times again at one load"); the memo not keyed by gen,
  red (the old catalog's 0.15 after a new one's 0.2).
- go test ./internal/catalog ./internal/provider ./internal/usage ok.
  ./internal/gui: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949) red, the same two red with
  the same output at origin/main ccb75030a on mote.

Real use, this machine, a copy of the real accounts in a sandbox HOME
(proxy blocked, MAGPIE_NO_STATS=1), v0.1.2518's tree (old) against this:
- /api/providers: 1506 models, 938 with a list price; every model's
  list and price the same in both. The rest of the reply differs only
  in fetched times and one login's lapsed time.
- 40 rounds of drift + state + providers, twice each, alternated:
  providers 28.4/27.6ms old, 24.4/24.6ms new; process CPU 2.09/2.03s
  old, 1.95/1.94s new.

Not run: the whole suite; Windows and Linux runs (nothing here is by OS).
2026-11-01 10:11:48 +08:00
yetone 314940d2d6 catalog: SameModel leaves a plain model id as it is, without a regexp or a copy
SameModel ran modelGaps' ReplaceAllString and built a byte copy for every
id it was asked about, even one with nothing to change. The Providers
poll asks it for each provider's models, 21.5 MB of 540 MB over forty
polls with real accounts. An id with no underscore, whitespace or double
dash now skips the regexp, and one with no version dot to rewrite is
not copied.

TestSameModelPlainIDsAllocateNothing compares SameModel with the old
code over about 30 ids (underscores, tabs, no-break spaces, "--",
dotted versions, leading and trailing dashes) and checks a plain id
allocates nothing. Broken by hand both ways it goes red: allocations
back (4 to 5), and wrong answers with the plain-id check inverted.

Run on mote: the test alone 3 of 3, internal/catalog ok,
internal/provider ok, gofmt and vet clean. Real accounts in a sandbox
HOME, forty Providers polls: SameModel 21.5 MB -> 2.5 MB, state and
drift replies byte for byte the same as before. Not run: the GUI suite
(no GUI file changed).

Picked onto 27a0cbd17 (origin/main moved, nothing in internal/catalog or peak.go); not run again there.
2026-11-01 07:41:23 +08:00
yetone 15066f84f6 appdir: a folder and file name are joined once, not on every read
appdir.Config and Cache, catalog.CachePath and LivePath, settings.Path,
provider.Path and the logins path each ran filepath.Join on every call,
and they are called on every read of a cached file, many times a request.
Those joins were 70 MB of the 1.4 GB twenty window polls allocated.
appdir.Join and JoinFile keep each (dir, name, ext) they joined, up to
4096 of them, so a path named again is the same string. A changed HOME
or folder is a different key, so a test's sandbox still gets its own
path.

TestFoldersJoinedOnce and TestLivePathNamedOnce: 0 allocations a call.
Broken by hand on mote (the files before this change) they are red at 1
allocation a call, and 3 for LivePath.

Run on mote at this tree (on d714c4216): gofmt clean; vet ok on darwin,
windows and linux (appdir, catalog, settings, provider); go build ok;
appdir, catalog, settings (49s), provider (187s), agent (324s) and
gateway (1244s) ok.

At the pushed head (on 019bfc951, which adds provider.Held): vet of
appdir, catalog, settings, provider and gui ok, go build ok, appdir,
catalog and gui's TestAccountLabelsBuildTheAgentsOnce ok.
2026-11-01 03:52:46 +08:00
yetone d714c4216d catalog: a newer model's line is looked up in the index made once per load
KinEfforts gives a model newer than the catalog its line's levels (gpt-
6.1-sol's from gpt-6-sol). borrowedEfforts asks it for every model with
no levels of its own, on each look at the providers. Each ask ranged
over every model of every maker's catalog and split and joined each key
to compare its versionless shape: 66 MB of the 1.4 GB a main magpie
allocated over 20 window polls with the owner's real config.

levelIndex (97ec2f8ae) now also holds each provider's thinking keys
that aren't budgeted, by their versionless shape (kin), in key order,
made once per catalog load. KinEfforts reads the keys of the id's
shape. Which one wins doesn't change: the newest, then within one
provider the greater key, then the first provider.

TestKinEffortsReadsAnIndex: 2000 thinking models of other shapes beside
zai's glm-5.3-flash; glm-6.1-flash takes its levels, an ask takes under
8KB, and a catalog loaded since is read at once. Broken by hand on mote
(the old catalog.go): red, "an ask took 128458 bytes with the catalog
unchanged".

Run on mote at 80bcef18f (go test -timeout 45m): internal/catalog ok
0.8s, internal/provider ok 238s. go vet of both on darwin, windows and
linux ok; gofmt -l clean.
2026-11-01 03:24:38 +08:00
yetone f9ca3dd44c provider: a look at one model of the vendor's list reads it without a copy
ListedAPIs, the Kilo and Cline free marks, a model's fast tiers and a
remote magpie's price each look up one model of the provider's fetched
list (liveByID), for every model a page lists. Each look copied the
models of that id out of the list read, to read one field. With the
owner's real config the copies were 32 MB of the 2.6 GB a v0.1.2432
magpie allocated over 20 window polls.

catalog.LiveByIDShared is LiveByID without the copy (clipped, so an
append is the caller's own); liveByID uses it, and still copies a model
the user gave its own id, to set that id. Every caller only reads it.

TestLiveModelReadWithoutACopy (a 200-model list, under provider.Hold and
filememo.Hold as a request runs): a look costs less than a model over the
list's read itself, a caller's append doesn't reach the list, and
LiveByID still hands back its own copy. Broken by hand on mote: liveByID
back on LiveByID is red (1112 bytes a look against 520 for the read; a
model is 432).

Run on mote (go test -timeout 45m): internal/catalog ok 0.7s,
internal/provider ok 112s. go vet of both on darwin, windows and linux
ok; gofmt -l clean.
2026-11-01 02:54:20 +08:00
yetone 97ec2f8ae6 catalog: a model's levels are looked up in an index made once per load
listedBy (ListedBy, ListedByBorrowed) is asked for every model's
levels on each look at the providers, through borrowedEfforts. Each
ask ranged over every model of every maker's catalog twice: for its id
as given, then, for a name models.dev knows, through SameModel, whose
regexp ran on each of those thousands of keys every time. On a real
config that was 0.28 GB of the 2.6 GB twenty polls allocated.

Each provider's keys are now indexed by their bare id and by
SameModel's spelling, in key order, once per catalog load (the Reset
count loadGen gives), as PricedBy's priceIndex is. Of several keys with
one bare id, the first in key order is now asked first, where before
it was the map's order.

TestListedByReadsAnIndex: a 2000-model provider beside zai; glm-5.3-
flash is found under another spelling, a key under its bare id, an ask
takes under 8KB, and a catalog loaded since is read at once. Red on
the old code ("an ask took 341917 bytes with the catalog unchanged").

Run on mote at 98a8dee82 (go test -timeout 45m): internal/catalog ok
2.2s, internal/provider ok 214s, internal/agent ok 368s,
internal/gateway ok 801s. go vet ./... darwin and windows ok; linux vet
of catalog, provider and agent ok (./... as a whole needs cgo for
wails). gofmt -l clean.
2026-11-01 02:48:24 +08:00
yetone c7c19d49d5 provider: asking whether a model decides copies no list
DecidesModel answered for a remote magpie, and for a provider that lists
its decision models (OpenRouter's), by building decideListed's whole
list (catalog.Live copies every chat model) and scanning it. Every model
of such a provider is asked this from available(), pluginDecisions and
the decider list, so a list of n models was copied n times per look:
0.43 GB of the 4.1 GB a real config allocated over 20 polls of
/api/drift, /api/state and /api/providers (v0.1.2430,
DecidesModel -> decideListed -> catalog.Live -> catalog.Chat).

It now looks the model up in the list as kept (catalog.LiveByID, which
readLive indexes once per read), and catalog.LiveListed says whether the
list has any model, for the Jev fallback decideListed has. The answers
are decideListed's: a remote magpie's models its list marks Decides; a
listed decision list's models; with none listed, OpenRouter's Jev unless
the server marks its own.

TestDecidesModelCopiesNoList: 2000 decision models, each ask under a
twentieth of the list's bytes, for both kinds, and the answers above.
Red on the old code (an ask 869,336 bytes, the list 869,829).

Run at 6a900e0d0 plus this change, on mote: go vet (darwin, windows, linux)
and gofmt of internal/provider and internal/catalog clean;
go test -count=1 -timeout 45m ./internal/provider ./internal/catalog
./internal/agent ./internal/gateway all ok (126s, 0.6s, 612s, 1305s).
2026-11-01 01:55:09 +08:00
yetone 8413267097 catalog: a list's image/jpeg is an image, so OpenCode Go's models that see take images again (zeo9901)
zeo9901 (CC01CC) on Discord #feedback: "magpie 中 opencode go 所有的模型似乎
都无法实现图片输入了". Their screenshot is a routing group of DeepSeek V4.1
Flash at Open Design and at OpenCode Go.

Cause: OpenCode Go's own /models (https://opencode.ai/inference/go/v1/models,
the same at /zen/go/v1/models) lists what a model takes as media types:
deepseek-v4.1-flash's modalities.input is ["text","image/jpeg","image/png",
"image/gif","image/webp"], Gemini's adds application/pdf and audio/*, and so
on. catalog's live-list reader took the list word for word and asked for
"image", found none, and recorded ImageInput = false, an explicit answer.
entryFor puts a list's explicit answer over models.dev's (which says
image), so with a working Go key every Go model was text-only: a direct
pick had its image described or turned away with "model does not support
image input", a group member was sent it described or not at all, and
agents were told the models take text only. It used to work while Go's
list spelt modalities as models.dev does, or said nothing.

Fix: catalog.Kinds reads a modalities list as models.dev words it
(image/* image, video/* video, audio/* audio, text/* text,
application/pdf pdf, each once, an unknown word kept, nil stays nil).
imageInput and the live reader's InputModalities/OutputModalities go
through it, as do Codex's input_modalities, the labs rows and a decision
provider's listed facts (decide.go). A list saved before this, still
holding Go's media types and false, is mended when read (mendKinds), so
a user sees images from the first read after the update, not the next
fetch. A user's own Accepts images answer still wins.

Which OpenCode Go models take images, per Go's list on 2026-10-31:
deepseek-v4.1-flash, kimi-k3, kimi-k3.1-pro, kimi-k2.7-code, glm-5.3-flash,
qwen3.8-max, qwen3.8-flash, qwen3.7-plus, minimax-m3, minimax-m3.1-flash,
mimo-v2.6-flash, mimo-v2.6-pro, step-5-preview, gemini-4-argon, grok-4.7,
gpt-6-luna, gpt-5.6-luna, claude-haiku-5-5, muse-spark-1.2/1.3-contributor.
Text only: deepseek-v4-pro, glm-5.2, glm-5.3, hy3, hy4-preview,
longcat-2.0, beam-free, iceman-contributor-free.

Tests (fixture: four rows of Go's real list, read without a key, no test
reaches the network):
- TestOpenCodeGoMediaTypesSee (catalog), TestKinds,
  TestSavedMediaTypesListSees, TestListedFactsMediaTypesSee (provider).
- Broken by hand: Kinds returning its input unchanged turns all four red
  (deepseek-v4.1-flash, kimi-k3, gemini-4-argon "Images false"); the
  mendKinds call taken out turns TestSavedMediaTypesListSees red.

Run on mote at the working tree on 82b45888a (origin/main 82b45888a plus this change):
- gofmt -l internal cmd: nothing.
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  ./internal/catalog ./internal/provider ./internal/gateway: ok.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/gateway ./internal/agent -count=1 -timeout 45m: all ok
  (catalog 0.7s, provider 129s, gateway 665s, agent 203s).
  The docs paragraph was added after the run; no code changed since.
  The full go test ./... and the GUI suite were not run (no GUI file
  changed).
- Rebased onto ceeb73a0f (two commits outside catalog); at the rebased
  tree go test -tags nogui ./internal/catalog ./internal/provider
  -count=1 -timeout 45m: ok (catalog 0.8s, provider 98s).

Docs: gateway-routing.md, "A model that turns an image away".

Not tried: a real OpenCode Go request with an image (the only Go key here
has expired, and it isn't to be used). Not known: which agent and version
the reporter uses; Open Design's DeepSeek in the same group is a separate
provider and wasn't looked at.
2026-10-31 14:51:11 +08:00
yetone 2ac423f4f2 kimi: a Kimi Code plan model is told always_thinking, dynamically_loaded_tools and its default effort, as Kimi's list says (jiabubu)
jiabubu on Discord (Kimi Code 2.2.0, Windows): Kimi Code's own provider
gives K2.8 Preview and K3.1 Pro the capabilities thinking,
always_thinking, image_in, video_in, tool_use and
dynamically_loaded_tools; through magpie they had thinking, image_in and
tool_use, so Kimi Code offered a thinking switch the models refuse to
turn off, and started K2.8 on high where Kimi's own starts it on max.

Kimi Code 2.4.1's managed provider (packages/oauth managed-kimi-code.ts,
capabilitiesForModel) derives them from /coding/v1/models:
supports_thinking_type "only" -> thinking + always_thinking,
supports_dynamic_tools -> dynamically_loaded_tools, supports_video_in ->
video_in, think_efforts.default_effort -> the default. magpie now reads
the same fields (flat, or nested reasoning.type, tools.dynamic_load,
reasoning.effort.default) into catalog.Model (AlwaysThinks,
DynamicTools, DefaultEffort; kimiFacts), carries them through
provider.Entry and the agent's model list, and the new Kimi Code's table
gets always_thinking, dynamically_loaded_tools and default_effort at the
vendor's default (else high, as before). Only Kimi's list sends these
fields, so another vendor's model is written as before; kimi-cli, which
refuses unknown words, gets none. A routing group has none of them.

default_effort is now recorded in the stash as magpie's (kimiOwn), so a
level the user picked stays while the model has it. A table with high
and no record is read as the high magpie wrote before it kept one, and
becomes the vendor's default (max on K2.8, high on K3/K3.1).

Left out:
- video_in: with type="kimi" Kimi Code uploads a video to
  {base_url}/files (purpose=video) and sends the ms:// id. The gateway
  has no /files route, and the id belongs to the account that stored it.
  Filed as #4485.
- dynamically_loaded_tools works (Kimi Code's tool select is behind
  KIMI_CODE_EXPERIMENTAL_TOOL_SELECT): the loaded tools' system message
  is lifted into the request's tools (liftMessageTools, #2322), so they
  stay callable (TestKimiCodeLoadedToolsReachKimi), but each load
  restarts Kimi's prompt cache. Filed as #4486.
- max_output_size: Kimi's own provider writes none; magpie keeps writing
  the model's known reply cap (32768 on K2.8 per models.dev), unchanged.

This also covers #3399 (K3.1 offered thinking off): Kimi's list says
"only" for both K3.1 models.

Real list: tests read Kimi's /coding/v1/models reply of 2026-10-31
(internal/catalog/testdata/kimi-code-cn-models-2026-10-31.json, read
with the owner's kimi-code-cn key, no key in the file).

Run (mote, at this commit on origin/main b62fa332f; the agent-wiring.md
line was added after the run, docs only):
- go test -tags nogui -count=1 -timeout 45m ./... : 79 packages ok;
  internal/proc (TestNoCommandBypassesProc) and internal/sqlitedb
  (TestOnlyThisPackageReachesSQLite) red on a Go module cache my e2e
  sandbox had left inside the run folder (vendor files under
  e2e-kimi/sb/home/go/pkg/mod); with it removed both ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... ok; gofmt -l clean.
- Real Kimi Code 2.4.1 (npm) in a sandbox HOME/KIMI_CODE_HOME on mote,
  with a sandbox magpie serve (MAGPIE_ADDR 127.0.0.1:34652), the
  kimi-code-cn preset pointed at a fake upstream that serves the real
  list: magpie wrote the six tables (K2.8: thinking, always_thinking,
  image_in, tool_use, dynamically_loaded_tools, support_efforts low/high/
  max, default_effort max; K2.7 Highspeed without
  dynamically_loaded_tools), Kimi Code took the config, and `kimi -p`
  reached the upstream with thinking enabled and reasoning_effort max
  (K2.8) and high (K3.1 Pro).
- Rebased onto 43966a53f..f2eb56c6b (claude, GUI budget, usage; none of
  them touch these files) as f5a82f215, then again at this head:
  internal/agent, internal/catalog, internal/provider ok, internal/gateway
  -run 'Kimi|MessageTools|Lift' ok. The full suite was not rerun there.

Broken by hand, each red then green:
- kimiFacts not called: TestFetchKimiCodeFacts and
  TestKimiCodePlanCapabilities red.
- fields not carried in route.go / entryFor: TestKimiCodePlanCapabilities
  red.
- the unrecorded-high rule off: TestKimiCodeOldHighBecomesTheVendorsDefault
  red.
- always_thinking without the !legacy guard: the kimi-cli case red.

Not tried: the TUI picker by eye (that the thinking switch is gone);
tool select with a real MCP server and the experimental flag; Windows
(the reporter's system; nothing here is OS-specific); a real Kimi
upstream through magpie (the list was real, the chat was a fake).
2026-10-31 03:27:34 +08:00
yetone 643b525469 usage: a DeepSeek call at peak hours costs double its off-peak list price
treeMan on Discord: DeepSeek bills off-peak at half the peak rate, and the
Usage page didn't follow it. The catalog's list prices for these models
are already the off-peak ones: models.dev's DeepSeek, Command Code and
OpenCode Go entries give the off-peak rate as the price and a factor-2
multiplier for peak hours, and api.json leaves the multiplier out
(deepseek-flash: $0.15/$0.60/$0.003, DeepSeek's page says $0.30/$1.20/
$0.006 at peak). So every peak call was counted at half its cost. Now a
call made from 01:00 to 04:00 or 06:00 to 10:00 UTC, Monday to Friday,
costs twice the list price. The call's own timestamp decides.

Which providers (provider.PeakOf, by base URL, or by preset/id only for a
provider with no URL, such as a plugin's or a removed one):
- DeepSeek's API (api.deepseek.com), every model, except on Chinese
  public holidays (catalog.PeakDeepSeek);
- Command Code (api.commandcode.ai, the commandcode preset and the
  commandcode-plan plugin): deepseek-v4.1-flash, -v4.1-flash-fast,
  -v4-flash, -v4-flash-vision-exp and -v4-pro, every weekday, since its
  docs name no holiday. deepseek-v4-flash-fast is one price at every hour;
- OpenCode Go (opencode.ai/zen/go): deepseek-v4.1-flash and
  deepseek-v4-pro, every weekday.
Unchanged: OpenCode Zen (a flat $0.30/$1.20), ZenMux, Cline Pass,
OrcaRouter and every other relay, a price the user set (ModelPrices
returns before a Peak is set), a "same as" price and every other model.
The provider's price rate still applies.

Holidays: catalog.cnHolidays has 2026 from the State Council's notice
(2025-11-04). TestCNHolidaysCoverThisYear fails on 2027-01-01 unless that
year's notice, due in November, is added. A year missing from the table
counts no holidays.

Where the hour is applied (catalog.Price.In): Record.CostAt (Usage's
totals and groups), the packed gateway blocks (priceBlock), OTLP's
exported cost and budget's estimate (now). The Sessions page sums per
model without per-call times and stays at the list price. The model
editor's price box says when a list price counts double (four languages;
app.js kept under its budget by shortening, not by a raise).

Run at the tree pushed (parent 32f5c3369), on mote:
- gofmt -l clean
- go vet on the six packages
- go test of catalog, usage and otlp whole, and provider and gui -run
  Peak|PriceIn|CNHolidays|Price|TestCoreScriptBudget, with TZ=UTC and
  with TZ=Asia/Shanghai: all ok
At 76b18f68d (the same change before the last two rebases), on mote:
- go vet ./internal/..., GOOS=linux -tags nogui and GOOS=windows vet of
  ./..., and the darwin, linux nogui and windows builds: ok
- catalog, provider, usage and otlp whole, in both zones: ok
- internal/gui: TestCoreScriptBudget was red (app.js 108 bytes over),
  fixed by shortening the hint. Ten AppKit window tests were killed at
  their 30s bar at load ~130 (TestDockJoinLeadsCommandTab,
  TestMainWindowCorners and others); this change doesn't touch them.
GUI:
- model-price-edit (now checks both peak hints and none on a plain list
  price), model-price-tiers, provider-price-rate and i18n-keys: Chromium
  ok on mote.
- WebKit on mote couldn't launch at all (browserType.launch timed out at
  180s, 69 WebKit processes from other runs), so the three price files ran
  in WebKit on Linux (wsl-run): 8 of 8 ok.
- The whole GUI suite (both engines) at ff23724f3 was still running at
  load 110 to 150 when this was pushed, 119 red of ~7200. Every file
  checked so far is a timeout under load or in #4304 / #3476.
  model-chip-steady is red the same way on origin/main 0911a65e7.

Broken by hand, each red:
- CostAt without .In(r.Time): TestCostAtTheCallsHour (0.753 at peak,
  want 1.506)
- priceBlock without .In(p.Time): its block half
- Peak.At ignoring holidays: TestPeakHours on 2026-10-05
- priceOf never setting Peak: TestPriceOfPeak
- OpenCode Go's model list dropped: TestPeakOf (kimi-k3 "weekdays")

Not tried: a real call to DeepSeek, Command Code or OpenCode Go at peak
and off-peak to compare against their bills; a full go test ./...; the
holiday rule's handling of the swapped working weekends (DeepSeek says
Monday to Friday, so a worked Saturday stays off-peak here); ZenMux,
whose own docs give no schedule.
2026-10-30 15:22:55 +08:00
yetone e887139e7a providers: Best in family serves the newest model of each family a provider lists
Steven on Discord #feedback asked for a provider to serve only the newest
model of each family, so a newer one (Opus 5.6) takes the old one's place
without re-picking.

The provider editor's Models control gets a fourth option, beside
Vendor's list / Picked only / Usage only: Best in family. It is also on the
CLI as `magpie provider models <id> best`. With nothing picked, the provider
serves only the newest model of each family in the vendor's list, up to 24.
A family is the id with its version numbers taken out
(catalog.FamilyOf/BestInFamily in internal/catalog/family.go). A dated
snapshot counts as its alias, and sizes and suffixes (mini, flash, -fast,
-thinking) stay part of the name. Provider.Exposed applies it, and so does
Codex's native list (CodexNativePicked). A provider/model a request names
explicitly is still served, since resolve doesn't go through Exposed. A pick,
Select none or Usage only clears the flag (normalize), and a providers.json
without bestInFamily reads as before, so every existing mode is unchanged.
The editor draws the family's newest as dashed (m.best) before saving. Every
language has the wording (zh, zh-TW, ja, de). The design reference is
docs/subsystems/providers-accounts.md (Model picks).

Tests: family_test.go is a table of real ids, including the models.dev Claude
list in testdata (no network). There are also best_in_family_test.go
(provider), TestProviderModelsBest (cli), provider_save_best_test.go (gui
save keeps/clears), codex_best_in_family_test.go (gateway) and
provider-best-in-family.test.cjs (5 languages x chromium/webkit x 1100/420).

Broken by hand: with the BestInFamily filter in Exposed and in
CodexNativePicked turned off, the 4 new Go tests went red.

Budget: after the rebase app.js went over appScriptBudget. Comments were cut
and the tooltip and hint merged into one string, so app.js is 1,311,399 of
1,311,735. Neither budget was raised.

Run at this head, on origin/main 1027db408, via mote-run (macOS 27):
- gofmt -l clean; go vet clean for darwin, linux -tags nogui and windows
  (at base 05a6087e1, the same Go diff).
- go test -count=1 ./internal/catalog ./internal/provider ./internal/cli
  ./internal/gateway: ok.
- go test ./internal/gui: everything except TestMainWindowCorners/macOS_26_SDK
  (red on macOS 27, #3949; not this change).
- node --test: provider-best-in-family, provider-none-picked,
  provider-picked-only-shows-picks, i18n-keys, gui-de, gui-ja, gui-zh-tw,
  context-map and gateway-key-models, 113 tests, 108 pass. The 5 reds are
  context-map 420px "two tiles overlap" (#3488, #4304) and gateway-key-models
  webkit en (#4304). Both fail the same way on a clean origin/main 1027db408
  checkout run alone (8 of 30 red there).
- The earlier wider GUI run (38 provider/routing files, concurrency 3) had
  the same red files on origin/main deb0b8da7 as at this change's head:
  model-chip-steady, models-works-only, provider-fetch-again and the others
  in #4304. Three with no issue were filed: #4320 (recovered-file),
  #4321 (tencent-cloud), #4322 (warm-now).

Not tried: no real account or real magpie app; the editor was checked
through Playwright screenshots only. Families are read off the id alone, so
a vendor whose ids don't put the version in numbers (or orders them
oddly, e.g. grok-4.20 against grok-4.7 compared numerically) may group
or rank unexpectedly. Bedrock's -v1:0 counts as version digits.
2026-10-30 04:48:17 +08:00
yetone 9b833205f7 groups: a found group's id and name come from models.dev's one spelling (XYenon)
XYenon on Discord (#feedback, 10-30): autoGroups() and spelledIn() picked
a found group's name and its public id apart, so a group read
glm-5-3-flash beside auto/glm-5.3-flash. The id also followed the order
the providers were added in.

Now:
- spelledIn takes the spelling models.dev gives the model most
  (catalog.Spelling, the normal index normalFor already reads): every
  member spelling of GLM-5.3 Flash (glm-5-3-flash, Ark's
  glm-5-3-flash-260828, glm-5.3-flash) gives auto/glm-5.3-flash. A model
  models.dev doesn't know keeps the old pick (first listed member
  spelling, else the first member's).
- autoGroups names the group from the same choice: catalog.NameOf of
  that spelling, else a vendor's own name, else the spelling itself.
  A found group the user changed keeps the name they saved.
- Old ids keep working. group/auto-<slug> doesn't change, and any
  auto/<spelling> is still the group (CanonicalRef: gateway, key
  allow-lists, fallbacks, members). PublicRef now takes an old
  auto/<spelling> to the current one too, so hidden, picked and ordered
  models saved by it hold, and a pick of it written now (Agent.Apply)
  is written as listed. An agent field magpie set to an old spelling
  moves on the next SyncCatalog (renameFoundGroups), as group/auto-
  values already did, because OpenCode checks its model against the list
  magpie writes. A value the user set stays as it is and is still served.

Tests (on mote, via mote-run):
- TestFoundGroupIDAndNameAreOneSpelling (5 member orders/spellings, the
  user's name kept), TestFoundGroupUnknownToModelsDevNamedByItsID,
  TestFoundGroupMovedOffAnOldSpelling. The catalog fixtures use
  models.dev's real spellings and names (glm-5.3-flash "GLM-5.3-Flash",
  volcengine's glm-5-3-flash "GLM 5.3 Flash").
- Broken by hand, one file reverted at a time: group.go reverted, the
  test is red (named "GLM 5.3 Flash" beside auto/glm-5.3-flash);
  provider/autoref.go reverted, red (id auto/glm-5-3-flash with Ark first,
  PublicRef of the old spelling unchanged); agent/autoref.go reverted,
  TestFoundGroupMovedOffAnOldSpelling red (field stays
  magpie/auto/glm-5-3-flash).
- go test -timeout 45m: internal/catalog, provider, agent, tui, cli,
  usageapi ok. internal/gui: everything ok except TestMainWindowCorners/
  macOS_26_SDK, which is #3949 (AppKit on macOS 27, nothing to do with
  this change). internal/gateway, codexcat, sessions ok.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows clean.
- No GUI file changed, so the GUI suite wasn't run. Names reach it
  through /api/groups.

Not tried: a real models.dev sync with real providers in a sandbox app.
Groups whose first provider spelled a model differently from models.dev
(e.g. claude-opus-4.8 from a relay vs Anthropic's claude-opus-4-8) get
the models.dev spelling once. Magpie-set agent fields move with it, and
values the user set keep resolving. A key or fallback chip saved under
the old spelling still shows it in the editor (it still works).
2026-10-30 03:09:29 +08:00
yetone 810a4144fe catalog: a model's Same as gives it that model's window, levels and images; a channel's tag in brackets is read past (pinmmis on X)
pinmmis on X (tweet 2115776439341506603): the same model from several
relays, each renamed to be told apart ("ds.4.1(WB)" for
deepseek-v4.1-flash), had none of models.dev's specs, and setting each
spec by hand per model was the only way.

The ids are the relay's own (magpie looks up the model's id, not a
display name), so this is not a display-name bug. The editor's
per-model "Same as" (settings' ModelSameAs) already merged routing
groups and priced the model; now it also gives the model that model's
window, reply limit, reasoning levels, thinking and images:

- catalog.UserSame, set by the settings package (sameas.go,
  sameAsBare: ModelSameAs indexed by bare model id, memoised per
  shared map), is asked by contextIn/lookupIn after the id as given
  and before magpie's own guesses (renamed, normalFor). An id
  models.dev lists stays its own; the user's own window, output,
  levels and images settings still win (callers read them first).
  The model named is looked up once, never sent back to UserSame (no
  loops). KnowsAsWritten (usage telemetry) never hears it.
- Zero-config part: those lookups also read past a channel's tag in
  brackets at an id's start or end (untagged: "deepseek-v4.1-flash
  (WB)", "[WB] ...", fullwidth and CJK brackets). A "[...]" written
  onto the id with no space is not a tag ("deepseek-v4.1-flash[fast]"
  may be a variant, TestRenameNeverTakesAModelForAnother). Prices are
  never borrowed this way (TestOtherSpellingIsNotPriced's rule); a
  Same as's price is still SamePriceIn.
- "ds.4.1(WB)" itself is not guessed: ds/4.1 could be flash or pro.
- GUI: the Same as box's tooltip says what it now covers, in every
  language; provider-same-as.test.cjs checks every language, not zh
  only. No layout or API change.
- docs/subsystems/providers-accounts.md says it.

Run on mote via mote-run:
- at the same change on 2c89794ac: go test -tags nogui -timeout 45m
  ./internal/catalog ./internal/settings ./internal/provider
  ./internal/agent ./internal/gateway ./internal/gui ./internal/cli:
  all ok (gateway 525s).
- at this commit (rebased on 2d11cde05, which touched provider and the
  GUI): catalog, settings, provider, gui again: all ok
- node --test provider-same-as, i18n-keys, names-fold in chromium and
  webkit, at this commit: 16 of 16 pass.
- gofmt -l clean; GOOS=linux/windows/darwin go vet -tags nogui of
  catalog, settings, provider: clean.
- Real use: magpie built in a sandbox HOME on mote with the real
  models.dev cache, a relay provider with ds.4.1(WB) (Same as
  deepseek-v4.1-flash), ds.4.1(other) and "deepseek-v4.1-flash (WB)":
  `magpie model spec` gives the first and third 1048576 / 384k /
  vision on / low,high,max, the second unknown.

Broken by hand: userSame and untagged made to find nothing ->
TestUserSameGivesTheSpecs, TestTaggedIDHasTheModelsSpecs (17 errors)
and TestSameAsGivesAnUnlistedModelItsSpecs go red.

Not tried: a real relay request in the GUI app; Windows/Linux runs
(pure Go lookups, no OS paths); the whole GUI suite (only a tooltip
string changed).
2026-10-29 20:36:04 +08:00
yetone 65bd4e4f72 provider: a model is priced at its maker's own API before a reseller's (bestony on Discord)
bestony on Discord (#feedback) asked that a subscription with no price of
its own, such as Command Code, be costed at the model's official list
price. magpie already estimates every subscription at the maker's list
price, but the maker step (PricedBy over the maker presets) took the
first preset that listed the id, and Mistral resells other labs' models:
deepseek-v4.1-flash-1017 was costed at Mistral's $0.30/$1.20 instead of
DeepSeek's $0.15/$0.60, glm-5-2 at Mistral's instead of Zhipu's, and a
lab that isn't a preset (Meta's muse-spark, Sakana, Tencent hy4-preview)
had no price at all.

catalog.MakerPriced prices a model at a models.dev provider that lists it
as its own: the entry's canonical_model_id names that provider as maker,
or the provider id is the maker's with a region (alibaba-cn), never a
plan's ("-plan") and never an entry at $0. A maker preset that is such
an API is asked first, in preset order, then the other owners by id;
the old PricedBy over the presets stays the fallback. makerListPrice
uses it in ListPrice's maker step, MakerPrice and PricedName. No new
setting: a model no maker lists still takes the user's price or a
same-as model.

Over every id in the real models.dev cache (2026-10-29, ~4086 ids) the
only prices that changed are the deepseek-v4.1-flash-1017 family
(0.30 -> 0.15), glm-5-2 (Mistral 1.40 -> Zhipu 1.19516), and newly
priced Meta, Sakana, Thinking Machines and Tencent hy4-preview models.

Run (mote-run, rebased on 1a8539432; catalog, provider, usage run again at this head):
- TestMakerPriceIsTheMakersOwn (fixture: literal entries of the real
  models.dev cache) red on the old code, 10 errors (Mistral's resale
  price, Meta unpriced), green on the new.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  for internal/catalog, internal/provider, internal/usage.
- go test -timeout 45m ./internal/catalog ./internal/provider
  ./internal/usage: ok.
- go test -run 'Pric|Cost|Usage' ./internal/gateway ./internal/gui
  ./internal/cli: ok.

Not tried: a real Command Code request and its Usage row in the GUI;
the full gateway suite; Windows/Linux runs of the tests.
2026-10-29 19:01:04 +08:00
yetone 0366e35c11 catalog: a model models.dev lists under another spelling takes its limits
xyenon (Discord #feedback, 10-29): Volcengine Ark lists
kimi-k3-1-pro-261024 where models.dev lists kimi-k3.1-pro, so magpie
knew neither its context window nor its reply limit. The ids differ only
in what the provider package's sameModel already folds when it groups
models: a version's dot written as "-" (or Fireworks' "p"), and Ark's
six-digit YYMMDD date.

Design
- sameModel moves to internal/catalog as SameModel, word for word
  (snapshotDate, modelGaps and atoi2 with it). provider's sameModel calls
  it, so grouping and catalog lookups fold ids by one rule.
- Exact matches go first and are unchanged: found (exact, Bedrock
  profile, "(variant)", ":tag"), then renamed (relay prefixes, window
  marks). Only when both miss does normalFor look up the id models.dev
  spells as SameModel(id) folds it. When several spellings fold into one
  key, the spelling most providers use wins, and then the lowest id, so
  Venice's kimi-k3-1-pro keeps its own 1000000/131072 and the other
  spelling gets the majority's 1048576/1048576.
- Decorate (a vendor's live list against the provider's own models.dev
  entries) tries the same provider's entry under another spelling before
  anything else. It fills only what the vendor's list leaves at zero and
  never copies a price, so a limit the upstream states always wins.
  ListedBy (a provider's own levels) gets the same last pass, per
  provider, after its exact passes.
- What is not borrowed: a price (PricedBy has no such pass, so nothing is
  priced from another provider's or another spelling's row) and a display
  name (NameOf; the upstream id stays the id).
- What is not matched: -pro-max, -mini, another version (k3.2, k3), a
  four-digit release (-2610), a six-digit number that isn't a date
  (261324), and OpenAI's dashed date. SameModel already kept those apart.
- Re-derived: everything that reads these tables goes through
  ContextOf/OutputOf/lookup, so ListedWindow, replyLimit, the Codex
  catalog, efforts and thinks get the fallback with them. Knows now takes
  other spellings too, so the usage report (stats modelLabel), which may
  send only ids models.dev lists, reads the new KnowsAsWritten, which
  doesn't.
- docs/subsystems/providers-accounts.md says all this.

Tests (internal/catalog/spelling_test.go, a fixture from models.dev's
rows for these ids, no network)
- TestOtherSpellingLimits: the report's literal ids
  (kimi-k3-1-pro-261024, volcengine/…, Kimi-K3.1-Pro-20261024) and
  twelve near misses; levels; Knows vs KnowsAsWritten; no name.
- TestOtherSpellingIsNotPriced: no provider prices the dated id, and the
  plan's price isn't taken for pay-as-you-go's id.
- TestDecorateOtherSpelling: the vendor's 200000 stays, the reply limit,
  levels and name are filled, no price; a -max id and kimi-k3 vs
  kimi-k3.1-pro are kept apart; ListedBy likewise.
- TestSameModelReportIDs.
- stats_test: a dated id models.dev knows only under another spelling is
  sent as "other".

Red on the old code (catalog.go and live.go reverted, KnowsAsWritten
stubbed): TestOtherSpellingLimits "ContextOf("kimi-k3-1-pro-261024") = 0,
want 1048576" and the rest; TestDecorateOtherSpelling Output 0, ListedBy
false.

Broken by hand
- The majority vote inverted: Venice's spelling wins, and the test asks
  for 1048576 and gets 1000000/131072. Red.
- KnowsAsWritten taking other spellings: TestOtherSpellingLimits red.
- stats reading Knows: "deepseek/DeepSeek_V4-260101", want
  "deepseek/other". Red.

Real catalog (models.dev cache on the WSL box, a throwaway test since
deleted): kimi-k3-1-pro-261024 gets 1048576/1048576 and levels
low,high,max, is not priced by volcengine, and isn't KnowsAsWritten;
kimi-k3-1-pro-max-261024 gets 0; Decorate of glm-5-3-flash-260828
against volcengine-coding-plan gets 1000000/131072 and the name
GLM-5.3-Flash with no price; claude-opus-5-5-20260801 gets
1000000/128000; gpt-4o-2024-08-06 is unchanged.

Run
- Full suite on the Linux box (wsl-run, Go 1.26.8) at 242e5c68d on base
  be8b0f381: go vet -tags nogui ./..., go build -tags nogui ., go test
  -tags nogui ./... -timeout 45m -count=1. 77 packages ok (catalog,
  provider, stats, gateway and gui among them). One red package,
  internal/agent: TestInstalledVersion, TestGrokInstalled and
  TestOmpDetectedWithPiDir, the three install-detection reds #4033 and
  #3548 already name for that box at main. They don't read the catalog.
- On mote at 242e5c68d: GOOS=windows go vet and darwin go vet of
  catalog, provider and stats, and a GOOS=windows build of magpie. All ok.
- Rebased on origin/main 4d9058a98, whose Ark plan list change touches
  none of these files: gofmt -l (clean), go vet, and go test -count=1 of
  internal/catalog, internal/provider and internal/stats on the Linux
  box. All ok.

Not tried: a request on a real Volcengine Ark account; the report's ids
come from xyenon's message and models.dev.
2026-10-29 15:47:18 +08:00
yetone 60561129f8 codexcat: two entries Codex's picker would name the same are told apart by their provider's id (nb5p on Discord)
nb5p had GPT-6.1-Sol from two providers both called Codex, and Codex's
model picker showed two identical entries, the hover text identical too.
Now, only when two listed entries would have the same display_name,
each gets its provider's id after it ("GPT-6.1-Sol · Codex · codex-b"),
or its own model id where the provider's doesn't tell them apart (a
routing group, two of one provider). Every other entry is unchanged.

Only display_name changes. The description and catalog Model.Name are
as on main. Codex puts each of the first five catalog models'
description into spawn_agent's "Available model overrides" (codex-rs
multi_agents_spec.rs spawn_agent_models_description, and
context/world_state/model_catalog.rs with model_catalog_in_context),
which goes upstream on every request; the real Codex 0.162.1 bytes in
internal/redact/testdata/codex-0.162.1-request.json show "- `fake/m1`:
m1 · fake via magpie". magpie's own spawnChoices sends Name. So the
first try (provider/account in the description) was dropped: it would
have sent the account's email upstream. display_name: read in codex-rs
at 5d5e5c5 (cloned on mote), core builds no prompt or tool text from a
model's display_name (model_catalog.rs and spawn_agent_models_description
use slug + description + efforts + tiers only); in the captured Codex
requests the name appears only inside the description. The id is in the
slug already, which is sent anyway. Apart is in the Model's JSON, so it
is in the list's tag and Codex asks for the list again when it changes.

Run (mote, at the rebased head):
- TestCodexPickerNamesSameNamesApart (internal/provider) and
  TestCodexApartInDisplayNameOnly (internal/codexcat): pass.
- Broken by hand: codexApart never marking a pair, and shownName
  ignoring Apart (the old behaviour): both tests FAIL, e.g.
  codex-b/gpt-6.1-sol shown as "GPT-6.1-Sol · Codex", want
  "GPT-6.1-Sol · Codex · codex-b".
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: all ok (at base 7e58591dc + this change)
- go test -tags nogui -timeout 45m internal/codexcat internal/catalog
  internal/provider internal/agent internal/gateway: all ok (provider 111s, agent 177s, gateway 559s)

Not tried: a real Codex picker with two same-named providers (no
second Codex-named provider in a sandbox here); the full ./... suite.
2026-10-28 20:50:15 +08:00
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00
JoeyWu-tech 32ea16c5a4 gateway, provider: a model AgentRouter turns away on chat in Chinese is asked, and tested, on the next API (#3766)
char1eslu (#3766): AgentRouter answers gpt-5.6-sol, gpt-6-astra and
gpt-6.1-sol on chat completions with a 400, "模型 gpt-5.6-sol 不支持
/v1/chat/completions 接口,请改用 /v1/responses(OpenAI Responses API)。",
and serves them on Responses (gpt-5.6-sol on Messages too: the report's
provider test has ✓ anthropic). wrongEndpoint, the gateway's word that a
model is served on another API, which has the request asked there when
the provider has a URL for it (and remembers it in unfit), read English
alone. So while the provider had a Chat URL, a Chat client's request for
these models got that 400 back, whatever other URLs it had. The report's
200 ("/v1/chat/completions → /v1/responses") is a request translated
past chat, which d03779cc does for this host only while chat isn't
usable for the model, as after the report's url=. A Messages client's
request goes to the reporter's Anthropic URL and is answered there.

wrongEndpoint now also reads the message's two clauses, "不支持
/v1/chat/completions 接口" and "改用 /v1/responses", and asksResponses
the second, so a provider with its Chat URL alone gets the note that the
model is served on /v1/responses, which it has no URL for. Both read the
body's JSON strings decoded too (wordsOf), as the gateway's other words
are (#1669): the report quotes the message, not the body, and a relay
whose JSON escapes it (模型 ...) says the same. Neither clause
names a model, so the other two models' refusals match if their
messages differ only in the name (the report shows their 400 rows, not
their words). The routing page says so.

The same words now reach the group's checks, as retryable and
shapeRefused read wrongEndpoint. In a routing group (chat, drawing,
video, System One), a member answering this 400 ended the request there
on d03779cc: it was neither retryable nor shapeRefused, as
unservedWords' 模型.{0,12}不支持 misses these model ids by one
character. Now the next member is asked and this one isn't rested, as
for the English words. The image-tool and cache-key retries, which ask
again on a 400, don't on this one.

Not changed: a model's test, which still asks one API (the next
commit). Other relays' wordings: only the report's two clauses are
added, nor AgentRouter's other way round (a chat-only model asked on
/v1/responses), which the report has no words for.

What was run (tree 4e5bb297, on origin/main d03779cc, go1.26.8,
linux/amd64):
- TestChineseRefusalFallsBackToResponses, new: a provider with a Chat
  and a Responses URL whose chat completions answers the report's 400
  (its message verbatim; the JSON around it is a guess), as it is and
  escaped as Python's json.dumps escapes it. A request on
  /v1/chat/completions and one on /v1/messages each get the reply from
  Responses, chat asked once and Responses once.
- TestWrongEndpoint: the report's 400, escaped too, and each of its
  clauses alone are the wrong endpoint; "当前分组 default 下对于模型 gone
  无可用渠道" (new-api's wording for a model no channel serves, written
  from memory, not from the report) is not.
- TestWrongAPINote: AgentRouter with its Chat URL alone and the report's
  400, as it is and escaped, gets " (asked at
  https://agentrouter.org/v1/chat/completions; gpt-5.6-sol is served on
  /v1/responses, which AgentRouter has no URL for)".
- The three, -count=50 -v: 150 PASS. -race -count=20 -cpu 1,2 over them
  and the fallback tests beside them (WrongEndpoint, WrongAPINote,
  FallsBack, OpenCodeGo, OtherRelayKeepsItsOneAPI): ok, no race.
- Broken by hand, each red:
  - wrongEndpoint without the two clauses: every case of
    TestChineseRefusalFallsBackToResponses, and TestWrongEndpoint's
    rows of the whole message.
  - wrongEndpoint with one clause of the two: TestWrongEndpoint's row of
    the other clause alone (each).
  - wrongEndpoint reading the body as it came: the escaped cases of
    TestChineseRefusalFallsBackToResponses and TestWrongEndpoint's
    escaped row.
  - asksResponses without its clause: TestWrongAPINote, both bodies;
    reading the body as it came: its escaped one.
- A real run: magpie built at d03779cc and at this tree (go build -tags
  nogui -buildvcs=false), in a sandbox HOME, a local server standing in
  for AgentRouter (its /v1/models lists gpt-5.6-sol, chat completions
  answers the report's 400, /v1/responses and /v1/messages answer), set
  up as the report has it: magpie provider add agentrouter url=...
  key=... models=gpt-5.6-sol and anthropic=..., then responses=..., then
  url= (the chat URL cleared). At each step magpie serve, and curl on
  /v1/chat/completions (whole and streamed) and /v1/messages:
  - Chat and Anthropic URLs: d03779cc answers both chat requests with
    the 400; this tree 200, chat asked once and /v1/messages after it.
  - Chat, Responses and Anthropic URLs: d03779cc answers both chat
    requests with the 400; this tree 200, chat asked once and Responses
    after it (the streamed one went to Responses at once: unfit).
  - The chat URL cleared: both builds 200, the chat requests answered
    on Responses.
  - /v1/messages: 200 at every step on both, from /v1/messages.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
  windows and darwin, and go vet and go build for windows without the
  tag: exit 0 each. go vet and go build without the tag on linux: exit
  1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
  67 ok, and 7 red, none in what this changes: agent
  TestInstalledVersion, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync TestSync
  (#3420); edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram
  (#3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); provider's "close of synctest channel from outside bubble"
  from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
  package's tests after it didn't run: go test ./internal/provider
  -skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
  PATH: ok.

Not tried: the real AgentRouter (no account here), macOS, an agent's
own requests (curl's stood in).

---- provider (second commit of the branch) ----

provider: a model turned away on one API is tested on the next (#3766)

char1eslu (#3766): after Test models, the three models AgentRouter
turns away on chat completions were red in the provider's Models list,
and Working only hid them, while the gateway answered them on
Responses. Their usage rows (kind provider_test, source probe: the
editor's test) were each a 400 on /v1/chat/completions, "模型
gpt-5.6-sol 不支持 /v1/chat/completions 接口,请改用 /v1/responses(OpenAI
Responses API)。". They stayed red after the reporter cleared the chat
URL (magpie provider set agentrouter url=), with their provider test
printing only ✓ responses and ✓ anthropic.

A model's test (testOne) asked one API, the first the provider speaks
unless the vendor's list, the user's pick or the client names another,
and took its answer as the model's. The editor's Test models sends the
editor's form, whose fields that aren't empty win over the saved
provider (typed), so a form that still names a chat URL the saved
provider no longer has asks chat: in the real run below that is red at
d03779cc, as the report's rows are.

Now, when the vendor says the model isn't served there
(catalog.WrongEndpoint: the gateway's wrongEndpoint, moved with its
words so both read the same), the test asks the next API the provider
has a URL for that may serve the model, by the gateway's rule (usable:
the model's listed or picked APIs, else each API the provider isn't
named-only on), with a key that sees the model on that API (keySeeing,
testOne's pick taken out as it was). That API's answer is the model's.
One that says the same has the next asked; when none is left the first
answer stays, so a provider with its Chat URL alone still shows the
vendor's message. Test models, a model's own test and Test as in the
editor, and magpie provider test <id> <model> (--as too), go through
it. As Codex the next API is asked with Codex's headers, as the gateway
sends them on Responses and Chat; as Claude Code the test isn't moved,
since the gateway sends Claude Code's headers on Messages alone.
docs/subsystems/providers-accounts.md says so, and the routing page
points there.

Not changed: which API is asked first, so a model that moved is asked
on chat again at each test before the API that serves it (the
gateway's unfit is its own). magpie provider test <id> with no model,
which tests each endpoint with a model of its own pick (testModel), is
as it was: its chat row can be red for a model the vendor serves
elsewhere, #3844.

What was run (tree 519dee3b, on origin/main d03779cc, go1.26.8,
linux/amd64):
- TestTestModelsMovesToTheAPIServingIt, new: AgentRouter with a Chat
  and a Responses URL and a key for each (sk-chat made for Chat,
  sk-responses for Responses), its chat completions answering the
  report's 400 (its message verbatim; the JSON around it is a guess), as
  it is and escaped. gpt-5.6-sol is OK on Responses, asked on chat with
  sk-chat and then on responses with sk-responses, and nothing else. A
  model chat turns away with new-api's "无可用渠道" (written from memory,
  not from the report) is red after one ask. With the Chat URL alone,
  gpt-5.6-sol is red after one ask, its error the vendor's message. When
  both APIs say it, both are asked and chat's answer stays.
- TestTestModelsKeepsAModelOnItsAPI, new: a model the user picked chat
  for, and one the vendor's list names on chat alone, is red on chat
  after one ask, as the gateway keeps its request there.
- TestTestModelsAsAClientMovesAsTheGatewayDoes, new: turned away on
  Responses with the word, a test as Codex is green on chat, asked with
  Codex's User-Agent; a test as Claude Code is red on Messages after one
  ask.
- The three, -count=50: 150 PASS; the gateway's
  TestChineseRefusalFallsBackToResponses, TestWrongEndpoint and
  TestWrongAPINote at this tree, -count=50: 150 PASS.
- -race -count=20 -cpu 1,2, internal/provider's TestTest and TestDetect
  tests and internal/gateway's WrongEndpoint, WrongAPINote, FallsBack,
  OpenCodeGo and OtherRelayKeepsItsOneAPI ones: ok, no race.
- Broken by hand, each red:
  - the test never hearing the vendor's word, as at the previous
    commit: TestTestModelsMovesToTheAPIServingIt, and
    TestTestModelsAsAClientMovesAsTheGatewayDoes as Codex;
  - the next API asked with the first one's key:
    TestTestModelsMovesToTheAPIServingIt, red on responses;
  - the next API asked whatever API the model is picked or listed on:
    TestTestModelsKeepsAModelOnItsAPI, both models green on responses
    after two asks;
  - a test as Claude Code moved too:
    TestTestModelsAsAClientMovesAsTheGatewayDoes, green on chat;
  - the words in English alone, as at d03779cc:
    TestTestModelsMovesToTheAPIServingIt, the report's message as it is
    and escaped;
  - the words matched in the body as it came:
    TestTestModelsMovesToTheAPIServingIt, escaped.
  The previous commit's own breaks of the words are red at this tree
  too, in the gateway's tests.
- A real run: magpie built at d03779cc, at the previous commit and at
  this tree (go build -tags nogui -buildvcs=false), in a sandbox HOME,
  the previous commit's stand-in and steps. magpie provider test
  agentrouter gpt-5.6-sol:
  - Chat and Anthropic URLs: "✗ chat gpt-5.6-sol · 400 · 模型
    gpt-5.6-sol 不支持 ..." at d03779cc and the previous commit, chat
    asked alone; "✓ anthropic" at this tree, chat asked and then
    /v1/messages.
  - Chat, Responses and Anthropic URLs: the same ✗ chat, then; "✓
    responses" at this tree, chat asked and then /v1/responses.
  - The chat URL cleared: "✓ responses" at all three, responses asked
    alone.
  Then, the chat URL cleared, magpie web's /api/provider/test (the
  editor's Test models) for gpt-5.6-sol: with the form naming the old
  chat URL, red on chat with the vendor's message at d03779cc and the
  previous commit, green on responses at this tree (chat asked, then
  responses); with the form's chat empty, green on responses at all
  three. The gateway answered as at the previous commit.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
  windows and darwin, and go vet and go build for windows without the
  tag: exit 0 each. go vet and go build without the tag on linux: exit
  1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
  67 ok, and 7 red, none in what this changes: agent
  TestCodexDriftReached and TestCodexBehindReverseProxy (#3398);
  TestInstalledVersion, TestHowInstalled,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
  TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640);
  gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); provider's "close of synctest channel from outside bubble"
  from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
  package's tests after it didn't run: go test ./internal/provider
  -skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
  PATH: ok.

Not tried: the editor itself (magpie web's route, which its Test models
posts to, stood in), macOS, the real AgentRouter (no account here).

Review (yetone/magpie maintainer agent): the two commits of
JoeyWu-tech's branch (387191d5a, f8fcf936e, patch sha256 15d451ff…,
as the issue says) squashed into one, one commit per issue. Read every
line. The only other place reading these words, asksResponses (the
note that a provider lacks a Responses URL), reads the Chinese and the
escaped body too; no other matcher of a wrong-API refusal is left
(grep for the English phrases outside catalog.go).

Run at this tree on 6cb1cfb79, macOS, go1.27:
- red by hand: the two Chinese phrases taken out of WrongEndpoint:
  TestChineseRefusalFallsBackToResponses (all four subtests) and
  TestTestModelsMovesToTheAPIServingIt red. The next-API loop in
  testOne off: TestTestModelsMovesToTheAPIServingIt and
  TestTestModelsAsAClientMovesAsTheGatewayDoes red. Green restored.
- real run, macOS: base and patched builds in a sandbox HOME, a fake
  AgentRouter (chat answers the report's literal 400, Responses
  answers), magpie provider add agentrouter url=… responses=…, then
  magpie provider test agentrouter gpt-5.6-sol and magpie serve with a
  /v1/chat/completions request. Base: "✗ chat … 400 · 模型 gpt-5.6-sol
  不支持 …" and the client gets the 400. Patched: "✓ responses", and
  the client gets the answer from /v1/responses (vendor log: chat,
  responses, chat, responses).
- at the pushed head (rebased on 5f3146be0; the docs conflict with
  #3696's sentences merged, both kept): go build ./..., go test
  ./internal/catalog ok; gateway -run
  'WrongEndpoint|WrongAPI|Fallback|FallsBack|Chinese|OtherAPI|Endpoint|OpenCode'
  ok (50s); provider -run 'TestTestModels|TestTest|TestOne|Probe' ok;
  vet linux and windows of the three packages ok; gofmt -l clean.
  The whole gateway and provider packages were not run at this head:
  another session's go test ./... held the machine (one suite at a
  time).

Not tried: the real AgentRouter, the GUI editor itself.
2026-10-27 16:23:20 +08:00
yetone ab546a4eea draw: SenseNova's sensenova-u1.5-lite is an image model, and draws on its images API
lileo0668 (Discord, #help) added SenseNova's API (token.sensenova.cn/v1)
as a provider. sensenova-u1.5-lite showed in its model list but not in
Settings' image generation picker, so magpie's generate_image couldn't
use it.

SenseTime's launch post for U1.5 Lite on the Token Plan says it is an
image model only (no chat), served at /v1/images/generations and
/v1/images/edits in OpenAI's shape; an edit is JSON with
"images": [{"image_url": "<https URL or data URL>"}], and
response_format is url (a 24h link) or b64_json.

- catalog.DrawsID and ImagesAPI know "sensenova-u1" (u1.5-lite,
  u1.5-fast), so the model a vendor's /models lists is a drawer, listed
  in the picker and asked on the images API, not chat.
- drawImages, for those models only: ask for b64_json, and send an edit
  as JSON with the images as [{"image_url": data URL}], the shape
  ChatGPT's backend takes, instead of the multipart form other OpenAI
  images APIs get. No other vendor's request changes.

Test: TestSenseNovaU1Draws (internal/gateway) fetches a fake SenseNova
/models (a chat and the U1 model), checks Drawers lists the U1 model
alone, draws it (images API, b64 back, chat never asked) and edits it
(JSON images). Broken by hand: without "sensenova-u1" in DrawsID it is
red (drawers []); with senseNovaDrawer returning false it is red (the
fake answers a link, image ""), and the edit would go multipart.

Run at this head: gofmt -l (clean), go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go
build -tags nogui, GOOS=windows go build, and
go test -tags nogui -timeout 45m ./internal/catalog ./internal/gateway
./internal/provider ./internal/imagemcp ./internal/gui: catalog, gateway
(566s), imagemcp and gui ok; provider crashes in
TestUnreadLoginsWriteErrorsKeepCredentials (synctest channel closed
from outside its bubble in filememo.Forget), which is #3632, open and
red on main since 091153bf, and not touched here. After the rebase onto
origin/main 8b0132b3d: gofmt, vet (three OSes) and the catalog tests
plus TestSenseNovaU1Draws and the draw tests (-run 'Draw|Image|Edit')
again.

Not tried: a real SenseNova key (none here); its exact /models bytes and
the full answer JSON are from its docs, not a capture. Not run: the full
./... suite (load ~90) and the GUI Playwright suite (no GUI asset
changed). A mask on an edit is passed as in Codex's shape; SenseNova's
docs don't name a mask.

Reported by lileo0668 (Discord).
2026-10-27 16:01:10 +08:00
yetone 6eb510f788 codex: a relay's own Codex entries reach Codex as it gave them (ctopsc on Discord)
ctopsc's custom provider points at a self-hosted sub2api (Responses). Its
plain /v1/models gives id, display_name, owner and created alone; asked
with Codex's client_version it answers Codex's own catalog shape per model
(window, max window, levels, base_instructions, tools, truncation, tiers).
magpie read the plain list and made Codex's entries up from models.dev, so
GPT-6.1 Terra went to Codex at 922000 where the relay said 272000.

What changed:
- catalog: a list row in Codex's shape (slug, supported_reasoning_levels,
  shell_type, base_instructions: CodexEntry) is kept whole on the Model
  (Codex), its window, max window and input modalities read off it.
- provider: for a provider the user added by its address (no preset, no
  account) whose Responses list has no such row, fetchOne asks the same
  URL once more with client_version (codexEntries). Only where the list is
  fetched (add, key change, Refresh), never per Codex poll. The answer only
  adds entries to models the plain list has. One that fails or can't be
  read keeps the last list's entries (a failed read is unknown); one that
  answers plainly says there are none. The entry's levels become the
  model's levels, and withUltra adds none to it.
- codexcat: listedEntry hands Codex the relay's entry as given,
  base_instructions included and unchanged, with magpie's slug, name,
  priority and " via magpie" description. The user's window, compaction,
  levels and image setting still win (levels keep the relay's
  descriptions). A model without one is made as before.
- agent: Codex's magpie-models.json gets the same entries.
- docs: providers-accounts.md, "A relay's Codex entries".

Run at this head (sandbox HOME, pinned caches):
- go test -tags nogui -count=1 ./internal/catalog ./internal/codexcat
  ./internal/provider ./internal/agent ./internal/gateway before the
  rebase onto 508911e43: catalog, codexcat, agent and gateway ok;
  provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials with
  "close of synctest channel from outside bubble" in filememo.Forget,
  which is #3632 (open, not this change).
- After the rebase onto 508911e43 (it changed internal/agent): catalog,
  codexcat ok; agent whole, with TestWSLMoreAgentsPick, TestZooCode and
  TestZooCodeFresh red on "no space left on device" (the machine's disk
  was full), then those three and -run Codex ok; provider -run Codex ok;
  gateway -run Codex ok (its first link failed on the full disk).
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./... and GOOS=windows go vet ./... clean.
- Not run: the full go test ./...; it was started and stopped when the
  disk filled (under 1GB free), and is to be run after the push.

Broken by hand, TestCodexListedEntry red each time (restored after):
- no client_version ask: "asked with client_version 0 times on one
  fetch, want 1";
- listedEntry turned off: service_tiers, levels, model_messages,
  shell_type ("unified_exec"), base_instructions (magpie's "You are
  Codex, based on GPT-5…"), max_context_window and more differ;
- a failed read taken as none: the keeps-last subtest red (truncation
  limit 10000 vs the relay's 12000, shell_type unified_exec);
- the user's levels ignored: all four levels and default "medium".

Not tried: a real sub2api or ctopsc's literal reply (the fixture follows
codex-rs ModelInfo, with values magpie never writes); a Codex binary
reading the list; /backend-api/codex/models directly (same
codexcat.Entries as /v1/codex/models, which the test reads). Not changed:
a user-set models URL is not asked again with client_version, and a
model on a dead side loses its entry with it. A list saved before this
gets the relay's entries at its next Refresh, not by itself.
2026-10-27 14:28:01 +08:00
yetone f51ab771f6 catalog, provider: a model only models.dev's lab lists is known, and a Claude account lists the gated models Anthropic told its Claude Code of (iebb on Discord)
iebb on Discord (10-27): his account has Claude Mythos 5.1, magpie
doesn't list it. models.dev took the gated Mythos 5.1 out of
anthropic's provider list (models.dev #11327) and kept only its lab
file, models/anthropic/claude-mythos-5-1.toml (#11328).

Cause. magpie read only models.dev's api.json (providers -> models).
The Claude subscription's list was exactly catalog.Provider("anthropic"),
so Mythos 5.1 left it with that PR. And a vendor list that still
returns it (an Anthropic key's /v1/models) got no window, reply limit,
name or thinking for it, since nothing read the lab catalog.

Fix.
- catalog: Sync also keeps models.dev's lab catalog (models.json) as
  labs.json beside the cache, through temp+rename; a failed fetch
  keeps the last one, and a cache without it is Stale once a process.
  A model only a lab lists votes into the same tables as a listed one
  (ContextOf, OutputOf, NameOf, Thinks, SeesImages); a model a
  provider lists keeps what providers say. A thinking lab-only model
  with no levels takes those of the newest of its family a provider
  gives (labKinEfforts: Mythos 5.1 takes Mythos 5's). catalog.Describe
  builds a Model from an id for lists that name ids alone.
- provider: the Claude account's list is models.dev's anthropic list
  plus what Anthropic told the account's Claude Code beyond it, read
  from .claude.json's additionalModelOptionsCache / modelAccessCache /
  additionalModelCostsCache (Claude Code's own sign-in and each saved
  account's directory). Account.Lists honours modelAccessCache's
  entitled per account, ListPrice falls back to Anthropic's price
  from additionalModelCostsCache, and the agent's own Claude Code
  picker (claudeOwn) offers the signed-in account's extras. WSL keeps
  the catalog list. magpie still asks Anthropic nothing with a Claude
  sign-in; nothing is sent differently, no Claude Code mimicry change.
- docs/subsystems/providers-accounts.md: two rows, the lab catalog
  and a Claude account's models.

Testdata: models.dev's api.json and models.json as served on 10-27,
cut to the anthropic and azure providers' Claude models and the
anthropic lab. Tests never reach the network.

Run:
- TestLabOnlyModelIsKnown, TestLabsLeaveListedModels, TestSyncKeepsLabs,
  TestClaudeAccountListsGatedModels, TestAnthropicKeyGatedModelDescribed:
  pass.
- go test -count=1 -timeout 45m ./internal/catalog/ ./internal/provider/
  ./internal/agent/ ./internal/gateway/ at 2e165fe9d + this change:
  catalog, agent (362s), gateway (557s) ok; provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
  channel from outside bubble" in filememo.Forget). It crashes the
  same alone on a fresh origin/main 19dc5b925 and is #3632, open.
- rebased onto origin/main 2afacd7d1 (this commit's parent): catalog
  and provider again with -skip TestUnreadLoginsWriteErrorsKeepCredentials,
  both ok. agent and gateway were not run again after the rebase.
- gofmt -l internal/: nothing. go vet for darwin, linux and windows on
  catalog, provider, agent, gateway at the rebased head: ok.
- Real use: magpie built from this tree (linux, nogui) in a golang:1.26.8
  container with a sandbox HOME, so the Mac's Keychain and ~/.claude are
  never read. `magpie sync` fetched models.dev's real catalogs today
  (api.json's anthropic has no claude-mythos-5-1; labs.json has it).
  With a fake Claude sign-in and a .claude.json whose bootstrap caches
  name claude-mythos-5-1, `magpie models` lists claude/claude-mythos-5-1
  "Mythos 5.1" low/medium/high/xhigh; `magpie model spec` gives 1M,
  128k, vision on; `magpie model price` gives $25/$125, cache read
  $2.5, write $31.25 / $50 (1h). A custom Anthropic-protocol provider
  against a fake /v1/models returning claude-mythos-5-1 lists
  fakeanth/claude-mythos-5-1 "Claude Mythos 5.1" with 1M / 128k /
  low..xhigh.

Broken by hand, each red:
- lab reading off in loadGen: every lab assertion in the catalog tests
  and the provider tests (no window, no levels, the API-key entry's
  context 0).
- syncLabs off: TestSyncKeepsLabs.
- labKinEfforts off: the efforts assertions.
- the Claude list back to catalog.Provider("anthropic"): "Claude
  account's list has no Mythos 5.1".
- claudeLists / claudeCodePrice off: the entitlement and price
  assertions.

Not tried:
- a real account with Mythos 5.1: none here. The .claude.json keys and
  shapes were read from Claude Code 2.1.311's own binary, not a real
  account's file.
- a custom Anthropic-protocol provider without catalog=anthropic gets
  no price for a lab-only model (labs carry none).
- the plugin host's mdev() (host.js) reads api.json only; Gemini CLI's
  own picker stays catalog-only; a saved Claude account whose Claude
  Code never ran has no .claude.json, so its gated models show once it
  has run there.
2026-10-27 12:16:33 +08:00
yetone ea33a78a05 provider: a proxy's level- or speed-named model takes its model's levels (nianshou5)
nianshou5 on Discord added their own CLIProxyAPI (CPA) as a custom
provider, and its models offered no reasoning effort in the ChatGPT app
while a plugin's did. CPA's /v1/models gives id, object, created and
owned_by alone (sdk/api/handlers/openai OpenAIModels strips its
registry's thinking levels), so every level comes from magpie borrowing
the model's. That works for an id models.dev knows (gpt-5.5, claude-*,
gemini-*, deepseek-*), but CPA's Antigravity and xAI channels name a
model for the level or speed they serve it at: gemini-3.8-flash-high,
claude-opus-5-5-high, claude-opus-4-6-thinking, gpt-oss-120b-medium,
grok-3-mini-fast. No catalog lists those names, so they had no levels,
and Codex, the ChatGPT app, /v1/models and the gateway's effort fitting
all read none. CPA's own registry gives those models levels or a
thinking budget it fits an effort to.

borrowedEfforts, which is reached only for a model its provider gave
no word on, now tries the id without a trailing
-minimal/-low/-medium/-high/-xhigh/-max/-thinking/-fast
(catalog.Unsuffixed) after every other match failed. A vendor whose own
list names a model so keeps its own word (effortsOf takes the
provider's), and a variant whose base magpie doesn't know
(grok-4.7-build-fast) still takes none. Every list reads Entry.Efforts
or Provider.Known, so Codex CLI's magpie-models.json, the Codex and
ChatGPT apps' /backend-api/codex/models, /v1/codex/models and /v1/models'
reasoning_levels all change together.

The reporter's one visible id, whatstoken/deepseek-v4.1-flash-1017,
already borrowed low,high,max on main against this machine's real
models.dev cache; their other two CPA ids are not known yet (asked on
Discord). So this fixes the class of CPA ids that had none; it may not
be their case.

TestCPAVariantModelsBorrowLevels serves CPA's /v1/models bytes from an
httptest server, fetches them with catalog.Fetch, and checks
Entry.Efforts, Provider.Efforts and the Codex list's
supported_reasoning_levels. It is red with the fallback turned off by
hand (three ids with "" in each list) and green with it.

Run at the pushed head (rebased on origin/main 0b72ccbef):
- go build ./...; GOOS=linux and GOOS=windows go vet ./internal/catalog
  ./internal/provider: ok
- go test -count=1 ./internal/catalog ./internal/codexcat, and
  -run 'CPA|Effort|Level|Borrow|Kin|Host' ./internal/provider: ok
Run at the same change on 7d67910f7, before the rebase:
- gofmt -l internal/: clean
- go test -count=1 ./internal/catalog ./internal/provider
  ./internal/codexcat: ok
- go test -run 'Effort|Level|Reason|Think|Codex.*Catalog|ModelsList'
  ./internal/agent ./internal/gateway: ok
- Against a copy of the real models.dev cache, every id in CPA's
  internal/registry/models/models.json as a custom provider: the five
  suffixed ids above now get their base's levels.
Not run: the full suite (machine at load ~190 with eight suites queued;
not holding the push). Not tried: a real CPA instance or the real
ChatGPT app.
2026-10-25 03:51:20 +08:00
yetone 0b72ccbeff agentplug: connect's models carry /v1/models' native_endpoints and pricing
cleary5779 on Discord builds an agent as an agent plugin and wants, in
connect({ gateway, model, models }), the API each model passes straight
through on and what it costs. Each entry of models (and model) now also
has, by the names /v1/models uses:

  "native_endpoints": ["/v1/chat/completions"],
  "pricing": {"prompt": "0.0000003", "completion": "0.0000012",
              "input_cache_read": "0.00000003"}

Each is left out when not known: a group or a model translated anyway
has no native_endpoints, an unpriced model no pricing, never [] or 0.
The fields connect had (id, name, context, output, images, efforts) are
as they were.

No second lookup: nativeEndpoints moved from the gateway to
provider.NativeEndpoints, and openRouterPricing/perToken to
catalog.OpenRouterPricing/PerToken (internal/catalog/openrouter.go); the
gateway calls them as before. magpieModels already priced each model with
provider.EntryPricer, the price /v1/models gives (m.Price); it now also
keeps NativeEndpoints in catalog.Model.Endpoints (json:"-"), which
plugged's wire turns into the two keys.

Docs: reference.md's agent plugins section (what connect gets, with an
example), agent-wiring and gateway-routing subsystem pages, and the
site's Plugins page in en, zh and ja.

Run at this tree (on origin/main 66b6d6ade), load ~150:
- gofmt -l internal: nothing. go vet on the touched packages,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test ./internal/catalog ./internal/provider: ok (agentplug has no
  tests). go test ./internal/gateway -run 'Models|PerToken|OpenCode|
  Native|Cursor': ok.
- go test ./internal/agent -run 'Plugged|Pi|Price|Alma|ModelOrder|Image|
  Group|Codex': one red, TestCodexThreadsComeBackOffMagpie/disconnect
  (.cache/magpie/sessions.json left in its TempDir), open as #3422; it
  passes 5 of 5 alone and this change doesn't touch sessions.
- TestPluggedConnectSeesEndpointsAndPricing is red with plugged.go's two
  keys taken out (no native_endpoints, no pricing on model or models),
  green with them.
Not run: the full ./... suite (machine at load ~150 with several suites
queued); the whole agent and gateway packages. Not tried: a real agent
plugin reading the fields.
2026-10-25 03:39:50 +08:00
yetone b094a577f5 catalog: a price and an endpoint's catalog are looked up in indexes, and a list is priced at one read of the providers
/v1/models is about to price every model it lists (next commit), and the
lookup it shares with the Usage pages was too slow for a path agents poll:
for 755 models over 30 providers, pricing alone took ~35ms a list.

- catalog.PricedBy walked every model of every models.dev vendor it was
  asked, lower-casing each key, five times over for an id it doesn't
  list (the bare pass, the dashed pass, both canonical passes).
  priceIndexOf builds per provider, once a catalog load (keyed on the
  Reset count read under loadMu, loadGen), the first key by bare id and
  by dashed bare id, and the agreed price under each canonical id.
  Same answers: the old PricedBy, kept beside the new in a scratch test,
  gave the same price and ok for 120,546 ids (every key of the real
  5.9MB models.json, upper-cased, dot-for-dash, with a path and :free,
  with -nope, and each canonical id) over six vendor sets, all vendors
  included.
- catalog.AtEndpoint walked every vendor's API each call (asked by
  EndpointCatalog in every ListPrice); now an index by endpointKey, once
  a load.
- provider.EntryPricer is EntryPriceIn for a list, reading All() once
  instead of once a model (byIDOrWas copied every provider for each);
  EntryPriceIn calls it, and agent.magpieModels (Pi's, dsh's model
  files) prices its list through it too.

Run at 9afa86306 (both commits, on origin/main 40a0b442c), load 73-95:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./...: exit 0, 70 packages ok
  (gateway 810s, agent 652s, provider 306s, catalog 29s); log kept whole
  and grepped, no FAIL. No other ./... suite ran meanwhile.
- go test ./internal/gateway ./internal/catalog ./internal/provider
  again beside it: ok.
- TestModelsListPricing is red with the pricing assignment taken out
  (both the list and GET /v1/models/{id} lose pricing), green with it.
Not tried: a real agent reading the list; Windows run (vet only).
2026-10-25 02:50:12 +08:00
yetone 9b0f48612b gateway: a plugin's model that searches by itself can be the web searcher
01huadalang (Discord #feedback, 10-20): Settings › Web search offered only
Antigravity; Trae's search model couldn't be picked, "可能也有别的模型能搜索
但是识别不到". partSearcher and modelSearches answer false for every
provider with an account behind it, so no plugin-served provider was ever
offered, and a plugin had no way to say which of its models searches.

A plugin now marks such a model with `searches: true` (in its config
models or the list its models hook gives). host.js passes it on,
plugin.Model carries it, and pluginCatalog makes it WebSearch "native".
partSearcher offers a plugin provider with such a model, with those models
only, at rank 4 (as Command Code's search models); remoteSearch asks it in
plain words, the way it asks Command Code's. A client's own web_search
sent to that model still goes to magpie's searcher (searchesModel is
unchanged): the plugin's upstream takes no web_search tool.

Behaviour change: a marked plugin model ranks ahead of Antigravity and
Google (rank 5) when magpie picks the searcher itself.

Run:
- TestPluginSearchModelIsASearcher (new; a fake plugin's model marked
  searches answers a weather question with a URL): red on the old code
  (the picker offers [], want the plugin's fake-search alone), green now.
- Broken by hand: host.js without the `searches` passthrough; the test
  goes red at the picker.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on gateway,
  plugin, provider, catalog.
- set -o pipefail; go test -timeout 45m ./... at this tree: 68 ok, no FAIL.

Not tried: the Trae plugin itself. It declares nothing about search yet;
marking Trae CN's search_agent there needs a Trae account to try it with,
which this machine doesn't have. No GUI files changed.
2026-10-22 03:18:11 +08:00
yetone f73f39050d catalog: a provider's model list is built once a load, without copying every model to the heap for each
Why magpie's own process sat at ~650 MB: a live heap profile of a
user's magpie (magpie heap, 48 minutes) held ~157 MB live but had
allocated 34.8 GB, ~725 MB a minute, so Go's heap peaked near 885 MB
and the footprint followed it. KeepDshWired's round every 30 seconds
was 11.8 GB of it: magpieModels("dsh") → Provider.Catalog → ... →
catalog.Provider for each catalog, which built every model again, and
mdProvider.levels alone was 5.97 GB flat. Its `kin = &x` took the
address of the range variable, so every model of the provider was
copied to the heap for every model asked: allocations grew with the
square of a provider's models.

- levels keeps the kin by id, date and levels, the same choice as
  before (newest by release date, then id, with levels, not after the
  model), with no pointer to the loop's copy.
- Provider keeps each provider's list for the load it was built from
  and gives callers a copy of it; Reset drops them, and a list built
  from a load that a Reset ended meanwhile isn't kept (gen).

Run:
- real models.json (5.8 MB), Provider for every provider id, a pass:
  63.5 MB / 272,952 allocs before; 8.96 MB / 10,478 with the levels fix
  alone; 3.2 MB / 232 with both (a throwaway benchmark, not committed).
- TestProviderAllocsGrowWithModels: red with `kin = &x` put back
  (40012 allocations for 200 models, at most 2000 wanted); red with the
  memo not stored; red with Provider handing out its own slice
  (a caller's change reached the next one). Green on this code.
- go test -race -count=3 ./internal/catalog: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  catalog, provider and agent: ok.
- Full suite, go test -count=1 -timeout 45m ./... on this batch at load
  ~380: every package ok but agent and gateway (past 45m, #2869),
  TestQueueFullAndWaitedOut (#3061), TestRequestBuildsProvidersOnce
  (#2965), TestMainWindowCorners (#2645, red alone on main too) and the
  app.js budget (raised in its own commit). gateway alone: ok but
  TestClaudeAccountsSpentFallBackToCodex (#2858); agent alone past 45m
  at load ~600, its codex/running/connect tests ok alone.

Not done here: a singleflight in provider's heldOf was written and
taken out again; a waiter blocking on another request's build can
deadlock if that build needs a lock the waiter holds, and nothing here
proved it can't.
2026-10-20 20:23:58 +08:00
yetone 81a24cf8fe groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.

What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
  public one). Every old form is still accepted as input forever:
  provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
  gateway (validateModel), keys, stats, affinity and usage, so both ids
  route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
  (allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
  exists, found groups are listed by their old id (AutoRefsOn) and
  auto/<x> means that provider's model. Documented in
  docs/subsystems/gateway-routing.md.

Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).

Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.

Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
  nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
  gateway, whose failures were the tests' expected ids (updated here)
  and two regressions now fixed (bare ids; desktop models hiding groups
  by prefix). Every failing test passes on rerun. Load average was
  ~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
  TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
  10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
  agent failed four tests that still expected the old ids
  (TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
  TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
  Reseat bug above. After the fix, go test -count=1 -timeout 120m
  ./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
  the routing files pass, except routing-bodies, routing-model-rest,
  routing-keys-fold and routing-request-metrics, which fail the same with
  33dbdcc52's JS.

Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.

Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
2026-10-20 00:18:51 +08:00
yetone 224ea7d5be catalog: a reset drops what a request built of the old catalog
5351343e7 keeps what a request built of the catalog for the next
request within heldFor, dropped by every write magpie makes. A reset
of models.dev's catalog (catalog.Reset) wasn't one of them: Sync tells
Touched after it, but a Reset alone left the providers' entries with
the old windows and output limits for up to a second, and Pi's and
Crush's model lists written in that second carried them
(TestPiModelsCarryMaxTokens, TestCrushModelsCarryMaxTokens red in the
full run: "unknown output sent: ...maxTokens:131072"). Reset now tells
Forget (provider.Changed) after it lets go of its lock.

Test: TestHoldKeptUntilAWrite gains "the catalog reset". Broken by
hand (Reset not telling Forget): red, "the catalog reset: built 0
times, want 1", and both agent tests red again; fixed, the agent tests
pass 3 of 3.

Run: go test ./internal/catalog -count 1: ok (3.4s); go test
./internal/provider -run TestHoldKeptUntilAWrite: ok; go test
./internal/agent -run 'TestPiModelsCarryMaxTokens|TestCrushModelsCarryMaxTokens'
-count 3: ok; go vet ./internal/catalog ./internal/provider.
2026-10-19 15:19:31 +08:00
yetone 9f9bfc1600 gateway, provider: a Codex account's models say Codex's 272K window, not models.dev's 922K (netube on Discord)
netube's Codex Plus account showed a 922K context window on Routing.
922000 is models.dev's input limit for gpt-5.5, which is OpenAI's API's
window. Codex holds a ChatGPT plan's conversation to the context_window
its own list gives (272000).

There were two causes:
- codex_backend.go's end() took catalog.ContextOf(model) (models.dev) as
  the window for a turn Codex sent natively. It now takes
  provider.CodexWindow(user, slug), and falls back to models.dev's window
  only when no list says. CodexWindow checks, in order: the window the
  user set on the codex provider; the account's own live list; magpie's
  Codex subscription's list; Codex CLI's models_cache.json.
- catalog.parseCodex dropped context_window, so until the live list was
  fetched, a Codex subscription's models (catalog.Codex) fell back to
  models.dev's 922K. That reached the Providers page and Routing
  (WindowOf), the Entry.Context agents are told, and siwcWithCodex. It
  now keeps Context.

Only Codex is affected. A provider on OpenAI's API that serves the same
id keeps models.dev's 922K, and both tests check that.

Tests:
- TestCodexNativeTurnTakesCodexWindow (gateway): a native turn's
  Prompt.Window is 272000 from models_cache.json, 258000 from the
  subscription's live list, and 400000 when the user sets it. An "oai"
  provider's gpt-5.5 stays at 922000.
- TestCodexModelsTakeCodexWindow (provider): checks WindowOf, CodexWindow
  (and 0 for an unlisted slug), and the catalog entry's Context, with an
  OpenAI API provider kept at 922000.

Broken by hand:
- codex_backend reverted to ContextOf: the gateway test went red, with
  922000 in all three cases.
- parseCodex's Context removed: the gateway test went red on its first
  case, and the provider test went red on WindowOf 922000, CodexWindow 0
  and the catalog entry 922000.
- Restored: both green.

Run:
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows -tags nogui.
- go test -tags nogui -timeout 45m ./... at 7660399a1+this: 64 packages
  ok. internal/agent and internal/gateway hit the 45m timeout under a
  load average of ~270. The running tests were 1s and 6s old
  (TestReseatOff, TestClaudeCodeSeenOnAnyRoute), so this was slowness,
  not a hang.
- Rerun at the rebased head with -timeout 90m: EXIT=0, 66 packages ok, none failed (agent 3761s, gateway 3105s), on cb05dc2d1+this.
- Rebased then onto 252bc61ce (84cd686af and 252bc61ce, internal/agent
  only, none of these files): go build ./..., go vet of gateway, provider,
  catalog and agent, and both new tests green there.
2026-10-17 16:37:09 +08:00
yetone ef6d5ca400 provider: a model's listed APIs, Cline/Kilo free mark and remote price are looked up, not the whole list copied for each, so 2,500 models' /v1/models is 0.8s again (K.Liu on Discord)
K.Liu: /v1/models with 2,000+ models took 2.8s on 127.0.0.1, where it
took 1.6s before, so third-party apps couldn't show the whole list.

Cause: 644ad1ed7 (#2094, first in v0.1.1234) has Exposed() ask
NoAPIFor of every listed model, and NoAPIFor asks ListedAPIs, which
read the saved list through p.live(): catalog.Live copies the list's
chat models (Chat) and ListedAPIs scans that copy, once a model. A
request that doesn't hold the catalog (/v1/models doesn't) did it
2,500 x 2,500 times, and /v1/models' nativeEndpoints did it again for
each row. Bisected with one sandbox HOME (one key provider, 2,500
listed models, all picked), server CPU for 4 requests: v0.1.1207
7.6s, v0.1.1222 8.3s, v0.1.1230 9.0s, v0.1.1232 9.2s, v0.1.1234
18.0s, v0.1.1237 18.0s, main 18.8s.

What changed:
- catalog: readLive indexes the chat models by id once a parse
  (filememo keeps it while the file is unchanged); LiveByID gives a
  model's entries in list order.
- provider: ListedAPIs, clineFreeModel, kiloFreeModel and remotePrice,
  each asked once a model, look the model up through p.liveByID (same
  p.lists() gate as p.live()) instead of scanning a fresh copy. Same
  first-match rules as before.

Measured, same sandbox HOME, 127.0.0.1, machine at load 40-90:
origin/main 4.7-5.9s a request, 18.8-19.6s server CPU for 4; with this
0.6-1.0s, 2.6-3.0s CPU for 4. The /v1/models body, sorted, is byte for
byte the same as origin/main's (2,500 models, 2,487 with
native_endpoints).

Test: TestListedAPIsCostGrowsWithTheList weighs Exposed() for 500 and
2,000 listed models by bytes allocated (not time). On origin/main it
fails "allocated 92034888 bytes for 500 models and 1416709568 for
2000: 15.4 times for 4 times the models"; with this it passes
(-count=3).

Run: gofmt -l clean; go vet -tags nogui for darwin, linux and windows
clean.

Max's report on Discord ("0.1.1265 所有供应商的额度似乎都无法刷新了") was
not reproduced: on v0.1.1265 in a sandbox, key balances and plan cards
refresh from the GUI's refresh, /api/usage/quotas and the background
loop. The one link found: with Gemini or Antigravity quotas, exposedIDs
runs Exposed() for every provider, the same per-model scan this
removes, inside /api/usage/quotas' 12s budget. Unconfirmed as their
cause; asked them for details.

Full suite: set -o pipefail; go test -timeout 45m ./... at 8b84dc902 +
this (sandbox HOME, load average 130-320 from other sessions): 63
packages ok; gui red only in TestPanelJoinsFullScreenSpaces (#2450,
fixed on main since in 63be47717); agent and gateway timed out at 45m
with no failed test. Rerun agent+gateway at -timeout 90m: agent ok
(3913.8s); gateway red in TestPluginStreamLargeReplies JSON_fast /
JSON_throttled (client timeout, filed #2551) and
TestMaxRPMTooLongIs429WithRetryAfter (Retry-After 1 for 2, #1791). An
earlier 60m rerun had agent red with the failing test cut from the log
and TestDesktopSubagentEffortScope red at 30.77s (passes alone, 12.9s).
Both gateway reds pass rerun alone at load ~240 (ok 52.5s).

After rebasing onto e733b0722: go vet -tags nogui ./... for darwin,
linux and windows clean; internal/catalog and internal/provider ok.
2026-10-16 18:51:40 +08:00