Commit Graph
29 Commits
Author SHA1 Message Date
yetone 7a6211d047 providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own.
A key's provider (built-in or custom) can give each model headers
(settings.ModelHeaders["pid/model"]). They go on that provider's
requests for that model alone, after the provider's headers and after
auth: a name both have is sent once, as the model's, so a user's value
is never overridden by the provider's or magpie's key header. The
gateway names the model (provider.WithModel) on every route that asks
one: chat on each API, translated and streamed, count_tokens, System
One's decision, embeddings, images, videos and the model test. A
fallback provider serving the same model id gets its own headers only.
Accounts and plugins carry their sign-in's headers and take none.

The editor's "Name, price and reasoning level" panel is now "Model
settings" (every language), with + Add header per model, staged and
made with the Save; Restore default takes them away.
The rows being typed are kept out of the draft's
compare, so an untouched editor still closes without asking.

Broken by hand: dropping WithModel from gateway.go turns
TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider
id check in modelOf turns TestModelHeadersStayWithTheirProvider red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real vendor that routes by header (Ark); fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetoneandMYCF711 df7c94bdf5 gateway: inline image descriptions survive a restart (#5121)
The vision description cache (Server.sights) was in memory only, so a
restart, update or handover described every image of a long conversation
again (62 calls in 2.5 minutes in the report). Completed descriptions of
inline images are now appended to vision-cache.jsonl (0600) in the config
dir before their waiters are released, and New restores them under the
same 2048-entry LRU. URL images stay in memory (their bytes can change);
failures are never written. Appends and compaction go through a file lock,
a corrupt or truncated line is skipped (and backed up before compaction),
and shutdown waits for pending saves within the drain window.

Patch by MYCF711, applied clean on main. One change: the Unix permission
test now makes the config folder before it pre-creates the file (it failed
on a fresh sandbox, where the folder doesn't exist yet).

Run (mote, at this tree): go test ./internal/gateway filtered to the
vision/sight/cache tests, ok; gofmt -l clean; go vet ./internal/gateway
for linux and windows, clean. Broken by hand: saveSight call removed from
see(), TestDescriptionSurvivesGatewayRestart red (2 descriptions, want 1),
green again with it back. Windows: the same filtered tests on xiaomi-gpu
via win-run. Not tried: full go test ./..., go vet ./... for linux (wails
cgo doesn't build off-platform on mote), a real process kill or a real
handover, a real gateway with a real vision model.

Co-authored-by: MYCF711 <323101370+MYCF711@users.noreply.github.com>
2026-11-04 07:57:43 +08:00
yetone d10f377657 providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each
model, since one model can cost differently on each provider. It has:
each row in a provider's per-model list has a price box (input, output,
cache read, cache write, 1h cache write, long-context tier, $ / 1M
tokens), saved in settings' ModelPrices under pid/model. It wins over
the list price in Usage (usage.Pricer through provider.BasePriceIn) and
in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to
be built; the button opening it said only "Names & levels", so nobody
finds a price there.

What changed:
- The button, its panel's heading and fold, and every note that sends
  the user there say "Names, prices & levels" (zh 名称、价格与推理档位,
  zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen,
  Preise & Stufen"); the gateway's vision and compaction notes, the
  provider package's text, the subsystem pages and the site's start
  docs (en, zh, ja) follow.
- The button's tooltip says it sets what each model costs at this
  provider; Usage's "estimated" tooltip says where a provider's own
  price is set and that it counts over the list price. Both in en, zh,
  zh-TW, ja and de.
- Not changed: the Codex model description text in internal/codexcat
  (it goes to Codex, so a vendor sees it) and core_budget_test's
  history comment.
- app.js: a comment above the price box is shortened so the core
  script stays under its budget, not raised (app.js 116 bytes under
  origin/main).

Run at the pushed head (rebased on origin/main 1af868a15), on mote:
- go test -run 'Budget|ModelPrice|ModelPref|Vision|Compaction'
  ./internal/gui ./internal/provider ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  ok (before the rebase, which touched no Go of this change).
- GUI, both engines, every language each file runs: the 149 files that
  name the label or open a provider's editor (before the rebase): 1191
  ok, 30 red in 7 files. Each of the 7 is red the same way alone at
  origin/main without this change: provider-fetch-again (#5057),
  provider-typed (#4673), provider-levels-scroll webkit (#4395),
  provider-picks-stay (#4397), usage-agents-hide (#3414), usage-ledger
  Requests (#5048), mobile-web (#3952, no .git in mote-run's copy).
  name-suffix-remote "chromium de" (ERR_NAME_NOT_RESOLVED once) passed
  alone at the head. After the rebase: model-price-edit, i18n-keys,
  name-suffix-remote, usage-ledger, usage-agents-hide again: go tests above ok; model-price-edit, i18n-keys and
  name-suffix-remote (all 10 cases) ok; usage-ledger Requests and
  usage-agents-hide red as at origin/main 1af868a15.
Broken by hand: model-price-edit.test.cjs at origin/main's label is red
in all 4 cases (the button "Names, prices & levels" is not found).
Not tried: the whole GUI suite (another session's full suite was on
mote, WSL at load ~100 with 31 test runners); the real app.
2026-11-03 17:00:38 +08:00
yetone 6d23a4282f provider: whether a model sees images doesn't wait for usage readings; start ~9 s → <3 s
magpie's gateway listened ~9 s after start. A goroutine dump 3 s in had
main in provider.Allowances' first-ask wait: the start's migrations
(agent.RenameLegacy) read Pi's effort field, which builds Pi's model list,
which asks provider.Described (does any model see images), which ranks
the vision models by spent accounts, which asks each agent's allowances.
Each agent's first ask waits firstWait (3 s) for its accounts' usage over
the network. Every agent's model list asks Described, so the GUI's first
lists waited the same way.

Described only asks whether a model is there, not which account a request
goes to, so it now runs under provider.Unwaited: Allowances answers from
what is last known (the readings kept on disk) and starts the reading
behind it, as after firstWait. A request routed by the gateway still waits
as before.

Real history in a sandbox HOME (17,140 session files, every account
copied from this Mac's), the network blocked by a dead proxy, `magpie web`
started twice each:
- before (v0.1.2528 tree): gateway up at 9.8 s and 8.8 s.
- this change: 2.8 s and 0.6 s; first /api/sessions answered at 4.5 s and
  2.1 s, against 12.2 s and 10.7 s.

Tests, on mote: TestUnwaitedAllowancesDontWait is new. Broken by hand
(Allowances waiting under Unwaited too) it fails: "took 20.0s".
go test ./internal/provider/ ./internal/gateway/ ./internal/agent/ ok
(gateway 740 s). gofmt -l clean; go vet (darwin), GOOS=windows go vet,
GOOS=linux go vet -tags nogui of provider and gateway ok.

Not run: the full suite; a start with the network up (the wait there
was the vendor's answer time, up to 3 s an agent); Windows and Linux.

Picked onto 2be5d206e (origin/main at push); not run again there.
2026-11-01 11:53:58 +08:00
yetone f435aadbf3 gateway: an image is described once, whatever model describes it, and a canceled request stops its descriptions
Pkh on Discord (0.1.2509, Linux, QwenPaw, Auto routing): with images in
the conversation, the Routing view filled with "Image description" rows,
one request asking for 63 in ~60ms, and the request they were for had no
row of its own.

Causes, each red on origin/main b2145eac1 (the new tests run there):
- A description was kept under the describing model and its level
  (sha256(model, effort, src)): AutoVision's pick changing between turns
  (opencode-go/deepseek-v4.1-flash, auto/qwen3.8-flash) read every image
  again. It is now kept under sightKey: a base64 data URL's decoded bytes
  (strict base64), else the URL, with the level picked in Settings, so
  the same picture on another protocol or media type is described once
  too, and seenBody dedupes by the key.
- describe ran on the first asker's context. Its agent canceling it failed
  the description for every request waiting on it ("context canceled",
  a 502 to a request nobody canceled) and took it out of the cache. The
  work now runs on its own context (WithoutCancel + cancel); a request
  that goes stops waiting, and only the last to go stops it and forgets
  it. A reply that came whole is kept though its asker ended.
- seenBody's queued images took a slot without looking at the context,
  so after a cancel each went on to serve with a dead context and put an
  instant 499 row on the Routing page. One waiting for a slot when its
  request ends is now asked of no one.
- The descriptions' routes are noted on the request's inflight (they run
  on its context), which dropped its "routing" placeholder; a cancel
  then left it no route at all. It now gets one (notDescribed), 499 when
  its agent canceled and 502 else, and the usage record names it. A
  group's request ends 499 on a cancel too.

Not as reported: a failure never threw away good descriptions (only the
failed one went), and seenBody already deduped and shared in-flight work
within the cache; it was the cancel, the model in the key, and the
queued work that made it read everything again.

Run on mote at this tree (rebased on da0005df8):
- gofmt -l internal: clean. go vet ./... on darwin, and GOOS=linux /
  GOOS=windows -tags nogui go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
  (806s); also ok on the earlier bases 8ac1c7a56 (with ./internal/catalog)
  and ccb75030a.
- -race -count=10 on the four new tests, TestUnrouted* and
  TestTextOnlyModelIsGivenTheImagesDescription: ok.

Broken by hand, each red with the named test:
- the model back in the key, and the key by src string:
  TestSameImageDescribedOnceWhateverDescribesIt;
- the work on the first asker's context:
  TestOneRequestGoneLeavesTheDescriptionToAnother (502 context canceled);
- the slot taken without the context: TestCanceledRequestAsksNoMoreDescriptions
  (9 rows, want 4); on origin/main 10;
- no notDescribed: TestCanceledWhileDescribingKeepsItsRoute (no route).

Not tried: Pkh's own QwenPaw conversation and providers; the fix is
tested with a fake describer only. heldSight (unrouted_test.go) now seeds
the cache under sightKey.
2026-11-01 10:50:31 +08:00
yetone 2570efb5f7 gateway: an image the picked model can't describe is described by the next model that sees (kelvinjason11 on X)
kelvinjason11 on X: "图片识别好像只支持一个模型识别 没有fallback". When
the describer (Settings' Image recognition model, or AutoVision's pick)
failed, the turn failed with it, though other models that see were there.

Now describeWith asks the pick first, always. When it fails for any reason
but the client's own cancel, magpie asks the next model that sees: the
first ready one of seersRanked, AutoVision's own order (ready, then
Claude account, Codex, API key, other, then cost), leaving out each model
already tried and each one that turned an image away (sightRefused). At
most 3 models (visionTries), and all of them within visionWaitMost
together: each try gets what is left of it, not a fresh visionTimeout.

- The text header names the model that described the image
  ("as other/bigeye describes it"), not the pick.
- The Routing row of the stand-in carries Instead, Why and Picked
  (describingInstead, the same fields web search's searchingInstead
  sets), and the Routing page says in every language that the pick
  couldn't describe it, why, and which model did instead.
- When none answers, the error is the first failure as before, then
  "nor could X, asked in its place: why" for each other model tried.
- Spent/allowance: each try goes through serve as before, so autoSpent
  and spentModel judge every stand-in the same as they judged the pick.
- vision_mcp's describe_image tool gets the same fallback.

Cache (s.sights): a description is kept under the pick and the image,
whichever model described it, with the describer's name beside it. The
same image sent again asks no one, the stand-in's text is reused, and
its header still names the stand-in. A new image asks the pick first
again, so a pick that comes back is used at once. Failures are not kept.

Settings' text ("When the model in use can't see images, this one
describes them to it") is left as it is: the pick is still asked first
for every image.

Tests (internal/gateway/vision_fallback_test.go):
- TestPickedDescriberThatFailsGivesWayToTheNextThatSees
- TestAutoDescriberThatFailsGivesWayToTheNext
- TestNoDescriberAnswersNamesEach
- TestPickedDescriberThatAnswersIsTheOnlyOneAsked
- TestCanceledDescriptionAsksNoOther
TestDescriberThatCantSeeIsntAskedToDescribe now expects the next model
that sees to describe in place of a text-only pick, not a 502.
GUI: internal/gui/tests/vision-instead.test.cjs (every language, 1100
and 520 wide).

Run on mote at 45739f15b (this tree, on origin/main 74f1df869):
- go test -tags nogui ./internal/gateway/ -count=1 -timeout 45m: ok
  (542.988s). An earlier run while mote was at load ~26 failed four
  Antigravity turned-away tests and TestCodexSpentGrokFailingIsTold.
  None of them touches vision, and all passed in this run.
- gofmt -l: nothing.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok.
- GUI, Chromium: vision-instead, search-instead, routing-vision-why,
  vision-mcp, routing-kind and i18n-keys (4/4) pass.

Broken by hand (in a worktree at 0fcb3acb3):
- The old code with the new tests: Picked, Auto and NoDescriberAnswers
  go red. PickedThatAnswers and Canceled pass, as they should on code
  that never falls back.
- The ctx.Err() check removed from describeWith: Canceled goes red (a
  vision row for other/bigeye appears).
- describeWith made to ask the next model after a success:
  PickedThatAnswers goes red ("eye asked 1 times, bigeye 1").

Not tried:
- The GUI files in WebKit. Playwright's WebKit launch timed out at 180s
  while mote was at load ~25 from other suites. To be rerun.
- vision-instead against the old Routing client, to watch it go red.
- No real account: the fallback was run only against fake upstreams.
2026-10-31 02:28:18 +08:00
yetone b64ec9d64f gateway: a picked model that turns an image away gets it described, not another provider (xyenon)
xyenon (Discord #feedback) picked provider-1/DeepSeek-V4.1-Flash in pi
with an Image recognition model set. An image they sent wasn't
described; the request was answered by provider-2/DeepSeek-V4.1-Flash.

Cause: provider-1's list says nothing of images, so magpie took
models.dev's word for the model (catalog.SeesImages: text+image) and sent
the raw image. The relay answered DeepSeek's 400 "Failed to deserialize
the JSON body ... unknown variant `image_url`, expected `text`". That
matches shapeWords, so the try failed as a shape refusal and went on to
the next candidate: provider-1's fallback (or the next group member),
the same model at provider-2, which sees. The describer was never asked.

Fix: a 400/415/422 whose words say images aren't taken (imageRefused:
unknown variant image_url/input_image/image, OpenAI's "only supported by
certain models", OpenRouter's "no endpoints found that support image",
vLLM's "not a multimodal model", 不支持图片 and the like) marks the model
blind for this server's run (refuseSight; blindTo checks it first). With
a describer, the same candidate is asked again at once with the images
described (seenBody, or seenGroup for a group), before any fallback or
other member; the try reads failSight, which the Routing page tells as
its own story (en/zh/zh-TW/ja/de); the row then reads answered, as
for floor's and foreign's re-asks. Later requests
are described up front, for a direct pick and a group (user or auto)
alike, on Chat, Responses and Messages.

Kept on purpose: with no describer (Image recognition off, or no model
that sees), going on to a candidate whose copy sees is the only way to
answer, so it still does (TestRefusedImageWithNoDescriberGoesToOneThatSees).
Documented in docs/subsystems/gateway-routing.md, "A model that turns an
image away".

Run (on mote, through mote-run):
- TestPickedModelThatRefusesAnImageIsGivenItDescribed (9 subtests:
  direct pick with a fallback, user group, group/auto-…; each API),
  TestRefusedImageWithNoDescriberGoesToOneThatSees, TestImageRefused: ok.
- Broken by hand: with gateway.go/vision.go/routing.go reverted to
  origin/main (d9cf85ae8), all 9 subtests fail with "the same model at
  the other provider was asked 2 times" and the raw image sent there.
- go test -tags nogui ./internal/gateway -count=1 -timeout 45m: ok (996s)
  at the d9cf85ae8 base. After rebasing onto 4534561f6: the new tests
  and -run 'Vision|Image|Shape|Group' in internal/gateway ok, and the
  three vets and gofmt again clean.
- go vet ./internal/gateway (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gateway, gofmt -l: clean.
- GUI: routing-sight (new, 5 languages) and i18n-keys in chromium on
  mote: ok. routing-sight and routing-shape in webkit on the Linux box
  (wsl-run): ok. WebKit on mote couldn't launch (browserType.launch
  timed out at 180s beside other sessions' webkit stuck 2h, routing-shape
  untouched failed the same), so its webkit leg ran on Linux instead.

Not tried: a real pi session against a real text-only DeepSeek relay
(no such account here); the fixture uses DeepSeek's literal 400 body.
The full go test ./... and the whole GUI suite were not run.
2026-10-29 17:23:24 +08:00
yetone 29185e3bbc gateway: a request held too long before routing leaves a report its user can copy
Jason on Discord (#general, v0.1.1995, AirbuildEnvironment over Codex's
/backend-api/codex/responses) got the 2m 504: "magpie held this request
for 2m0s without routing it to any provider ... report it with magpie's
log". The desktop app runs the gateway in-process and logs only to
stderr, so there is no log for him to send.

giveUp now writes a report of the held request to a small file in
magpie's cache (held/, folder 0700, temp file renamed into place, the
newest 5 kept). It holds the time, version, OS, the method and path, the
model and agent, how long it was held, each named wait with its time and
whether it was still under way (noteWait now takes a kind: body, body
room, decision model, image description, plugin hooks, JS middleware,
Codex reset, masking), the body room's state, the requests in flight,
and a goroutine profile (function names and lines only, cut at 128KB).
It holds no body and no headers. Route.Held names the file. On the
Routing page, the request's story then says a report was saved, with
Copy Report and Open Folder (Open Folder is left out in magpie web).
GET /api/gateway/held/{name} reads only a report's own name. The 504's
text no longer points to a log: it names Copy Report on the Routing page
and the folder. The log line names the waits too. i18n is in zh, zh-TW,
ja and de, and docs/subsystems/gateway-routing.md has the section.

What held Jason's request is not known from what he sent. The waits that
count before routing are: the body arriving (idle deadline only), body
room (up to 100s, then 503), the decision model (see the next commit),
plugin hooks (11s), JS middleware (250ms a hook), image description
(bounded by the request) and the Codex reset (20s). Slots, RPM and
upstream come after the route begins. A WebSocket upgrade gets a 426.
The report names the wait, so the next one says which.

Run:
- mote, at 57b21abd9 before the rebase: go test ./internal/gateway
  -run 'Unrouted|Held|...' passed. The full go test ./... -timeout 45m
  was cut off when mote dropped off the network (2 packages ok). The
  full suite then went to the Windows box (see the next commit).
- xiaomi-gpu (Windows), node --test: routing-held-report 50/50 in
  chromium and webkit, 5 languages, 1100/420px, app and web.
  routing-held-request and i18n-keys pass. All routing-* and i18n*:
  1742 tests, 94 reds, none in i18n*. The same files are red alone at
  origin/main 033b17baf (22 of 46 in WebKit), recorded on #4124.
- GOOS=windows/darwin go vet ./internal/gateway ./internal/gui,
  GOOS=linux go vet ./internal/gateway, go build ./... : ok.
Broken by hand: leaving Route.Held unset turned
TestUnroutedHeldReportSaved red ("names no report"). Dropping the
story's report line in client.js turned routing-held-report red in both
engines.
Not tried: a real held request in the real app. Linux vet of
internal/gui (cgo for Wails, cross-compiled). The GUI test on macOS
WebKit, since mote was unreachable.
2026-10-29 15:10:34 +08:00
JoeyWu-tech 430e3050d8 gateway: magpie's own searches and image descriptions go without the agent's middleware (#3695)
aiirobyte (#3695): the gateway exited five times on 2026-10-26, and
every client was refused until it was started again. The one exit with
a stack died of "fatal error: concurrent map read and map write": two
of seenBody's goroutines in middleware.(*Run).Tried at once, one of
them in moejs's InternGoString.

A request's middleware runs in runtimes of the request's own
(serveAgent). Only one goroutine may use a runtime at a time (moejs),
and Run has no lock to hold callers to it. serve runs each try's
onProvider on them (triedOn) through the Tried the request's context
carries. For a model that can't see, magpie has each image of the
request described (seenBody), up to four at a time, and each
description is a request it makes of its own gateway on a context made
from the agent's (magpieChose(ctx)). So the descriptions carried the
agent's Tried and ran onProvider on one runtime from as many
goroutines. A model that can't search has its searches made the same
way (searchWith): a search is asked beside the agent's own stream,
which goes through the middleware's onEvent, and beside the round's
other searches, so one search is enough to share the runtime when the
middleware has onEvent. The runtime's maps were read and written from
two goroutines and the gateway died. When it didn't, the calls' values
crossed. In the runs below, hooks threw on values that weren't there
("Cannot read properties of undefined (reading 'push')", and "(reading
'messages')"), and a description went out as
{"0":0,"messages":[0,{"content":[0,{"image_url":0}],...}],...}, its
max_tokens, system prompt, text and image each turned into 0. An
earlier run of the same break (tree e1c90a00, this code with older
comments) had one image asked about twice and another never.

ownAsk takes the request's Tried off the context of those two asks, so
they go without the agent's middleware, as serveAgent's comment already
said of them ("search and vision stand-ins") and as magpie's other own
requests (titles, the classifier) go. The agent's own tries are as
before: each runs onProvider once, on its runtime. The subsystem page
now says why, and the user docs (en, zh, ja) name searches and image
descriptions among magpie's own requests.

Going without also keeps what the docs tell a hook. Its ctx.protocol,
ctx.model and ctx.stream are the agent's request's, while a
description's body is a Chat request and a search's an Anthropic one,
whatever the agent speaks. A description is also kept for later
requests (sights), so one asked through a request's middleware was
handed to later requests, other agents' too. The one community
middleware with onProvider, antigravity-cloak, rewrites Claude Code's
and Codex's lines in the system prompt, which a description's or a
search's prompt, magpie's own, doesn't have.

Not changed: the report's other fixes, a lock over the runtime, one ask
at a time, or a Run per ask. Each keeps the gateway up but still runs
the agent's middleware on asks that are magpie's own, which the docs
say go without it, and with the first two onProvider still gets bodies
its ctx doesn't describe. With ownAsk nothing else uses a request's Run
from two goroutines (holdWriter's keepalive writes under the h.mu the
handler's writes hold). magpieChose is left as it is: it says whose
pick a call is, and its other callers, Codex's thread titles,
descriptions and predictions (codex_titles.go), run before serveAgent
with no Tried to take off.

What was run (tree 4f97ac18, on origin/main 865df247, go1.26.8,
linux/amd64):
- TestImagesDescribedWithoutTheAgentsMiddleware, new: a text-only model
  asked with four images, and a middleware whose onProvider adds a line
  naming the provider's model. The four descriptions reach the model
  that sees without the line, the text model's request has it, and
  onProvider is called once, with no failure.
- TestSearchesWithoutTheAgentsMiddleware, new: a model that can't
  search makes two web_search calls in one round, with a middleware that
  has onProvider and onEvent. Both searches reach the searcher without
  the line, the model is asked twice, its first ask with it (the second
  goes on from that ask's body), and no hook failed.
- Both, without -race: -count=50 -v, 100 PASS; -count=40 three more
  times, ok.
- go test -tags nogui -race -count=20 -cpu 1,2 ./internal/gateway with
  this -run, ok, no race:
  'WithoutTheAgentsMiddleware|TestMiddleware|TestTextOnlyModel|TestVisionSetting|TestImageThatCant|TestGroupsTextOnly|TestDescriberThatCant|TestSeerPicks|TestManyImages|TestWebSearch'
- Broken by hand, each run with -race -count=1, then without -race at
  -count=40 three times:
  - main's vision.go: the test red, onProvider called 5 times (each
    description and the agent's try), 3 of the calls throwing "Cannot
    read properties of undefined" (reading 'push' twice, 'messages'
    once), the fourth description reaching the model that sees through
    the middleware as the mangled body above, races reported. At
    -count=40 all three runs died: of "concurrent map read and map
    write" in InternGoString (intern.go:167) twice, and of "concurrent
    map writes" in internASCII (intern.go:195) once.
  - main's search.go: the test red, both searches through the
    middleware, races reported. At -count=40 each run had 40 of 40 red,
    and none died.
  - ownAsk returning the context as it is: both tests red, races
    reported. At -count=40 all three runs died of "concurrent map read
    and map write" in InternGoString.
- A real run: magpie built at 865df247 and at this tree (go build -tags
  nogui -buildvcs=false), magpie serve in a sandbox HOME, a provider (a
  local server) with a text-only model and one that sees (from its
  /v1/models' modalities), Settings' vision model set to the one that
  sees, and a middleware added with magpie plugin add whose onProvider
  adds a line. 200 requests to the text-only model on
  /v1/chat/completions, four new images each, twice per build.
  865df247's gateway answered 6 and died on the 7th request, of
  "concurrent map read and map write" at the report's intern.go:167 in
  InternGoString, reached from Run.Tried; in the other run it answered
  7 and died on the 8th, of "concurrent map writes". 24 and 28
  descriptions reached the vendor, all but one with the line; that
  one's onProvider threw "Cannot read properties of undefined (reading
  'push')", so it went as it was. This tree's answered 200 of 200 both
  times, its 800 descriptions without the line and its 200 text
  requests with it.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
  nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go
  build -tags nogui ./... and GOOS=windows go build ./...: exit 0
  each. go vet and go build without the tag on linux: exit 1 (this box
  has no GTK or WebKitGTK dev packages).
- node --test site/*.test.mjs, as CI runs it (node v22.22.1): 45 pass
  (none of them reads plugins.html).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
  (systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
  45m, log kept): 65 ok, and 7 red, none in what this changes:
  - agent TestCodexDriftReached and TestCodexBehindReverseProxy: #3398;
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
    and TestZedAppPath: #3141;
    TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
    #3641.
  - edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram: this
    box's umask 077, #3640.
  - gateway TestPluginToldWhereTheAgentWorks, the package's only red:
    this box's /tmp/.git, #3675.
  - gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
    this box's millions of open fds, #3649.
  - pii TestFindJoinsTextsAndMapsBack, TestGPUDeathMovesToCPU,
    TestServeStartsWithoutResidencyHeartbeat and TestWarm: #3741, fixed
    on main by c84f859d.
  - provider: "fatal error: close of synctest channel from outside
    bubble", #3632; the package's tests after it didn't run.

Not tried: macOS, Windows (built and vetted only), the reporter's
middleware (the report doesn't name it), a real vision model or
searcher.
2026-10-27 15:47:49 +08:00
yetone 5a94eec3ae gateway: a request held 30s before routing in no known wait is answered then
sharwowwow on X: "转圈两分钟才报 504,这个超时阈值本身就很折磨人。网关要是能
早点失败、早点给明确错误,排查能省不少时间。" A request held before any
route was answered 504 only after unroutedMost (2m), whatever held it.

Now the time a request spends in a wait magpie knows of is added up as it
happens (noteWait/waited, the union of overlapping waits), and a request
held unroutedUnknown (30s) outside them gets the same 504 and message
then. unroutedMost (2m) stays the cap for one in known waits. Known waits,
each read from the code between counted and noteRoute:
- the request's body arriving: r.Body is wrapped (waitedBody), so every
  read of it (keyLimited, requestBody, readRequestBody) counts;
- masking (noteMasking);
- System One's or the decision model's classifier (askWaited);
- an image's description (seenBody);
- Codex's auto reset before the route (autoReset);
- plugins' gateway hooks / plugin host start (GatewayBegin) and JS
  gateway middleware (Begin, Request);
- every notePhase (slot, rpm, upstream); these come after the route for
  watched requests today, so it only guards a future change.
What is left is magpie's own work (catalog build, parsing, planning,
affine, reading the usage log), ~8.5s at its slowest (a cold catalog
sync); 30s is about three times that, with room for a loaded machine.
The log says "30s of it in no wait magpie knows of".

Run at this tree (rebased on origin/main 9120acaff):
- gofmt -l internal/gateway: clean.
- go vet ./internal/gateway/... on darwin, GOOS=linux, GOOS=windows: ok.
- go test -timeout 45m ./internal/gateway/...: ok (478.0s).
  Also ok on the earlier bases a5ce158e5 (655.8s) and 7d075df9d (448.1s).
Not run: the full go test ./... and go vet ./..., because the machine's
disk was full (under 1GB free for over 20 minutes; a build and one
gateway run failed with "no space left on device", every red naming it). No -race run.

Broken by hand, each test red, then restored:
- without the 30s answer (u.giveUp(true)),
  TestUnroutedUnknownHoldAnsweredSooner: not answered before unroutedMost;
- without the body wrap, TestUnroutedSlowBodyNotCutOff: answered 504
  while its body was still arriving;
- without masking's excuse, TestUnroutedMaskingNotCutOff: answered 504
  while it was masked.
TestUnroutedSlotWaitNotCutOff stays green without notePhase's excuse (the
slot wait is after the route); it guards that a slot wait is never cut.

Not tried: no test of its own for the classifier, auto reset, gateway
hook, JS middleware or image-description excuses; no run in the real app
or against a real provider.
2026-10-26 19:04:27 +08:00
yetone 4a3e07f1cf model: magpie model spec sets a model's window, output, vision and levels at once
Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models
(kenari/*:free) had no window, reply limit, vision or reasoning known,
and there was no one place to say them.

  magpie model spec <provider/model>                 what it has, and whose each value is
  magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto]
  magpie model spec '<provider>/*' --context <n> --output <n>
  magpie model spec <provider/model> --reset
  magpie model specs

It writes the stores magpie model context/output/images/efforts write
(providers.json contexts; settings.json modelOutputs, modelImages,
modelEfforts, modelReasonless), so every reader that went by those goes
by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's
/api/providers badges and chips, and the agents' model lists. Every
part is checked before anything is written; a refused command writes
nothing. Agents are told once.

Readers that bypassed the stores and now honour them:
- provider.Efforts returns the kept levels, so the gateway fits a
  request to them (fitEffort): xhigh asked of a model kept to low-high
  goes as high. This reverses #92 (47e12df41), which narrowed only the
  lists handed out; docs/subsystems/gateway-routing.md says so.
- entryFor: levels given a model with none known make it Reasoning.
- gateway AutoVision picks by the user's ModelImages (seesAt).
- GUI gateway client: a reasonless model offers no level chips.

Run at this tree (base a93190ae1):
- go test -count=1 -timeout 45m ./internal/{provider,cli,gui,gateway,
  settings,tui,agent,catalog}: all ok (gateway 505s, agent 360s).
- GUI: gateway-*.test.cjs, model-reasonless, plugin-gateway, i18n-keys
  (25 files, both engines, the new file at 1100 and 420 in en, zh,
  zh-TW, ja, de): 225/225 pass. app.js untouched.
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Sandbox HOME, built binary, `magpie web` on 47821/47820 and a fake
  Chat vendor on 47811: before, kenari/glm-5:free had no window or
  levels; after spec 128k/16k/on/low-high, /v1/models said 128000,
  16000, image input, [low medium high]; max_tokens 100000 went as
  16000, xhigh as high, low as low; qwen-x with --reasoning off was
  sent no reasoning field; /api/providers had context 128000, output
  16000, images/imageSet, kept [low medium high], reasonless for qwen-x.
  A models.dev sync during the run (GLM-5 202752/131072) didn't move
  the spec; after --reset the vendor's values came back. Bad values,
  an unknown flag and --help wrote nothing (files hashed).

Rebased onto a6a3dbde8 (the ZCode mover's min, one line): at the
pushed head 5af093d8b's tree, ./internal/provider and ./internal/cli
-timeout 45m ok, and the spec tests in gateway and gui ok.

Broken by hand, each went red: AutoVision on raw sees; Efforts on the
full list; the Reasoning line removed; output, vision or context not
written; ParseLevels skipped; agents told twice; --context 0 taken;
help printing modelUsage; old client.js; the GUI named() image and
reasonless branches.

Not tried / not changed: no full go test ./... (another session's
full GUI suite was running). Codex's ChatGPT-model /models pass-through
and the Codex effort dropdown read catalog.Codex(), not a spec. The
TUI shows no spec badges. A Context-tab trace keeps the window it was
recorded with. Pre-existing and the same on origin/main a6a3dbde8: a
GLM-5 relay with no levels known has xhigh sent as high.
2026-10-24 05:31:59 +08:00
yetone 243aa709b2 gateway: AutoVision and the searcher's pick keep each provider's ranked models until a list, a provider or a setting changes
Why: a live heap profile of the app (yg6888 on X, ~1 GB held) had
36 GB allocated, and 5.3 GB of it was under seer -> autoVision ->
smallModelWhere. 4.8 GB of that came through agent.magpieModels
(provider.Described, asked for every agent's model list: dsh every 30s,
and the window's state). Each AutoVision did three things for every
provider that was on:
- built its Exposed list twice: once in smallReady, then again only to
  read the picked model's price;
- asked spentModel (perKeyBarred, 1.4 GB) about every candidate model,
  before picking one;
- copied the list three times in pickSmall.
The searcher's pick (searcherReady, Searchers, chosenSearcher) goes
through the same smallReady. For a Remote magpie it asked
p.Available() once per model (remoteSearch).

What changed:
- rankSmall puts the candidates in pickSmall's order once. pickSmall of
  any subset is the first of that subset in this order, and
  TestRankSmallIsPickSmall checks that against the old pickSmall over
  2000 random lists and subsets. smallReadyOf then asks spentModel in
  rank order and stops at the first model with allowance. The model it
  picks, and whether it is ready, are the same as before. Usually only
  one model is asked.
- The candidate carries its cost, so smallModelWhere no longer builds
  Exposed a second time.
- keptSmallCands keeps each provider's ranked candidates in
  stamped[smallKey, []smallCand]. The key is the provider id, the
  signed-in account (agent, user, plan, home) and which filter ("sees",
  "search"). Entries are dropped when provider.StampNow moves, or
  after stampedFor (1 minute).
- provider.StampNow (hold.go, added with dsh's round) is made of:
  - held.gen, which Changed moves: a provider saved, an account,
    catalog.SaveLive/Touched/Reset, a plugin's change;
  - filememo.Gen (settings.Save and every other write this process
    makes);
  - environSum;
  - the time and size of the providers' file, the settings file and the
    catalog's cache file, so a write by another magpie (the CLI) counts
    too.
  The one-minute backstop covers what nothing signals: a list another
  magpie fetched, or another program changing an existing account's
  model list. A new account is a new key, so it is seen at once (within
  provider.Accounts' own 30s).
- Whether a model is out of its allowance (spentModel) is still asked
  on every call, never kept. Two callers building one key at the same
  time each build it. Nothing waits on another, and nothing is built
  under the lock.

Measured on the real path: a sandbox HOME with the live
~/.cache/magpie/models.json (5.8 MB, 231 providers) copied in, 12 API
key providers (openrouter, anthropic, openai, google, deepseek,
nano-gpt, vercel, kilo, requesty, aihubmix, zenmux, poe), and the
catalog.Provider fix 4f044c24c applied to both sides. The benchmark is
go test -bench, -benchtime 2s, not committed. The pick is
requesty/mimo-v2.6-flash before and after.

| Benchmark | Before | After |
| --- | --- | --- |
| AutoVision | 769.7 ms, 22,075,218 B, 73,732 allocs/op | 7.3 ms, 238,201 B, 1,134 allocs/op |
| AutoVision under provider.Hold | 347.8 ms, 21,532,432 B, 69,061 allocs/op | 2.1 ms, 85,207 B, 244 allocs/op |

What is left is mostly provider.All, which reads the accounts.

Tests:
- TestAutoVisionDoesNotBuildListsAgain: AllocsPerRun of AutoVision and
  searcherModel with 4 and with 400 listed models. It allows 50
  allocations of difference: 521 against 527.
  - Broken by hand (stamped.get always builds), it went red at 611
    against 1055.
- TestAutoVisionSeesEachChange checks that each change is picked up:
  - picks changed through provider.Save;
  - a vendor's list re-fetched with new prices (catalog.SaveLive);
  - providers.json rewritten directly, as another magpie would;
  - settings.Save moving the stamp;
  - a Codex sign-in written into the same HOME.
  Broken by hand (the stamp ignored, only the minute kept), it went red
  at "AutoVision = "" after Haiku and Gemini were enabled". Run with the
  other AutoVision tests, TestAutoVisionPassesOverOneOut went red too.
- TestAutoVisionKeptListsAskAllowanceEachTime checks that a used-up
  Codex account is seen on the very next call.

Run:
- gofmt -l internal/: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- set -o pipefail; go test -count=1 -timeout 45m ./internal/gateway/
  ./internal/provider/ ./internal/catalog/ ./internal/gui/, at load
  ~400 (other sessions' suites), with 4f044c24c applied:
  - gateway ok 2259.7s, provider ok 821.8s, catalog ok 16.5s.
  - gui FAIL in two tests that fail the same way without this change.
    Each was run alone, with these files reverted, on 28bcd4f7e:
    - TestMainWindowCorners: the real AppKit window was killed at its
      40s deadline, alone too (#1936, #2645).
    - TestSetAnswersWhileDevinAndProvidersHang: setting slow/slow-1
      took 10.9s against its 10s bound. Alone it took 3.3 to 5.4s with
      this change and 4.6 to 5.9s without it, passing 3 of 3 (#1375).
- The new tests were run again after the split into two commits:
  go test -run 'TestInfoCounts|TestAutoVision|TestRankSmall|Searcher'
  ./internal/gateway/: ok.
2026-10-20 20:32:05 +08:00
yetone 11173c8a20 gateway: a long Computer Use turn fits each screenshot once, not every turn (fflake33 on Discord)
fflake33 (magpie 0.1.1279, macOS) sent Codex Computer Use turns of
570K-680K tokens with hundreds of screenshots through the Responses
route to codex/gpt-6.1-sol: 26.5s and 52.7s of the 41.7s and 71s to the
first token were magpie's own work, sampled in image resize, JPEG
decode/encode and JSON.

The causes, from a pprof CPU and alloc profile of a synthetic turn (160
distinct 2940x1912 JPEG screenshots, 112 MB body):
- codexImagesFit's cache of fitted images was a map cleared at 64
  entries, so past 64 screenshots every image of every turn was decoded,
  resized and JPEG-encoded again: ~19s CPU a turn (triangleResize 42 GB
  allocated over 3 turns).
- It looked each part up by path from the top of the body
  (gjson "input.%d.content.%d"), reading the 112 MB body again for every
  image: ~9s CPU a turn.

What changed:
- codexImagesFit walks the body once (ForEach over items and parts, at
  their offsets) and splices only the changed image strings; the rest of
  the body goes byte for byte as before.
- The cache (fitted) is an LRU keyed by sha256 of the limits and data
  URL, bounded at 256 MB of fitted bytes and 8192 entries, letting go of
  what goes unsent for an hour. It holds the encoded bytes, not the
  base64. A request looks all its images up before keeping any it made,
  so a conversation larger than the budget still finds what was kept
  since its last turn.
- Images not kept are made side by side, at most min(4, GOMAXPROCS) at
  once (each holds ~100 MB for a Retina screenshot); the same image twice
  in one request is made once.
- Sibling: the describer's cache (vision.go sights) was FIFO at 256, so a
  text-only model sent 300 screenshots described every one again each
  turn. It is now LRU at 2048 (a description is a few KB).

Numbers, codex_images_timing_test.go (MAGPIE_TURN_TIMING=1), magpie's
time before the fake upstream had the request, 160-163 screenshots, run
back to back at load ~15-60 on this M-series mac:
- before (de671719a): turns 1-4 31.4s, 30.6s, 31.7s, 35.2s; CPU
  27.5-28.4s per turn (pprof labels per turn)
- after: turn 1 7.5s (18.4s CPU, 160 images made in parallel), turns 2-4
  2.7s, 2.6s, 5.2s; CPU 2.4-2.6s per turn
The ~2.4s left per 112 MB turn is whole-body JSON passes (decodeJSON with
jsonValid and RawMessage clones, parseResponses, codexBody's re-marshal,
~0.4-0.8s each); not changed here, as each needs its byte-for-byte output
re-proven.

echo_ts (Codex through magpie on Copilot ~10x slower, no images): the
same timing test on a Copilot account with no images measured magpie's
local work at ~3ms (33 KB), ~13ms (215 KB) and ~56ms (989 KB) per turn
on the old code at low load, the same on the new. That is not a 10x, so
its cause is elsewhere and is not fixed here.

Tests, each broken by hand and seen red:
- TestCodexScreenshotsAreNotFittedAgainEachTurn: 100 then 101 distinct
  screenshots; the second turn makes only its new one, and sends the
  others as the same bytes. Clear-at-64 restored: "made 65 images again".
- TestCodexFittedImagesPastTheBudget: 30 images over a budget of 10;
  turns 2 and 3 make 20 each, held bytes within budget. Keeping each
  image as it is made: 30 of 30 each turn; budget unchecked: held past it.
- TestCodexFittedImagesLetGoWhenIdle.
- TestManyImagesDescribedOnce: 300 images twice to a text-only model are
  described 300 times. sightsKept 256 restored: 576.

Run: gofmt -l (clean); go vet ./... on darwin, GOOS=linux and
GOOS=windows -tags nogui; go test -race on the gateway's TestCodex*,
TestManyImagesDescribedOnce and TestTextOnlyModel* (ok); full
`set -o pipefail; go test -timeout 45m ./...` at ab88ffd55 (this
change on origin/main 2026-10-18 21:4x): every package ok except
internal/agent, which hit the 45m package timeout under load ~200
(running TestT3CodeKeepsTheUsersSettings at 0s, the known #2544/#2723);
alone with -timeout 90m it is ok (4385s, load ~250-350). gateway ok in
2600s, provider ok in 438s.

Not tried: a real Computer Use session against ChatGPT; Windows or
Linux runs of the timing test.
2026-10-19 00:26:39 +08:00
yetone 6f950653fc gateway, codex: a model turned away for an image says why magpie takes it for text-only and where Accepts images is (KimYx0207 on X)
mark_li21 pasted an image in Codex through magpie and was told the model
doesn't take images, with no hint of why or where that is changed;
KimYx0207 asked that the refusal say the model's list has no image input
and point to Providers → Names & levels, so nobody switches models or
reinstalls Codex first.

Codex turns the image away itself ("… does not support image inputs.
Remove images or switch models."), and magpie can't word that. What it
can:

- Codex's /model: a model magpie hands Codex without "image" now reads
  "<name> (text only: Accepts images is in its provider's Names & levels
  in magpie) via magpie". It still ends " via magpie", which is how
  catalog.MagpieAdded tells magpie's entries from Codex's own. A model
  that sees and a routing group read as before.
- The gateway's own 400 (every other agent): after "does not support
  image input" it says why — Accepts images turned off by the user for
  it, or the provider's model list marking it as not taking images, or no
  model in the group marked as taking images — and names
  Providers → <provider> → Names & levels, before the note on image
  recognition it already gave.

Tests: TestCodexCatalogSaysTextOnly; TestTextOnlyRefusalSaysWhyAndWhere
(the user's own answer, a group); TestKnownTextOnlyModelRejectsImagesBeforeUpstream
now checks the why and the where on all four APIs. With codexcat.go and
gateway.go put back, all three are red.

Real use: a catalog from codexcat.Catalog handed to Codex 0.162.1 under a
sandbox CODEX_HOME (model_catalog_json, a dead provider URL); /model
lists "Text Model (text only: Accepts images is in its provider's Names
& levels in magpie) via magpie" and "Sees Model via magpie". Pasting an
image there wasn't tried.

Run at origin/main df3734b95 + this change: go test -tags nogui
-timeout 45m ./... 66 packages ok; gofmt -l clean; GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. No GUI file changed, so the
GUI suite wasn't run.
2026-10-17 06:29:57 +08:00
yetone ad312dfee9 zhipu: a 1308 or 1310's reset time, written with no zone, is read as Beijing's, and a held refusal says its time with the offset (Player on Discord)
Player reached a Remote magpie with a GLM Coding Plan key: "Z.ai:
[1308][Usage limit reached for 5 hour. Your limit will reset at 2026-10-15
20:12 (out of its allowance: not asked again before 17:12)". Z.ai's 1308
and 1310 ("Usage limit reached for N hour. Your limit will reset at
YYYY-MM-DD HH:MM:SS", bigmodel.cn "您的限额将在 … 重置") write the time
with no zone. It is UTC+8: code-yeongyu/senpi#3348 has a 1308 received at
2026-09-21T17:17:32Z saying 01:18:11, 39s later as UTC+8 and 8h later as
UTC; kodustech/kodus-ai#2104 and openclaw/openclaw#97764 show the same
zone-less form for 1310. resetsWhen reads only a time with its offset, so
nothing read it: the key rested quotaRest (15 min), the held refusal said
"not asked again before" a quarter-hour on (17:12, this magpie's local
time with no zone), and after it Z.ai was asked and refused again until
20:12 Beijing time.

- routing.go: zhipuResets/resetsZhipu read Zhipu's own words ("Your limit
  will reset at", "您的限额将在") then a whole date and a time to the
  minute at least, in UTC+8; not when a digit, colon or zone follows
  (cut in its seconds, or a zone of its own, which resetsWritten reads).
  resetsAt tries it after resetsWritten, so restAfter and keepRetry both
  see it, for the built-in key, a relay passing it on, and a Remote
  magpie's held refusal.
- heldClock: a held time is given as "20:12 UTC+8" (today) or
  "Oct 16 09:00 UTC+8", since its reader may be a Remote magpie's user on
  another clock. Siblings: the quota-held 429 (gateway.go), the capped
  window error (fallback.go), the spent searcher (search.go) and describer
  (vision.go), all of which wrote Local() with no zone.
- docs/subsystems/gateway-routing.md says both.

The "manual weekly reset" was Z.ai's weekly reset card, spent on Z.ai's
site (magpie only counts them, b69b0e810). It clears the weekly window;
the 5-hour window stays full, which is the 1308 Player got. Not a magpie
bug.

The held message's parenthesis is balanced in the code; Player's quote
was cut before the ")".

Run:
- TestResetsZhipu: Player's literal words (no seconds), Z.ai's OpenAI and
  Anthropic envelopes, senpi#3348's case (39s), kodus#2104's 1310,
  bigmodel.cn's Chinese raw and \u-escaped, a Remote magpie's held line;
  not read: cut in seconds/after the colon/in the minute/in the date, its
  own UTC/+00:00/Z, month 13, hour 25, past, over a week, WorkBuddy's
  words without offset, a date in passing.
- TestHeldClock in UTC+8, UTC and UTC-3:30, today and tomorrow.
- TestZhipuRestsUntilItsReset: a 1308 three hours off rests the key three
  hours (Retry-After), Z.ai asked once, and the held refusal names the
  time with its offset.
- Broken by hand: resetsZhipu taken out of resetsAt, TestResetsZhipu and
  TestZhipuRestsUntilItsReset go red (Retry-After "900"; held refusal
  "Z.ai reset at 20:12:53 … not asked again before 17:27 UTC+8", the
  reporter's bug); heldClock put back to Local().Format("15:04"), the
  end-to-end test goes red ("not asked again before 20:13").
- go test -tags nogui -p 1 -run 'Zhipu|Reset|Rest|Held|Quota|Cap|Spent|
  Searcher|Vision|Written' ./internal/gateway: ok.
- gofmt -l clean; go vet -tags nogui ./... on darwin, linux, windows: ok.
- The full suite ran out of disk on this machine (df / down to ~1 GB,
  45 "no space left on device" in agent, cli, davsync, gateway, gui,
  library, provider, sessions); it is not a record.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 4594d66d2d gateway: an image description's time limit is the describer's, not its wait in the queue, and the usage log no longer calls it the agent canceling (#2318, davisjiahao)
askVisionWith put a 2-minute context.WithTimeout around the whole
description, which goes through the gateway itself (s.serve): its wait for
a slot (MaxConcurrency, QueueWait), for room in the minute, and the pauses
between tries all spent it. A reasoning seer (gpt-6.1-sol on a Codex
account) queued or retried had little or nothing left to describe in, and
the image's turn failed. The usage log said 499 "the agent canceled the
request" for magpie's own limit.

sideDeadline (side_deadline.go) now bounds a request magpie asks of itself:
the vendor has its limit from when the request last went out to it
(httptrace WroteRequest, each try's own), and the whole of it, waits
included, a larger one. Image descriptions get 3 minutes per try (a dense
screenshot at a high reasoning level can take over two) and 10 in all; a
model's search (modelSearch, the same 2-minute limit, the #1522 message)
keeps 2 minutes per try and 5 in all. The context's cause says which limit
ended it, and the 499 sites in serve record "magpie stopped waiting: its
image description had no answer in 3m0s" instead of the agent canceling.
Still 499, no fault of the vendor's.

Not done: the issue's setting for the limit (none needed once the wait
isn't counted) and sending the raw image to a model that can't see it.
A pause between two tries still runs on the first try's limit.

Tests (vision_wait_test.go): TestVisionWaitIsntTheDescribersTime queues
the description behind a held request for twice the limit;
TestVisionLimitEndsASlowDescriber has a describer slower than the limit
and checks the 502 and the usage row. Broken by hand (WithTimeout back,
the old 499 text) both fail: "no answer in 300ms" and "vision usage: 499
the agent canceled the request". modelSearch has no test of its own; it
uses the same sideDeadline.

Run: go test -tags nogui ./internal/gateway -run
'Vision|Search|Image|Seer|Describ|Concurren|Queue|Cancel|Usage|Lane|RPM'
ok (58s); gofmt clean; go vet -tags nogui ./internal/gateway on darwin,
linux, windows clean. Not tried with a real queued seer.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone dc2f0da820 gateway, gui: Image recognition and Web search pick how hard their model thinks (MOMO on Discord)
MOMO asked on Discord, "外置模型能不能提供思考深度选项": the model that
describes images (Image recognition, analyze_image) and the searcher's
model (e.g. Antigravity's Gemini 3 Flash) had no reasoning level of
their own to pick.

Settings › Models now has a chip beside each of those two pickers. It
opens the app's menu (openProtoMenu, no native select) and offers
Default plus only the levels that model has (Efforts, weakest first;
none shown when the model's levels aren't known, or the row is Off).
The pick is saved as settings.visionEffort / searcherEffort, one of
catalog.EffortRank or empty, and is checked on save. prefsKeep carries
both, so saving another setting keeps them.

Default keeps what magpie did before. Image recognition is still asked
at the least level the model has (classifyEffort), and the searcher
still gets no level. A picked level is fitted to the model's levels at
call time (fitEffort), and only these two calls carry it
(side_effort.go):
- askVisionWith sends reasoning_effort. The image cache key includes
  the level, so changing the level reads the image again.
- searchBody puts thinking (disabled for none, else enabled with
  budgetOf's budget) and output_config.effort (except for pre-adaptive
  Claude) on the searcher's Anthropic body. The gateway's translation
  turns that into each vendor's own form: adaptive or between_tools
  for new Claude, reasoning.effort for Responses, and thinkingLevel
  for Gemini 3 on Code Assist / Antigravity.
- A picked level raises max_tokens by its budget (replyRoom), so the
  thinking doesn't eat the reply.
- ownSearch and Kimi's search service are sent no level. A fallback
  searcher is sent the level fitted to its own model.

docs/subsystems/gateway-routing.md: new "How hard a side model thinks".

Tests:
- TestVisionEffortPicked and TestVisionEffortOnAnthropic check the
  vision body.
- TestSearcherEffortPicked checks the searcher body on new Claude, old
  Claude and Responses.
- TestSearcherEffortOnGemini checks the searcher body through
  buildCodeAssist for antigravity.
- TestSideEffortChecked covers settings validation.
- side-effort.test.cjs covers the chips: levels shown, a pick saved,
  Default clears it, toggle and Escape, no scroll, fit in the row and
  the menu inside the window. It runs in Chromium and WebKit at 1100
  and 420, in en/zh/zh-TW/ja/de.

Run:
- go test -tags nogui ./internal/gateway/ (full, -timeout 30m) on
  origin/main 3a9d73c5c + this change: everything passes except
  TestRateLimitIsWaitedOut "an hour away" (1.9s against its 1s bound,
  load ~190). That test passes on freshly fetched origin/main 41972b25f
  alone (-count=10) and in 8 parallel -cpu 1 copies. Filed as #1971.
- go test -tags nogui ./internal/settings/ ./internal/gui/: ok.
- Broken by hand, each goes red:
  - searchBody dropping the effort fails TestSearcherEffortPicked and
    TestSearcherEffortOnGemini;
  - askVisionWith back to classifyEffort fails TestVisionEffortPicked
    and TestVisionEffortOnAnthropic;
  - the settings check removed fails TestSideEffortChecked;
  - prefsKeep without the two fields fails side-effort.test.cjs.
- GUI:
  - side-effort.test.cjs: 10/10.
  - searcher-pick, images-*, vision-mcp, settings-search/sections/
    general, routing-vision-why and i18n-keys: 123/123.
  - 67 more Settings files: 778 pass. text-size "zh, dark ... 150%"
    failed in WebKit under parallel load; it passes 11/11 alone and is
    #1866.
- gofmt -l is clean. go vet passes for darwin, plus GOOS=linux and
  GOOS=windows with -tags nogui, on gateway, settings and gui. go build
  passes.
- Not tried against a real Antigravity or other real account: the
  request shapes are checked against fakes and the gateway's own
  translators.
2026-10-13 16:40:24 +08:00
yetone b5d7f0574c gateway: image recognition and web search that magpie picks pass over a model out of its allowance, and ask none when every one is out (#1801, hibaliqya-yonma)
What was wrong: AutoVision (the model that describes images for models
that can't see) and autoSearcher (the model that searches for models
that can't) pick a provider and model before routing runs. They never
looked at routing's allowance state. That state covers accounts barred
at a usage cap, rests for quota or credit, and full key or subscription
windows. Routing then had one candidate and tried it all the same. Each
image or search was sent to the account that had run out and got the
same 429 again, while another provider with allowance sat unused.

What changed:
- fallback.go: spentModel(p, model, from, now). A model is spent when
  every candidate routing would try for it (perKeyBarred) is capped,
  resting for quota or credit, or has a full window (candidate.full,
  model-aware for pools). It also says when the first one is back. A
  rate rest doesn't count.
- search.go: smallModel goes through smallReady, which prefers models
  that aren't spent (pickSmall keeps the old choice among them).
  autoSearcher ranks a searcher with allowance before searchRank.
  modelSearch doesn't ask a spent searcher that magpie picked
  (searcherSpent), tries the others with allowance first, and adds why
  it skipped to its error. A searcher named in Settings is asked as
  before.
- vision.go: AutoVision ranks ready first, then tier and cost. When
  every describer is out it still names one, so seer and Described
  (which tell agents every model takes images) don't flip with a
  window. askVisionWith (gateway and MCP) answers an auto describer
  that is spent with the reason and when it is back, and doesn't call
  upstream. A describer named in Settings is asked as before.
- Image and video generation (AutoDrawer, AutoVideomaker) are left
  as they were.
- docs/subsystems/gateway-routing.md: new section, tests added to
  Verification.

What was run:
- New tests in side_spent_test.go: TestAutoVisionPassesOverOneOut,
  TestAutoVisionTierAmongThoseWithAllowance,
  TestSpentModelAcrossAccounts, TestVisionDoesNotAskSpentDescriber and
  TestSearcherPassesOverOneOut.
- Broken by hand three ways:
  - spentModel returning false: all five go red.
  - Only autoSpent's check in askVisionWith removed:
    TestVisionDoesNotAskSpentDescriber goes red (200 from upstream).
  - Only modelSearch's skip removed: TestSearcherPassesOverOneOut goes
    red.
- go test ./internal/gateway -run 'Search|WorkBuddy|Kimi|Vision|Spent|PassesOver'
- gofmt -l, go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  and GOOS=windows go vet ./... are all clean.
- Full go test -timeout 40m ./... in a sandbox HOME at load 66-100:
  47 packages ok. internal/gateway and internal/agent hit the 40m
  package timeout. Gateway also had failures, each filed:
  - TestOTelWaterfall* (#1794, fixed on main since).
  - TestCodexHeardWithinItsIdleTimeout (#1800).
  - TestIntentClassifierGroup (3.17s against a 3s bound, filed as
    #1813).
  All of them pass alone, and go test ./internal/gateway on its own is
  ok (982s).

Not verified: not tried with a real account that has run out. Windows
was only vetted.
2026-10-12 23:04:29 +08:00
yetone 6c1c0a7472 gateway, gui: magpie's image recognition is an MCP server of its own, /mcp/magpie/vision, with one analyze_image tool (JonahFu on X)
What: beside /mcp/magpie/web-search, the gateway serves the model that
describes images (Settings › Models › Image recognition, else magpie's
automatic pick) as a Streamable HTTP MCP server. analyze_image takes an
image (absolute file path, http(s) URL or data:image URL) and an optional
prompt: without one it is described as a model's image is (same cache and
system text), with one the prompt is asked beside it. The JSON-RPC serving,
guard and Origin check are shared with the web search server (serveMCP).
A file path is read only for a local, unproxied caller, up to 20 MB, and
only when its bytes are an image; another computer sends a URL or data
URL with a gateway key. Each call holds the key's limit (budget.Reserve)
and reads in Routing as the agent's analyze_image call. Settings › Models
shows the address under Image generation (#visionMcpRow), in every
language.

Run:
- go test -tags nogui ./... (no failures); gofmt -l clean; GOOS=linux and
  GOOS=windows go vet ./internal/gateway.
- New TestVisionMCPAnalyzesImage / WithNoSeer / Guarded / HeldToKeyLimit.
  Broke the local() guard by hand: TestVisionMCPGuarded went red on the
  other computer's file path being read.
- GUI (chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 520px):
  vision-mcp, search-mcp, public-url-default, images-missing,
  settings-sections, i18n-keys, routing-vision-why: 95 pass. The row was
  first put between the two pickers and images-missing went red (it finds
  them by position), so it sits last.
- Real use: this build under a sandbox HOME holding only the owner's
  OpenRouter provider, Image recognition set to openai/gpt-6-luna.
  initialize, then tools/call with docs/screenshots/font-settings.png as a
  file path and a prompt: the model listed every settings row and its
  value correctly.
Not tried: a real agent (Claude Code, Cursor) mounting it; its MCP
exchange is the same as the web search server's.
2026-10-12 08:03:24 +08:00
yetone d5cae267a7 gateway: image recognition and web search pick only models the user enabled (JonahFu on X)
On a provider with a long list, AutoVision and the searcher picked their
small model from everything the vendor lists (Available), not from what
the user enabled. A Trae CN user's text-only model had its image sent to
OpenRouter's anthropic/claude-haiku-5.5, which they never enabled and
which OpenRouter refused for their region (403).

smallModel, and so AutoVision, searcherModel and the searcher's
first-model fallback, now chooses from Exposed: the user's picks, else
what agents are offered. With no enabled model that sees, a request
turned away says so ("none of the models enabled in magpie can see
images ... enable one that can, or pick one in Settings → Models → Image
recognition"); Vision off says it is off; a describer magpie picked
itself that fails is named as magpie's pick.

Not done: no fallback to another describer on a refusal. With the pick
limited to enabled models, a refusal is of a model the user chose, and
the error now names it and where to change it. Image generation's
AutoDrawer still picks from image models a provider lists: image models
aren't in the chat pickers, so limiting it to picks would turn drawing
off for nearly everyone.

Run: the two new tests fail on the old code (AutoVision =
router/google/gemini-3-flash, searcherModel = google/gemini-3-flash) and
pass now; go test ./... green except internal/gui's
TestDockJoinLeadsCommandTab, which reads the live desktop's Command-Tab
order and passes run alone; gofmt; GOOS=linux and windows go vet
./internal/gateway.
2026-10-12 00:01:28 +08:00
yetone d5f434f308 gateway, gui: an Image recognition or Image generation model picked in Settings that magpie can't find any more is no longer replaced in silence: Settings › Models marks it missing and says what describes or draws in its place, and the description's row in Routing names it beside the automatic model that described instead (found on #1287)
Before, if the picked model didn't resolve (its provider removed or turned off, or the model gone), seer() and drawer() quietly fell back to AutoVision/AutoDrawer. Settings still showed the gone id as the pick, and Routing showed only the automatic model. The turn still goes ahead with the automatic model, so nothing the user sends breaks. What changed is that magpie now says so:

- VisionMissing and DrawerMissing (pickedMissing) name the pick that doesn't resolve. /api/settings carries them as visionMissing and imageGenMissing.
- CallFor.Missing is set on every description (withDescribeFor). This covers the single-model and group paths and every protocol. routing.js tells that story first.
- With no automatic describer either, the 400 and 502 a turn is refused with name the missing pick and where to change it. So does a draw request that names no model.
- renderImages and renderImageGen show "<id> · missing" in the picker and a red line under the row. The line names what stands in, or says nothing does, and asks the user to pick another model.
- zh, zh-TW, ja and de are translated.

Verified:
- New internal/gateway/vision_missing_test.go. I took out the behaviour (Missing on the row, the notes, the draw message) but kept the helpers so it compiles. Both tests then FAIL:
  vision_missing_test.go:80: probe/text anthropic: the description's row is for {Agent:other Model:probe/text Unknown:false Missing:}, want it to name the missing gone/bigeye
  (the same on responses, codex and chat, and for group/mixed)
  vision_missing_test.go:116: probe/text with no describer: 400 ... "model \"probe/text\" does not support image input"
  vision_missing_test.go:135: no drawer: 400 ... "no model to draw with: pick one in magpie's Settings → Images → Image generation, or name one"
- New internal/gui/tests/images-missing.test.cjs checks Settings › Models in en and zh at 1000px and 360px: the picker text, the line inside its row, and no page overflow. A pick that is found shows as before. routing-vision-why.test.cjs gains the missing row. With app.js and routing.js from before this change (Chromium): pass 2, fail 7.
- node --test images-missing, routing-vision-why, routing-side-calls, settings-sections, gui-ja, gui-de, gui-zh-tw and i18n-keys in Chromium and WebKit: 42 pass, 0 fail.
- go vet -tags nogui ./internal/gateway ./internal/gui passes on darwin, GOOS=linux and GOOS=windows. go build -tags nogui ./... passes.
- HOME=<tmp> go test -tags nogui ./internal/gateway ./internal/gui: ok (208.5s, 36.9s).

Not verified: no real magpie instance with a provider actually removed. The gateway was exercised through Handler with fake upstreams, and the GUI with a faked /api/settings. Drawing's own Routing row still doesn't say its model fell back: drawing calls have no story in kindWhy. Only the Settings row and the refusal say it.
2026-10-08 19:08:09 +08:00
yetone e7de897f93 gateway, gui: Routing now says why an image was described for a model. Either nothing magpie knows says the model sees images, so it is counted as text only, or its provider's list or the user's own setting says text only. It names the fix for each: tick "Accepts images" in the provider's models, or pick the describing model in Settings › Models › Image recognition (#1287, Admin123456-check)
The reporter set Codex to deepseek-v4.1-flash and saw a row "codex/gpt-6.1-sol · 图片描述" in Routing. The model was counted as unable to see images. With no Image recognition model set, magpie had a Codex account's model describe the image (AutoVision). The row said only "which can't see images", so it gave no reason and no way to change it.

CallFor gains Unknown. It is set when blindTo counted the model as text-only only because nothing says it sees (the request has no imageInput of its own). This holds on both the single-model path and the group candidate path. routing.js's kindWhy gives each case its own story. zh, zh-TW, ja and de are translated.

Verified:
- New TestDescriptionSaysWhyTheModelCantSee sends an image on the responses, codex, chat and anthropic routes. It covers an unknown model, a model whose list says text only, and a group of each. Without the gateway change it FAILs, e.g.
  vision_unknown_test.go:182: probe/text responses: the description's row is for {Agent:other Model:probe/text Unknown:false}, want unknown true
  with the same failure on codex, chat, anthropic and group/unknown.
- internal/gui/tests/routing-vision-why.test.cjs checks the vision row's tag and story in en and zh, in Chromium and WebKit. With routing.js from before this change it gives pass 0, fail 2.
- node --test routing-vision-why, routing-side-calls, gui-ja, gui-de, gui-zh-tw and i18n-keys: 18 pass, 0 fail.
- go vet -tags nogui ./internal/gateway ./internal/gui passes on darwin, GOOS=linux and GOOS=windows.
- HOME=<tmp> go test -tags nogui ./...: all ok except the root package and internal/plugin (TestHostRunsAsMagpieBun context deadline). Those fail only in the full run under load. Run alone, both pass (34.9s, 122.7s).

Not verified: the reporter's real provider. A throwaway test against the real models.dev data found no preset where deepseek-v4.1-flash counts as unable to see. So their case is one of: their provider's list says text only, a model setting, a stale models.dev cache, or a plugin. That is asked on the issue.
2026-10-08 18:44:49 +08:00
yetone 46f03154ff gateway: a gateway key can be held to some models (#882, LCorleone) — a key could reach every model magpie serves. A key now keeps an optional list of models (caller-keys.json "models", none = every model, so older files read as before): <provider>/<model> or <provider>/*, matched against the provider that serves the call, so a bare model name is resolved first and OpenRouter's "anthropic/x" is not Anthropic's. Such a key sees only its models in /v1/models, /v1/models/{id} and the Anthropic (Claude Desktop) and Gemini lists, a routing group only when every member is its; asking for another, by id, bare name or through a group with a member it may not use, is refused before any provider is asked with a 403 in the API's own error shape (permission_error) that names the key and its models, logged as a rejected call like an over-limit key's 429; a fallback it may not use is skipped; embeddings, images and videos it names are held too. magpie's own calls for it (a web search, a picture described, Codex titles with the model Settings name) are marked in their context, not by a User-Agent a client could send, and go on. Set it with the new badge on the key's row in the Gateway page (the app's menu: All models, every model of a provider, each model; sent when the menu closes) or magpie gateway-key models <id> openai/gpt-5 anthropic/* (all takes it off); gateway-key list has a MODELS column. The app's menu, fitting neither below nor above its button, now goes on the roomier side and scrolls instead of running off the window. en/zh/ja/de. TestGatewayKeyModelsHoldAKey (lists, 403s by id, bare name and group, Anthropic shape, fallback skipped, magpie's own call, a free key) fails without the change; TestModelPatterns, TestKeyModelsKept, TestGatewayKeyModelsCLI, TestCallerKeyModelsRoutes pass; gateway-key-models.test.cjs (Chromium and WebKit, en and zh: no native select, menu inside a 420px window, picks sent on close, All models, no scroll, no left border, 560px fits) passes with gateway-connect-keys, gateway-key-limit, gateway-caller-keys and click-scroll. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. 2026-10-05 16:52:23 +08:00
yetone 2a4042a94d perf: magpie opens and shows the Agents page in a fraction of the time it took (Junjie Zhou on Discord: 8 个 agent 30 个 provider … 每次我打开的时候都会很慢,要好几秒。setting 页面秒进后 我切换到 agent 就有问题) — at start, writing the agents' model lists (agent.SyncCatalog) built every provider's catalog thousands of times with nothing held, each build reading migrations.json, settings and groups again: 6000+ file reads and ~8.5s of CPU in the first 8s with the owner's 30-odd providers, all competing with the first /api/state and the Agents page. Now SyncCatalog, magpieModels and main's start-up moves run under provider.Hold, migrations, groups, settings and a provider's fetched models are held for a second like the rest, and filememo.Hold lets a GET /api/* not stat a file it confirmed unchanged within the last second (any magpie write, Changed() or a recent mtime still reads it again). A big ~/.codex/config.toml parsed in quadratic time (the TOML parser's Shape counts newlines from the start for every key): a 3 MB one took 5.4s, now 0.04s (tomlShaper). theInstalled reads through edit.Read's memo. Measured with a copy of the owner's magpie config and agent configs under a sandbox HOME, the real server in WebKit: CPU in the first 8s 8.59s → 0.39s, page up 475 → 75ms, Agents rows drawn 775 → 325ms after start; the agents' written model files are unchanged (pi byte for byte, opencode the same models). TestTOMLShaperMatchesParser, TestTOMLBigFileParsesInLinearTime (fails on the old code), TestHold (filememo), TestHoldReadsMigrationsOnce. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. 2026-10-05 03:02:40 +08:00
yetone 6cab11673e vision: a model whose list says nothing of images is given the image described, and the description is in Routing as its own call (Discord, Fate: since v0.1.725 images reach a text-only model in Codex, but it reads them badly and Routing shows no call to the Vision model) — 19e239c7 tells agents every model takes images while a describer is set, but the gateway described an image only for a model whose list says explicitly it takes none (ImageInput false); a model the vendor's /models says nothing of (ImageInput nil — most API keys' models, which magpie counts text-only and agents were told so before) had the image sent on as it came, so the text-only upstream got the raw image (dropped, or read by whatever it does with it) and the Vision model was never asked. Now, while a describer is set, a model that isn't known to see (its catalog entry's Images: the list's answer, the user's override, else models.dev) is given the description, on every API (Responses and Codex's /backend-api/codex, Chat, Anthropic, Gemini), for its current turn, older turns and tool results (function_call_output's input_image), and as a routing group's member (blindTo). Without a describer an unknown model is passed images as before. The description was already a call through the gateway (agent magpie-vision) but untied to anything; it now has kind "vision" ("Image description" in Routing, zh 图片描述), For naming the agent and model it described for, and the request's session, so it shows in that conversation's Routing beside the turn. The describer's prompt (every text transcribed, layout, values) and the image (sent whole, never downscaled) were already right. TestModelNotKnownToSeeIsGivenTheDescription (data: and https input_image on /v1/responses and the Codex backend path, Chat), TestModelNotKnownToSeeToolAndGroupImages and TestDescriptionIsInRouting fail on the old code and pass. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but TestUserPath, TestCodexVersion, TestClaudeRunEndsWhenTheClientLeaves and davsync, timing tests under load that pass alone and in their packages rerun. Not tried in the Codex App with a real account. 2026-10-03 16:05:17 +08:00
yetone 19e239c7bf vision: while a model that sees describes images, agents are told every model takes them (Discord, Fate: with Settings › Vision set, a text-only model in Codex still said it "does not support image input") — the gateway already described an image for a text-only model on every wire format, but the agents were told the model was text-only (Codex input_modalities ["text"], opencode modalities, dsh/omp input, droid NoImageSupport, cline/zed/qoder/workbuddy flags…), so they turned the image away before magpie was asked. provider.Described, set by the gateway to whether seer() finds a describer (Vision names one, or Automatic finds a model that sees; not with Vision off), makes magpieModels (every agent's model file) and codexListed (the ChatGPT backend's /models list and its ETag) say images for every model; Vision changed in Settings rewrites the agents' lists (catalog.Touched). TestDescribedModelsTakeImagesInAgentsLists (Codex list, input_modalities, tag) and TestDescribedModelTakesImages (agent files) fail on the old code and pass; TestDshModelLimits and TestMiniMaxCode turn Vision off to keep testing a text-only model as such. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried in the Codex App with a real account. 2026-10-03 15:25:43 +08:00
XYenonandAmp 564f8782c7 provider: keep conversation models on mixed decision providers (#609)
Distinguish decision-only providers from gateways that also serve conversations. Only Jev models use the decision API; ordinary models remain in the catalog, automatic groups and conversation routes. Keep the full model cache when probing a mixed provider’s decision endpoint, and allow conversation model tests in its editor.

Verified with go vet -tags gtk3 ./..., go test -tags gtk3 ./..., node --check internal/gui/assets/app.js, and an isolated browser fixture.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0fe05-afd7-70df-97cf-fdb69c4f4680

Co-authored-by: Amp <amp@ampcode.com>
2026-10-03 04:06:02 +08:00
yetone efed707066 providers: a provider can be switched off, kept with its keys but out of every agent's list (希望服务商可以有一个开关按钮,关闭后不再写入模型) — a provider whose quota ran out could only be removed, losing its key and settings, or left in, its models still written into the agents and requests still sent to it. Now each provider (a signed-in account too) has a switch on its row in Providers and in its editor's header; off, the row is dimmed and says Switched off (已关闭), its models leave the catalog, so the model lists magpie writes into agents' files are rewritten without them as after any provider edit, and it is left out of routing groups, fallbacks, the Automatic image, vision and search picks, the routing pools and balance and usage polling. A request naming one of its models is answered 404 saying the provider is switched off in Magpie, not that the model is unknown. Switched on, all of it comes back. Saving the provider from its editor keeps it off; magpie provider off|on <id> and the TUI's o do the same. Tested: an off provider's models are not in the catalog or served, a group with it routes to the member left, a fallback to it is not tried, a request for it is refused as switched off, and turned on it is listed and answers again; an account's off is kept. Checked the Providers page in a sandbox HOME in light and dark: switching a row off and on, the editor's switch and its note 2026-09-29 02:49:36 +08:00
yetone d00d9ffe6f gateway: a model that can't see images is given what a model that can says of them (让Magpie支持配置图像识别模型) — until now an image sent to a model the catalog knows takes text only was turned away in the latest turn and left out of older turns and tool results, so an agent on DeepSeek, GLM or any text-only model couldn't be shown a screenshot at all. Now each image in such a request is described once by the vision model and the description goes in its place, in every protocol (Chat, Responses, Anthropic, Gemini), current turn, older turns and tool results alike: "[Image, as <model> describes it for this model, which can't see images:] … [End of the image's description]". The describer is asked through the gateway itself (User-Agent magpie-vision/1, recorded as agent magpie), with a system prompt to transcribe text, code, errors and UI state exactly and not to answer or guess; images are described four at a time, and a description is kept (256, by model+image) since an agent sends a conversation's images again every turn, a failure not kept. An image of the latest turn that can't be described is a 502 saying why; one in an older turn is left out as before. Settings → Images → Image recognition picks the model: Automatic (a small model that sees — a Claude account's, a Codex account's, the cheapest of an API key's, another account's), Off (images turned away as before), or any model or group that sees; an id that doesn't resolve is refused. In a routing group the description is made only when a text-only member is actually tried, so a rule that routes images to a member that sees costs nothing; a member whose image can't be described is skipped for the next, the last one answers 502. The describer's own request is never described again, so a Vision set to a text-only model is turned away, not looped. Checked in a sandbox HOME against a local vendor: an image sent over Chat and over Anthropic to a text-only model reached it as the description, the describer was asked once per image, and the Settings row and its picker in light and dark. 2026-09-29 01:20:31 +08:00