ac4af582301a4e8a29245dbba767eba31334ddf9
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
70a0c387cb |
agent: a provider named magpie written by hand is the user's, not connected (JFunfunfun on X)
Pi set up by hand on a provider of its own named magpie (magpie/<model> at the gateway) read as connected in magpie: every catalog change wrote magpie's list over that provider, RenameProvider rewrote its refs, Drift offered Reconnect, and Disconnect took the provider out. |
||
|
|
0911a65e7d |
agent: a catalog sync leaves a magpie provider the user wrote alone while the agent isn't connected
yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
at magpie and picked a few models by hand. MiMo's switch on the Agents
page was off, yet after an update the provider held every one of
magpie's models. SyncCatalog runs at each start and update and on every
catalog change, and MiMo Code's Sync (openCodeLike) brought any
provider.magpie block up to the catalog whether magpie wrote it or not.
magpie's default went over a list the user set.
An Agent whose Sync does nothing but keep a block of magpie's name up
to the catalog is now ListOnly, and SyncCatalog runs it only while the
agent is Wired, which is what the Agents page's switch shows. The same
sync was in every sibling, so ListOnly is on all of them: openCodeLike
(OpenCode, MiMo Code and their WSL forms), piLikeKeyed (Pi and forks),
Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi,
MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen
Code and T3 Code. Left out on purpose: Codex, Claude, Grok and Hermes,
whose Syncs also repair while not connected (Hermes keeps its bots'
magpie provider current) and have their own gates.
Trade-off: a list magpie wrote while connected doesn't follow the
catalog while the agent runs a model of its own (switch off); it does
again once a model of magpie's is picked. Users whose list was already
written over: magpie keeps no copy of the old list, so it stays full;
from this release on it is left alone, and they trim it once by hand
(or connect the agent in magpie and use its model list's Pick).
Tests: TestCatalogSyncLeavesAHandWrittenMagpieBlock (MiMo, Pi and Crush
with a hand-written magpie block stay byte for byte; connected, MiMo's
list follows the catalog; disconnected and written by hand again, left
alone; a magpie model picked in MiMo, followed again).
TestListOnlyAgentsReadConnected: every ListOnly agent magpie connects
reads as Wired (n >= 15), so none of them loses catalog updates.
Fixtures of TestSyncCatalogRewritesAgentLists,
TestModelNameAndLevelsReachAgentFiles, TestSuffixModesReachAgentFiles
and TestPiKeepsTheirKeysInMagpiesProvider, and internal/cli's
TestSaveAnswersBeforeTheAgentsSync (its Pi settings were {}), now have
Pi connected (settings.json defaultProvider magpie), as a block magpie
wrote implies.
docs/subsystems/agent-wiring.md says the rule.
Run (mote, sandbox HOME via the tests' syncHome/codexHome):
- old code + the new test: red (MiMo, Pi, Crush written over; after
Disconnect written over).
- broken by hand: ListOnly dropped from openCodeLike: red on MiMo
(lines 52, 82); the Wired gate in SyncCatalog replaced with true: red
on all three.
- go test -tags nogui -count=1 ./internal/agent: ok.
- gofmt -l clean; go vet ./... for darwin, GOOS=linux and GOOS=windows:
ok.
- full suite, go test -tags nogui -count=1 -timeout 45m ./... at base
|
||
|
|
5160809d2e |
agent: a catalog sync's round looks at each file once; a write reads the disk (#1665)
A catalog sync asked about each agent's files many times a round (GetJSON, GetTOMLTop, settings.load from each agent's Sync): on Windows an empty sandbox's start stat'ed settings.json 1065 times and config.toml 569 in 25s, almost all from SyncCatalog. Each round now holds what was read (filememo.Hold), as the GUI's read-only requests and the gateway already do. What a hold serves may be up to a second old, so nothing is written from it any more: - edit.Read, which every Set*/Del* helper and the agents' own read-modify-write code start from, looks at the disk even under a hold (filememo.ReadNow). The getters (GetJSON, GetJSONRaw, GetJSONItem, GetEnvFile, GetYAMLTop, the YAML getters, GetTOMLTop's line reader) read through the hold. - settings: a write's load under fileMu (lockFile) reads the disk too. Before this, a GUI request's hold could already hand a Set* stale bytes; that is closed as well. WriteAtomic forgot every held file even when it left the file as it was, and a sync writes each agent's files each round, almost always unchanged: it now forgets only after a real write. Measured on xiaomi-gpu (Windows 11), as in the steady commit before this one (second start, 27s, stats counted by an uncommitted build): before 2307 stats, sync 1318 of them, round 1308ms this alone 1787 stats, sync 864, round 1273ms with steady's 988 stats, sync 96, round 96ms First start of an empty sandbox: 2448 stats before, 1041 after. Run: - TestHeldReadIsNotWhatAWriteIsMadeFrom (json, toml, yaml), TestUnchangedWriteKeepsWhatIsHeld, TestHeldSettingsAreNotWhatAWriteIsMadeFrom: with edit.Read and the settings write load put back on the held read and WriteAtomic's Forget removed by hand, json and yaml lost the other app's key, the settings case wrote "light" over "dark", and the forget case went red; green with the change, on mote. - mote, at the pushed head: gofmt -l internal clean; GOOS=linux/windows/ darwin go vet of steady, edit, filememo, settings and agent clean; go test -count=1 of steady, edit, filememo, settings, agent, provider, catalog and library ok; internal/gui red only on TestMainWindowCorners (#3949, macOS 27, red on main before this). - xiaomi-gpu: go test of edit, filememo and settings ok. |
||
|
|
71fd92ddf7 |
saves: a routing group or provider saved answers before the agents' files are synced
CyberCaius on Discord (native Windows): "路由组和供应商编辑保存有时候保存会卡 很久才保存成功", at least 3s, while an agent's request runs. Cause: every write of providers.json ends in catalog.Touched -> Changed, which was agent.SyncCatalog, run inside the HTTP request. It rewrites every agent's model list that differs. On Windows, a file another program holds open refuses the rename over it, and steady.Rename retries for 0.5s before giving up. So each such file costs a group save half a second, and a provider save, which stores several times, costs more. In WSL the same sync goes through wsl.exe and \\wsl.localhost. Fix: catalog.Changed is agent.SyncCatalogSoon, which runs SyncCatalog in the background (it already folds overlapping runs into one more round). A CLI command waits for those rounds at the end of run() (SyncCatalogSettled), so `magpie group add` still ends with the files written, and run() puts catalog.Changed back for tests. The GUI's direct SyncCatalog calls in providers.go (arrange, keeplogin, switchonly, login actions, sign-in import) use SyncCatalogSoon too. Run at the pushed head (parent |
||
|
|
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
|
||
|
|
d9b943555d |
agent: a key of the gateway's own in place of magpie's still reaches magpie (#2510, PaulT on Discord)
PaulT made a key under Gateway keys and put it in Hermes's config.yaml
(providers.magpie.api_key) in place of `magpie`. Requests went through
magpie, but the picker said Hermes's api_key was changed and that
magpie's gateway won't take its requests.
The class: wiringOff, and the key checks of Codex
([model_providers.magpie] experimental_bearer_token), Qwen Code
(env.MAGPIE_API_KEY) and Reasonix (its env file), accepted only the exact
key magpie wrote. A sync also wrote `magpie` back over the user's key,
in mergeKept (every yamlKept/jsonKept agent) and in Reasonix's install.
keyHolds(v, want) is the one check now. Where want is a key magpie gives
for its gateway (gateway.Token, the LAN key, or a TokenFor), it takes any
v that access.Authenticate takes, the same test dsh has used since #1332.
It never stands in for a URL or another value. A key the gateway doesn't
take, or one turned off, is still drift and is still written over.
Run, at
|
||
|
|
2eee900dc9 |
agent: eight more syncs keep what the user set on magpie's block (#2030's siblings)
|
||
|
|
78b3f1f21a |
agent: an agent pointed at magpie on another machine keeps that address and key through a start's sync (coeo91 on Discord)
coeo91: after an update or a restart, the base URL in an agent's config sometimes went from the LAN address back to 127.0.0.1. Every start of magpie (and a provider added, a catalog fetched) runs SyncCatalog, which runs each agent's Sync to bring magpie's models in its files up to date. Each Sync writes magpie's whole provider block, base URL and key included, from gateway.URL(), so a block the user had pointed at a magpie on another machine (a NAS's, or this machine's LAN address) went back to 127.0.0.1 with magpie's own key. Only ZCode (zcodeAddress), WorkBuddy (buddyWriteAt) and Codex (#816) kept such an address; in a sandbox HOME, 27 files of the other agents went back (Qoder, OpenCode, Pi, Crush, Cline, Qwen Code, Kimi, Grok, Hermes, omp, MiniMax, Snow, Hanako, VS Code, Copilot JetBrains, Goose, dsh, ...). The fix is one place for all of them: SyncCatalog runs each Sync through synced, which passes every file written through keptAway (edit.Filtered, a filter on edit.WriteAtomic while it runs). In a file without the gateway's own address, with an address on another machine and none a WSL distro was seen at, a write that brings gateway.URL() in place of that address keeps the address, and one that brings magpie's own key (gateway.Token, TokenFor, the LAN key, "Bearer " too) in place of another key keeps that key. An address on this machine's loopback (another port, localhost) still follows the gateway, a WSL distro's way to Windows is still magpie's to move, magpie's own files are never filtered, and with two addresses or keys gone the write is left as it is. A pick made in magpie still points the agent at this magpie. Tests: - TestSyncKeepsAnAddressOnAnotherMachine wires every agent in a sandbox HOME, points each file at 192.168.50.10 with a key of its own, adds a provider and runs SyncCatalog: no file is back on 127.0.0.1, the address and key are kept, and the new model is written. With SyncCatalog calling a.Sync() directly it fails on 27 files. - TestKeptAwayOnlyWhatIsSure: old port, localhost, WSL and two-gone cases follow the gateway; a NAS beside a local Ollama is kept; Qwen Code's key written on its own is kept. - TestKeyValuesFormats, TestFilteredWrites. Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent ./internal/edit; go test -tags nogui ./... in a temp HOME. |
||
|
|
a8290d2772 |
agent: a catalog sync or a model pick keeps the keys a user or another tool added to magpie's provider block (Pi's providers.magpie.compat.sendSessionAffinityHeaders from pi-cache-optimizer) instead of writing the block whole (#1103)
syncJSON and Pi's writeMagpie set providers.magpie to a freshly built
object, so a key magpie doesn't write there was dropped on every sync.
theirsKept now merges magpie's block into what the file holds: keys magpie
writes are its own, objects in both are merged key by key, and anything
else (compat, an options key, Crush's extra_headers) stays. The model list
is still magpie's whole, so a model gone from the catalog leaves it, and a
sync with nothing new writes nothing.
The same goes for every agent that writes the block whole: Pi and OmO,
Aside, Pencil, OpenCode (and the agents built on it), OpenChamber, Crush
and Command Code.
Verified: TestPiKeepsTheirKeysInMagpiesProvider (the reporter's
compat.sendSessionAffinityHeaders: true in Pi's models.json, through
SyncCatalog and a pick) and TestOpenCodeAndCrushKeepTheirKeysInMagpiesProvider
fail without the change ("compat.sendSessionAffinityHeaders dropped by the
sync", "opencode sync") and pass with it. go test -race ./internal/agent
and go vet ./... pass in a sandbox HOME.
|
||
|
|
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. | ||
|
|
8323b0ae87 |
agent: OpenCode and OpenChamber list a magpie model's reasoning levels weakest first, not alphabetically (#713, Hu9956 on v0.1.780: 思考 offered 默认, High, Low, Max, Medium, Ultra, Xhigh, where other providers in the same OpenCode go by strength and MiniMax Code had magpie's in order) — openCodeVariants returned a map[string]any, which encoding/json writes with its keys sorted, so each model's variants object in opencode.json came out high, low, max, medium, ultra, xhigh, and OpenCode builds its variant list from the object in key order (checked with OpenCode 1.18.34: opencode models --verbose under a sandbox HOME/XDG dirs keeps a config's variants in the file's order, alphabetical or by strength; it doesn't sort them itself). openCodeVariants now returns an orderedJSON (a key/value list whose MarshalJSON writes keys as given) of the model's efforts put weakest first by gateway.ByStrength, the gateway's effortRank order (none, minimal, low, medium, high, xhigh, max, ultra; a level it doesn't know after them, stably), so a level appended after max (ultra) lands last too; edit.SetJSON keeps the custom marshaller's order when it indents the block. An opencode.json an older magpie wrote would have stayed alphabetical, as Sync's sameJSON compares decoded values and took it for the same block: OpenCode's (and its WSL and mimocode forms', through openCodeLike) and OpenChamber's Sync now use syncJSONInOrder, which also rewrites the block when its tokens, keys included, don't read in the same order as magpie's (sameOrder), and leaves one in order alone; the other agents' syncs are as before. TestOpenCodeVariants now checks the marshalled bytes (weakest first, an out-of-order list sorted, none as {}), and TestOpenCodeVariantsInOrder writes opencode.json under a temp HOME and checks the raw file lists low, medium, high, xhigh, max, ultra, that a block in the old alphabetical order is put in order by Sync and that a second Sync leaves the file byte for byte; both fail on the old code, and the Sync half fails with plain syncJSON. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried in OpenCode's or OpenChamber's own picker with the reporter's setup; OpenCode reads its config at start, so one already open shows the new order after it is reopened.
|
||
|
|
09c635cf03 | agents: a model through magpie tells Pi, Crush, omp and Codex how much it holds, and a provider added, edited or removed reaches the model lists agents keep in files of their own — the catalog carried no context window, so Pi took every model through magpie for a 128K one (a CLIProxyAPI's gpt-5.5 holds 922K) and Crush for a 200K one; each model now carries models.dev's input limit, else its context, looked up by bare id as most of the providers serving it give it (a proxy's "openai/gpt-5.4", "gpt-5.4(high)", "glm-4.6:free" find it too; a group holds the least of its members'). And those lists were written only when a model was picked: Codex's magpie-models.json, Pi's models.json, OpenCode's, Crush's, Command Code's, omp's and Hermes' provider blocks and dsh's llm-deepseek entry kept the catalog as it was then, so a provider added later never showed. Saving a provider, a vendor's list fetched anew or models.dev synced now rewrites each one magpie wrote, where it differs, and the app does once at start-up; a Codex signed in to ChatGPT, which asks the gateway, kept its cached list under the backend's ETag, which a change of magpie's never changed — the ETag (and a reply's X-Models-Etag) now carries a tag of magpie's models, and a cache from before a change is aged so the next Codex asks again |