8a4e32febef69bb797cdf3003ec1395e725d5d63
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cdfdb62c69 |
agent: a model field's list is joined with the catalog once while neither changed
Each agent's model field returned append(its own models,
viaMagpieShared(...)...), a copy of the whole catalog's options for
each field of each agent on every poll: Picks was 94.7 MB of 496 MB
over forty polls of the Agents page with real accounts. withVia keeps
the joined list per agent and prefix while the own models read the same
(sameOption, field by field) and the catalog's list is the very one
kept (same array), and joins it again when either changed. The list is
read only and clipped, as viaMagpieShared's is; every caller of a
field's Options reads it, Picks clones it before it drops anything.
The 52 `return append(own, viaMagpieShared(...)...)` sites call it.
omp's and Reasonix's planner edit the joined list after the append, and
Grok's writes Same into its copy, so they keep their own copies.
TestWithViaKeepsTheJoinedList: the same own models give the same array,
own models changed in a value or only an icon are joined anew, a
provider saved since is listed, and nothing joined is the catalog's own
list. TestSameOptionReadsEveryField sets each field of Option alone and
fails when sameOption doesn't see it. Broken by hand: never answering
from the kept list ("the same own models joined the catalog again"),
and FastFor left out of sameOption ("sameOption doesn't read
Option.FastFor").
Run on mote: both tests alone 3 of 3; internal/agent, internal/tui and
internal/cli ok; internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners (#3949); gofmt, vet and GOOS=windows
and linux vet clean. Real accounts in a sandbox HOME, forty polls:
Picks 94.7 MB -> 51.2 MB, state 190.8 MB -> 154.0 MB, state and drift
replies byte for byte the same as before. Footprint peak 136 MB.
|
||
|
|
bb478f0e50 |
agent: a look that only ranges over magpie's models reads the list kept
magpieModels gives each caller its own copy of the list it keeps per
agent. Most callers only range over it, or count it, and a range copies
each model anyway, so the copy guarded nothing for them (the models'
own lists were shared before too: the copy was shallow). sharedModels
is the list kept, read only; every `range magpieModels(` and
`len(magpieModels(` in internal/agent (39 files) takes it. Callers that
keep the list, append to it or hand it on still get their copy.
Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls of /api/state, /api/providers and drift, pprof alloc_space
between two heap snapshots,
|
||
|
|
6712e367e8 |
agent: a look at the stash shares one read of it
Each /api/state and /api/drift poll asked the stash (stash.json) for one value hundreds of times, through Detected, Drift and the agents' wiring checks, and each ask read the file and parsed it again. In a real-account heap profile (20 rounds of drift, state and providers) stashLoad was 24-34 MB of what was allocated. stashShared reads it through filememo.Read, so every look shares one parse until the file changes, by magpie or by another process. Every read-only caller uses it now, the 24 files here and QwenPaw's unstashPeek. stashLoad, which callers change and write back, still gives each its own map, cloned from the same parse. Real use: the owner's real-account sandbox, offline (proxy to :9), 20 warm rounds of /api/drift, /api/state and /api/providers: - allocated 477 MB ( |
||
|
|
dd7442f283 |
agent: a look at the via-magpie options shares the kept list
viaMagpie handed every caller its own copy of the options list it keeps per stamp, and a window poll asks for it from most agents' fields and pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus ~8 MB more on the way, of the 713 MB the polls allocated. viaMagpieShared returns the kept list itself, clipped, so an append makes the caller's own array. The 58 callers that only read it, or append onto it, now take it; viaMagpie (a copy) stays for the ones that change it. TestKeptListSharedWithoutACopy checks that 20 shared looks return the kept array, and that an append onto a shared look and a write into get's copy leave the kept list as it was. Run on mote at this tree: - gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway), go build ./...: ok. - Broken by hand (shared returns slices.Clone): the test is red, "a shared look copies the kept list". - go test -count=1 ./internal/agent: ok (480s). Not run: internal/gateway and internal/gui packages on this tree. |
||
|
|
73a12e8bf6 |
wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file when that file already exists` (linusxiong). In the distro ~/.codex is a link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't follow a link the distro has: a mkdir of it says it exists, and nothing below it can be made, written, read or listed. ggbdpq found and explained the link (thanks); their patch, which takes that EEXIST as "there", wasn't used: the writes below the link fail next (its test passed because a symlink here is followed). The fix, for every agent folder and every writer through \\wsl.localhost: - The WSL probe asks `readlink -f` in the distro where each agent folder, its skills folder and the folders beside them lead (wslLinkPaths -> distro.Links; a $HOME that is itself through a link is left alone), and which drive each Windows mount is (win:/mnt/c C: -> distro.Drives). - distro.open opens a path at or below a link where it leads: on a Windows drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the distro, through \\wsl.localhost again. native spells it back through the link, so the agent is told its own path. - A link readlink couldn't resolve is never guessed at: distro.open errors, and the agent is unreached (Agent.Unreached: its notice says why; every field Set and Sync returns it). - Writers: the agents' own files (place.join/place.open, every filepath.Join(at.home, ...) in internal/agent), the library's WSL targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir), the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs). - Not changed: magpie's image MCP server opens arbitrary paths an agent in WSL gives it the same way; filed as #4578. Links deeper than the probed paths (other than <agent dir>/skills) aren't resolved. A distro probed by an older magpie has no Links until probed again (each run). Run: - Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex, .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway Windows test running the real probe with that HOME: probe said link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi, win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\ magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file when that file already exists" (the report's error). distro.open wrote SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both read back with cat in the distro through the links; .pi said "~/.pi in WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target removed after. - New tests with a fake distro whose ~/.codex and ~/.claude are links to /mnt/c/... that don't exist here, so, as through \\wsl.localhost, nothing below them can be made: TestWSLFolderIsALinkToC, TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink, TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved (agent). - Broken by hand: the library tests on the base (with a no-op FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the report's error; with ggbdpq's patch applied they still fail (the skill mkdir, and RTK's hook not written). - mote: go build ./...; go vet of agent, library, sessions, provider for darwin, GOOS=windows (and linux for agent, library); gofmt -l clean; go test -timeout 45m ./internal/agent ./internal/library ./internal/sessions ./internal/provider: all ok. - Windows (win-run): the same four packages. The new tests pass (the RTK ones skip: the fake distro runs sh). 32 tests are red, all already red at the base |
||
|
|
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
|
||
|
|
250bdd5c4f |
gui: Names in agents' lists names the connected agents it changes nothing in (love1sbug on X)
love1sbug on X found Names in agents' lists seemed to do nothing. Claude Code and Qwen Code follow it now; a sweep of every agent in a sandbox HOME (each set to one relay model, the setting switched, the files compared) found the rest that follow it, and those that can't: - handed the models' ids alone, their formats having no name for one: Goose, jcode, Hermes Agent, Reasonix Studio, AtomCode, fx, Antigravity CLI, AstrBot, Mister Morph; - with no list of magpie's models: Gemini CLI, Snow CLI; - reading the gateway's /v1/models themselves, whose display_name is the name alone on purpose (a remote magpie relies on it): Empryo, Cursor Private Inference. Those carry agent.NoNames (copied to an agent in WSL), sent to the GUI as noNames. Where the setting is offered (Settings › Provider in model names, Routing's Names in agents' lists, a provider's Names & levels) a line names the connected ones: "Changes nothing in Goose, Hermes Agent: magpie's names don't reach their model lists", in every language. With none connected nothing is said, so the Settings row keeps no line under its name (1ooogle on X, model-suffix-own's check). A page drawn before the agents are read (Routing, an open provider editor) says it once they are (redrawNoNames, beside redrawSuffix). name-suffix-no-names.test.cjs checks the three places in chromium and webkit, en/zh/zh-TW/ja/de, at 900px and 390px with no sideways scroll, that an agent not connected or following it isn't named, that none says nothing, and, with /api/state answered 1.5s late, that all three still say it. On the old assets 12 of the first 13 chromium tests fail; the late case failed on this commit's first version too (found when a loaded run failed the editor's case; reproduced with the injected delay). Run: that test and i18n-keys, gateway-mode, model-suffix-own, name-suffix-remote, name-suffix-saved, name-suffix-where-named, settings-general/groups/search/sections in both engines; go test -tags nogui ./internal/agent ./internal/gui ./internal/provider ./internal/gateway (before the rebase); gofmt -l; go vet darwin/linux/windows. With 11 files at once at load 80-120, webkit failed once on this test's "no page errors" check (ja 900px, the late case) beside settings-sections' "Settings in parts"; not reproduced in 3 runs since (10 files, then 8 copies at once), and the errors weren't kept. Not tried: the GUI against a real magpie with Goose connected. |
||
|
|
9c11abbd00 |
agent: jcode is an agent magpie connects: a magpie profile with magpie's models, jcode started on the one picked (wani on Discord)
wani asked on Discord for jcode (1jehuang/jcode, a coding agent in Rust)
as an agent magpie connects. There was no earlier request in issues or
history.
What changed:
- internal/agent/jcode.go: a new agent for jcode's config.toml in
$JCODE_HOME, else ~/.jcode (jcode-storage's jcode_dir). Detected by the
file, the folder, or `jcode` on PATH.
- Connecting adds a named profile, [providers.magpie], with the keys
`jcode provider add` writes: type "openai-compatible", the gateway's
/v1, an inline api_key naming jcode (magpie-jcode; jcode's requests
carry nothing else that tells it apart) and requires_api_key = true.
Without that key, jcode sends no key to a loopback base URL.
- Its models list has one entry per model of magpie's: context_window
(128000 when magpie doesn't know it; jcode would assume 200k), input
text/image, and reasoning = true for a model with effort levels, so
jcode's /effort offers them.
- It sets [provider] default_provider = "magpie" and default_model, the
model picked. What was there is stashed, and Disconnect puts it back.
- Picking a model of jcode's own while it is on magpie takes magpie
out: the profile goes and the user's provider comes back with that
model.
- Each key is set alone, so the user's other keys and tables stay, as
do their own keys in magpie's profile (headers, extra_body) and a
reasoning_effort they set on one of its models while the model has
that level.
- jcode writes a profile's models as [[providers.magpie.models]]
tables when it rewrites the file itself (Config::save,
to_string_pretty). Those are replaced by the one list.
- A sync with nothing to change doesn't write.
- Disconnect drops the profile whole, sub-tables included.
- Check says when the profile is gone while jcode still starts on it,
or when its base_url or key is off.
- While jcode runs, the notice says to restart open jcode sessions,
since it reads the file when it starts. The notice is a newNotice
template, translated in i18n.js (zh-CN, zh-TW, ja, de) and listed in
NOTICES, as TestEveryNoticeIsTranslated asks.
- agents.go, agentenv.go: registers it; JCODE_HOME joins the agent env.
- icons/jcode.svg: jcode's halftone mark (jcode.sh/favicon.svg) as a
mask icon, every other dot of its lattice.
- docs/reference.md, docs/subsystems/agent-wiring.md, README.md,
README.zh-CN.md: jcode's row and its place in the agent list.
- WSL isn't covered: jcodeAt reads the place's home and JCODE_HOME, but
it isn't added to the WSL agent list (another session has wsl.go open).
What was run:
- go test -tags nogui ./internal/agent -run '^TestJcode'. The fixture is
the bytes jcode 0.94.0 wrote for `jcode provider add`. The tests went
red when, by hand, I:
- made a no-op sync write;
- dropped the user's reasoning_effort;
- skipped the stash, so Disconnect wasn't byte-identical;
- left jcode's [[providers.magpie.models]] tables in, which makes
invalid TOML;
- dropped requires_api_key.
- Real use:
- jcode v0.94.0 (release binary, sha256 checked) ran under a sandbox
HOME with JCODE_HOME set and JCODE_NO_TELEMETRY=1. Its config.toml
was the one jcode wrote for its own "probe" profile.
- A sandbox magpie (MAGPIE_ADDR 127.0.0.1:3671) with a fake OpenAI
upstream on 3672 ran `magpie jcode magpie/fake/org/echo-1`, a model id
with two slashes.
- `jcode run 'Say hello in one word.'` answered with the upstream's
reply, streamed. The upstream saw model org/echo-1, and usage.jsonl
recorded the turn under agent "jcode".
- `jcode provider add two …` while connected appended its own profile
and left magpie's as it was.
- `magpie jcode default` then gave back the file jcode wrote,
byte-identical, with jcode's new [providers.two] kept.
- The icon rendered as a mask in Chromium and WebKit. The only GUI
change is the notice's translations; TestEveryNoticeIsTranslated and
internal/gui pass, and node --check accepts i18n.js.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent
and internal/agentenv; go test -tags nogui ./internal/agent
./internal/agentenv ./internal/gui; go test -tags nogui ./... under a
temp HOME (load ~80): every package passed. After rebasing on
origin/main, internal/agent and internal/agentenv were run again,
along with internal/gui, gofmt and the linux/windows vet.
|