3eba174fd90eca4fe1622fa8e16bfa076281ac32
2662
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
82611c3c9e |
library: a project turns on a plugin Claude Code installed, in its own settings (#7254)
Plugins Claude Code has installed itself (installed_plugins.json) are listed on a project's Claude plugins tab, each with one Claude chip. On writes enabledPlugins.<id> = true into the project's .claude/settings.local.json through the format-preserving JSON edit (comments and the user's keys stay); off takes out only a key magpie wrote that is still true. A key the user already had is neither written nor taken out; a file magpie made goes once the skill offs, hooks and plugin keys sharing it are all gone. Worktrees follow through syncTrees; RemoveProject lets go. Written fresh, not ported. Run (mote-run): go vet library/gui/cli; go test ./internal/library -run TestProjectClaudePlugin (new, two tests); project-claude-plugins, project-plugins and i18n-keys GUI files in chromium and webkit, en and zh; go test ./internal/gui reds only on testenv's docs-index guard (routing-groups pages newer than the search index, not from this change). Not tried: a real Claude Code reading the project's enabledPlugins; the whole GUI suite; a CLI for it; "off" for a plugin the user turned on user-wide. |
||
|
|
ab342fa40d |
library: magpie library project server and subagent add, rm and agents (#7248)
The CLI had project skills and instructions only. `server` and `subagent` now list, add (agents= or the agents already used, else every agent here that reads a project's MCP file or subagents folder), take out and re-point a project's library servers and subagents through ProjectServer and ProjectSubagents, the calls the Library page makes. A name the project doesn't have is refused, as is an unknown agent or flag; a part magpie couldn't place exits 1 with why. The command shape follows the reference commit in the reporter's fork (0d3a6de55), rewritten over this tree's calls rather than ported. Run: mote-run go test ./internal/cli -run TestLibraryProject (the new TestLibraryProjectServerAndSubagentCmd: the user's own .mcp.json server survives an add and an rm, Codex's file gets the server, Claude's and Codex's subagent files come and go with their agents). gofmt and go vet ./internal/cli clean. Not tried: the whole Go suite; the package run also prints testenv's docs-index guard (routing-groups pages newer than the search index), which is not about this change; a real agent reading the files. Co-authored-by: Arobotmaster <50254754+Arobotmaster@users.noreply.github.com> |
||
|
|
6d153bffca |
library: list the skills, MCP servers and hooks of plugins installed natively in Codex and Pi (#7244)
The Library now reads Codex's plugin cache (plugins/cache/<marketplace>/<plugin>/<version>,
manifests under .codex-plugin, .claude-plugin or .cursor-plugin; config.toml's
enabled flag) and Pi's packages (settings.json packages, package.json pi.skills,
user and project scope) and lists what they bring on the skills, MCP and hooks
tabs under "Installed in the agents themselves", with origin and scope.
Read-only: nothing is copied, linked or registered; the agent keeps loading it,
load status stays unknown. Paths stay inside the plugin; an unreadable file
means unknown. New GET /api/library/native (lazy, not on the polled
/api/library) and `magpie library native`. Docs row in library.md.
Run (mica, sandbox HOME, nothing of the live ~/.codex or ~/.pi touched):
- go vet darwin; internal/library native tests (6) and the new GUI test
library-native.test.cjs in chromium and webkit, 5 languages, 980 and 380 px.
- Built binary against a sandbox copy of the real Codex cache manifests (74 files).
- Not tried: Claude native plugins, subagents, Pi MCP and hooks, a live Codex
or Pi, Windows and WSL Pi. The whole GUI suite and the full Go suite run after the push.
- Not mine: every package using testenv is red on origin/main
|
||
|
|
9ec023a46b |
routing: the default routing is called Quota first, not Smart (@canlee886)
The groups magpie finds on its own (auto/<model>) hold one model served by
several providers, and with no rules they follow their Routing, whose
default was labelled Smart / 智能. @canlee886 read that as "judges how hard
the task is and sends easy ones to a cheap model". It does not: the member
whose allowance renews soonest goes first, ties in list order, the next takes
over on a failure.
A cheap-model rule cannot be a built-in default for these groups: their
members are the same model, so there is no cheaper member to send an easy
request to. The mechanism for hard-to-strong, easy-to-cheap exists (the
"Hard to strong, easy to cheap" template and rules with an intent) but it
needs members of different strength, which the user picks. So the honest fix
is the label.
- The mode is "Quota first" (额度优先, 額度優先, 枠優先, Kontingent zuerst) in
every picker, chip, tooltip and hint, in all five languages (the English
key text and each translation).
- The no-rules line now says it does not judge how hard a task is.
- docs/reference.md, gateway-routing.md and the routing-groups site pages
(en, zh, ja) name it the same. The stored value ("") is unchanged, so no
saved group or provider changes behaviour and nothing needs migrating.
Run (mica, node --test, chromium and webkit, five languages): 19 GUI files
(routing-rule-example, routing-save, routing-group-strategy, routing-manual,
routing-weight-chip, rotate-figure, account-weight, routing-key-windows,
routing-free-expiring, builtins, i18n-keys, i18n-en-no-cjk and the routing
Smart-text files): 440 of 446 pass. The 6 reds (account-arrange 1 and 2,
key-weight 17 to 20) fail identically on origin/main
|
||
|
|
f534245f1c |
routing: a group with no rules says how it routes (@canlee886 on X)
The editor said nothing of what a group does with no rules. Without rules the group goes by its Routing (Smart unless set): the member whose allowance renews soonest first, ties in the listed order, the next taking over when one fails. One line under Rules now says so (and names the routing when another is set); with one model or Manual the existing line stays. Added in zh, zh-TW, ja, de. Layout unchanged. Run on mote at the change: routing-rule-example (extended: the line in every language, Smart and In order, gone once a rule is added; Chromium and WebKit, 1100 and 390 wide), routing-advanced, routing-rule-ops/ remove/drag/columns/models/effort, routing-entry, routing-intent-entry, group-editor-fits/align, group-template, i18n-keys: all pass. Not run: the whole GUI suite, Go (no Go changed), the real app. |
||
|
|
f7173c79a3 |
codexcat: another magpie's ChatGPT model is Codex's own, given this Codex's entry for it
A remote with no Codex cache of its own (a server) builds its entry from the bundled instructions, so office/codex/gpt-6-astra still lacked the backend's model_messages and fields. OwnSlug takes an id ending in the entry's codex/<slug> as Codex's own: entriesAt gives it this computer's models_cache.json entry, as a local account's codex/<slug> gets, and OwnIn keeps it in the Codex app's first list (gateway catalog too). A relay's plain gpt-6-astra is not taken. Run (mote-run, rebased head): TestRemoteChatGPTModelIsCodexOwn red with OwnSlug turned off (description "GPT-6-Astra via magpie", OwnIn false), green now; the codexcat, provider, gateway and gui runs, gofmt and the three vets in the commit before. e2e with a models_cache.json in the local CODEX_HOME: description "Frontier intelligence for the most demanding work." and model_messages present, codex exec FAKE-OK. Not run: the full suite (next, at the pushed head); a real ChatGPT account behind a real remote. |
||
|
|
958d4fcaf1 |
pii: the local models' folder is chosen under Advanced, and Move… moves them (MetalHqa on X)
On Windows both models (Privacy Filter 1.6 GB, AstrLink Guard 39 MB) went onto the C: drive with no way to choose. Settings > Privacy now has Advanced > Models folder: Move… picks a folder in the system's picker and moves what is downloaded there; Move back returns it to magpie's cache. The default is unchanged. - settings.RedactModelDir is this computer's own (kept by KeepOwn, never set by a settings save). - pii.Root() is the one place every path is made from (dir, guardRoot, so the model, its cache files, pf-serve, the CoreML program). - pii.MoveTo: a rename on one disk, else a copy checked by sha256 read back; the setting switches after it and the old subfolders are deleted last (never the picked folder); a failure puts back what it moved and keeps the old copy. Refuses a relative path, an unwritable folder and one inside what is moved. A picked folder that has gone (disk unplugged) is not recreated by a download. Download and Remove wait out a move. - GUI: pmfolder.js, loaded on first draw so the core script is no bigger; strings in zh, zh-TW, ja, de. Docs: gateway-routing.md, masking.html (en, zh, ja), site index regenerated with docs-index.mjs. Run (mica; mote had no room, load 35/18 and 29/12): - go test of internal/pii folder tests, internal/gui TestPrivacyModel*, internal/settings and settingsapi keep tests: ok. Each broken by hand and red: guardRoot ignoring the folder, no rollback, no missing-folder check, KeepOwn line removed, settingsapi line removed, folder action not calling MoveTo. - Windows box (win-run): the move tests ok, TestMoveAcrossDisks on a real C: to D: move ok. - GUI privacy-model.test.cjs, Chromium and WebKit, 5 languages, 1100 and 640px: 104 of 104. - go vet on pii, gui, settings, settingsapi for linux (nogui), windows and darwin: clean. node --test site/*.test.mjs: 135 of 135. Not run before this push: the whole GUI suite, go test ./... (both follow at the pushed head), the size-budget and i18n tests (run after the rebase), gofmt over the whole tree (touched files only), and a real Privacy Filter download into a picked folder on a real account. |
||
|
|
83bb079dee |
gui: the scroll capsule sits above Plugins' install box and the Library's save and pick bars, not over Install (WaiooT on X)
scrollends.js lifted the capsule above only .after-list and .view-foot. Plugins > Discover's .pm-manual (and the Library's .lib-savebar, .lib-pickbar) are held at the window's foot too, so the capsule covered the Install button's right end. They are now in the list it steps over. No layout change. Run (mica, copy of this tree): new view-ends-install-bar.test.cjs red on the old scrollends.js (390px: capsule over pm-browse, pm-minput and Install, all 12 subtests) and green on the new one (12 of 12: chromium and webkit, en/zh/zh-TW/ja/de, 390/560/980/1280 wide); with only the Library classes removed it is red at lib-savebar. go vet ./internal/gui/... and GOOS=windows go vet, gofmt -l clean. view-ends, view-ends-relayout, routing-editor-foot, plugin-manual-float and i18n-keys: 78 of 80 together; the 2 are webkit view-ends' first subtest (en 440 light) timing out at 8s in that batch, twice, while view-ends.test.cjs alone under BROWSER=webkit is 16 of 16 on this tree and on origin/main. Not run: the whole GUI suite and go test ./... (mica held by another session's full GUI suite, mote at load 46; to be run at the pushed head), the Library's own bars with real fixtures (stand-in sticky bars of each class are used), the real Linux app. |
||
|
|
f288cc61af |
sessions: a deleted Grok Build session's index rows come back with its restore (#4595)
Follow-up to crayonlu's commit (Grok Build sessions deletable, their session_search.sqlite rows dropped first). Review of that commit: Sound: the delete is scoped to the session's own folders (updates.jsonl's dir, plus its subagents' sibling folders grokFiles already folds in); the cwd's prompt_history.jsonl and other sessions stay. The index is opened by a normal connection with a 5 s busy timeout and BEGIN IMMEDIATE, so it works beside a running Grok Build (WAL, the file's journal mode is left as it is); a file that can't be opened or read stops the delete before anything moves (failed read = unknown); no index or no tables deletes as before. Nothing touches the network, no new dependency, no .github/site. Checked against Grok Build 1.0.67 itself (its binary's SQL and the index it wrote on this machine, copied, never opened live): session_docs has session_id, cwd, updated_at, title, content, content_hash, over session_docs_fts with the _ai/_ad/_au triggers; there is no DELETE FROM session_docs in the binary, so Grok has no delete of its own to match. Wrong or thin: Restore did not put the index row back, and Grok Build's bootstrap is stamped in meta.last_bootstrap_at, so nothing says it indexes a restored folder again; a move that failed after the rows were gone left the session whole but unindexed. Now grokSearchRowsDrop returns the rows, every column by name (so a Grok Build that adds a column keeps it), and Delete keeps them in the trash entry's grok_search.json (not in the note the Trash page lists). Restore INSERT OR IGNOREs them (a row Grok wrote again meanwhile wins; an unwritable index doesn't stop a restore), and a delete that stops after dropping them puts them back. TestGrokDeleteRestore now checks the rows and FTS entries are back; TestGrokSearchRowsComeBackWhole checks every column and the kept row. Broken by hand: Restore without the put is red on "after the restore: 0 rows and 0 found". Run (mote, worktree of this branch; full suite at rebased |
||
|
|
6671091676 |
sessions: Grok Build's sessions are deletable, its search index's rows going with them (#3003, #4595)
#3003 (acsfreerun) asked for a Delete on Grok Build's sessions; #4595 kept them listed with no Delete, because a session is a folder but Grok Build copies each session's text into $GROK_HOME/sessions/session_search.sqlite, which a folder delete would leave behind: its search would go on finding a session Grok Build no longer lists. Deletable("grok") now says yes, and sessionPaths' "grok" branch moves the whole folder (updates.jsonl, summary.json, the locks, prompt_context.json, terminal/, everything else it kept) and its subagents' folders, which grokFiles folds into the session it ran in. What the cwd's folder holds for every session there (prompt_history.jsonl), another session's folder and the index stay. The trash, Restore, Purge, the recent-write ErrActive guard and WSL handling are the ones Delete already has. grokSearchRowsDrop (grok_search.go) deletes the deleted session's row in session_docs, and its subagents', inside one BEGIN IMMEDIATE with a 5 s busy timeout, so it waits for Grok Build's own write instead of failing; the session_docs_ad trigger takes the row out of session_docs_fts. It runs before the first file is moved: a row that can't be taken out (a database that isn't one, a lock held past the timeout) stops the delete and the session stays whole, rather than a folder gone from the list and still found by search. No index file, or one without those tables, deletes as before. Restore brings the folder back; the index row is not put back, so Grok Build's search finds a restored session only if Grok Build indexes the folder again. Tests, in-repo and on fixtures, never on a real ~/.grok: the sessions package's fixture tree gained a lock file per session, a subagents/ entry, a terminal/ file and the cwd's prompt_history.jsonl, and a small session_search.sqlite is built in-test from the real file's schema (v4, session_docs over FTS5 session_docs_fts with the three triggers). TestGrokDeleteRestore (delete, folder and row and FTS entry gone, another session's row kept, ErrActive, Restore, Purge), TestGrokDeleteLeavesTheSessionWhenItsIndexRowCantGo and TestGrokSearchRowsDrop; TestGrokSessionDeleteOnThePage drives the page's own handlers (GET /api/sessions/manage?agent=grok says deletable, POST /api/sessions/delete moves it, the trash lists it, POST /api/sessions/restore puts it back). docs/subsystems/gateway-sessions.md: the delete paragraph, and Grok Build out of the "sessions magpie cannot delete" list. Run (mote, this tree, on origin/main |
||
|
|
d245951c9f |
gateway: Antigravity and agy get the hub's tools whole, not find_tools/call_tool
/hub/antigravity wrapped a big tool list in find_tools/call_tool, a second
lazy load on top of Antigravity's own (izhidigua on X, 11-19). agy 1.5.12
loads MCP tools lazily itself: its binary carries "Call a lazy-loaded MCP
tool. Read the tool's schema file", McpToolConfig.enable_lazy_load,
SplitEnabledToolsByEagerLazy and per-tool schema files under
~/.gemini/antigravity-cli/mcp/<server>/. So agy and antigravity join
hubSearchers, like claude, codex, pi, droid and omp. mcp-router.md says so.
enable_lazy_load is a config flag that may be set by the server, not by the
client; an account where it is off would list every tool whole.
Run: TestHubMCPToolsWhole now covers agy and antigravity; with both removed
from hubSearchers it fails ("agy listed [find_tools call_tool]"), with them
it passes. go test -run 'Hub|MCP' ./internal/gateway ./internal/gui ok on
mote; gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
of internal/gateway ok.
Not run: the full Go suite (mote and mica were both busy with other
sessions' full suites), a real agy session. The Library's agy
mcp_config.json handling is another session's and is untouched.
|
||
|
|
0417417e57 |
library: a project takes a whole Claude plugin, and gives it back (jinpwng on X)
A project can now have a library Claude plugin for chosen agents (projects/plugin). Its skills, MCP servers and subagents go where the project's own do (withPlugins adds them for a sync and puts the project's own sets back after), and its hooks are written entry by entry into .claude/settings.local.json and .codex/hooks.json (HookRecs). Taking the plugin out deletes it from Plugins, and only what magpie placed or wrote comes out; an entry the user changed stays. Removing a plugin from the library drops it from every project. The Library plugins tab gets a Project plugins section with per-agent chips, in en, zh, zh-TW, ja, de. Run, on mote at the pushed head (rebased on origin/main |
||
|
|
0a37c93682 |
library: a skill linked in from ~/.agents/skills whose folder is gone is shown as gone and given to no agent (#7226)
"Bring in all" links a skill of the skills CLI's folder into the library. After `npx skills remove` its folder is gone: the library entry stayed listed and every sync linked each ticked agent to the dead link. markDangling (skill_dangling.go, each read and sync) finds a linked-in skill whose folder is absent or has no SKILL.md, marks it Gone (the page already offers to take such a skill out; RemoveGoneSkills only removes the link) and sets Skill.Dangling, which gives() reads, so no agent, project or shared folder is given it and magpie's own links to it are taken away. It is cleared when the source returns. A stat error other than not-exist is unknown and keeps the entry. Nothing the user owns is deleted. The library's own folders are never judged. Run (sandbox HOME, tests only): - New TestLinkedInSkillWhoseSourceIsGone and TestSourceGoneKinds: red on the old code (no Gone, agents keep the link), green after (mica-run). - Windows junction case TestJunctionToARemovedFolderIsGone, plus the two above, via win-run on xiaomi-gpu: ok. - gofmt -l clean; go vet -tags nogui ./internal/library for GOOS=linux and windows: clean. - Full `go test -tags nogui -timeout 45m ./...` on mote at this head was still running when pushed (the first 39 packages ok, no red); shipped on the coordinator's word with these targeted runs. No reds named. Not tried: a real `npx skills remove`, the GUI (no GUI files changed, so the GUI suite was not run). |
||
|
|
5d4f9862ca |
library: an agent that is not installed is listed only for what magpie gave it here, not for a synced tick (izhidigua on X)
A library synced from another computer carries each item's agent ticks. held() counted a tick as a reason to list a not-installed agent, so on a computer without Claude, Claude Code or Pi the MCP switches (and any row withGone widens) listed them, while Skills showed only the installed four. Take-it-out (Target.Gone) is for what magpie wrote into the agent on this computer, which Applied records and sync never carries; a tick alone gave it nothing to take out. held() now counts only Applied (skills, MCP, hooks, env, router, router rules). Run, on mote at this tree: TestGoneAgentWithOnlySyncedTicksIsNotListed (new; claude-desktop, claude and pi ticked from a sync, none installed, nothing Applied), red on the old code (all three listed), green now; TestGoneAgentListedToTakeOut still passes (an Applied agent is listed); go test ./internal/library; gofmt -l; go vet of internal/library for linux, windows and host. Not tried: the reporter's two computers; the whole GUI suite (no page file changed). Full suite, mote, at 7bb2f5ac0 (this change on |
||
|
|
7f3b272726 |
library: the Antigravity app and agy share one MCP file, and magpie's entry in it is magpie's (izhidigua on X)
Antigravity and agy read and write the same ~/.gemini/config/mcp_config.json. With both ticked and MCP routing switched on, the first one's sync wrote the "magpie" entry; the second one's hubFor then found a "magpie" entry it had not written itself and judged it the user's own server by that name (hubOwn): it kept a direct connection and offered to import it, and switching off left that side's servers behind. hubFor now asks sharerWrote: an entry by the hub's name in a file that another target reading the same path has Applied is magpie's own. Run, on mote at this tree: TestAntigravitySharedMCPFile (new; two rounds of on then off, with fs stdio and web http ticked for both, then Read shows no server direct), red on the old code (the second agent kept its servers direct and the file kept the foreign entry), green now; go test ./internal/library; gofmt -l; go vet of internal/library for linux, windows and host. Not tried: real Antigravity or agy (sandbox HOME only). Full suite, mote, at 7bb2f5ac0 (this change on |
||
|
|
fa52741ebc |
agent: omp 18.1.6 and later name themselves; magpie's User-Agent only for an older omp (Zyvaletta on X)
magpie wrote `headers: {User-Agent: omp}` into omp's models.yml for every
omp. A newer omp sends `omp/<version>` itself, and the header put that
version out of sight.
From omp's own source: pi-ai 18.1.6 (CHANGELOG 2026-09-03, "Inference
requests now identify as omp by default") wraps fetch in
withInferenceUserAgent, later transportFetch, which sets User-Agent
omp/<VERSION> only when none is set. Real omp runs against a stand-in
gateway on mote, sandbox HOME, `bun add @oh-my-pi/pi-coding-agent@<v>`,
every API (Chat, Responses, Messages, Gemini):
16.3.5 and 18.1.5: Bun/1.4.2
18.1.6 and 18.4.4: omp/<version>
18.15+ needs Bun >= 1.4.4 (mote has 1.4.2); its source (18.15.0,
18.22.2) has the same transportFetch.
Now (ompUserAgent): no header from 18.1.6 on; omp/<installed version>
before; plain omp when the version isn't known. The version comes from
the installed package.json (InstalledVersion), never the network.
ompKept takes a User-Agent of magpie's own (omp, or omp/<version>) for
magpie's, so an old `User-Agent: omp` is replaced or removed on the next
sync, and any other value, under any casing, is the user's and stays
alone. usage.AgentOf cuts at "/", so omp, omp/16.3.5 and omp/18.4.4 all
count as omp; nothing reads omp's version from the UA.
Tests (internal/agent/omp_useragent_test.go): TestOmpUserAgentByVersion,
TestOmpOldMagpieUserAgentSynced, TestOmpUsersOwnUserAgentStays.
Broken by hand: origin's omp.go with a stub ompOwnUserAgent, all three
red; ompKept returning yamlKept's result unchanged, the last two red.
Real omp with the new header (mica, same stand-in): 16.3.5 and 18.1.5
with `User-Agent: omp/<v>` send omp/<v> on all four APIs.
Docs: docs/subsystems/agent-wiring.md row "omp's User-Agent"; site
omp.html en/zh/ja.
Run at this tree (base
|
||
|
|
bb9c5ae154 |
gateway: an inline image is counted in the context map by its vendor's rule, from its size (paiven_x on X)
@paiven_x on X: a Codex session (gpt-6.1-terra) of a few hundred small
screenshots sent ~42 MB a request, and the context map showed 764K
tokens, 413K of them images, while Codex's own count was about 371K.
Every inline image was taken at a flat 1600 tokens (imageTokens), so
~258 small screenshots read as 413K where OpenAI counts an 800x500
one at 480.
Now an image's width and height are read from its header alone
(image.DecodeConfig over a streaming base64 decoder: a few KB of a PNG,
a JPEG up to its frame header, a lean body's imageRef through
keptImageOf), and counted by the rule of the protocol's vendor
(prompt_image.go):
- Anthropic: 28 px patches, ceil(w/28)*ceil(h/28), after the reference
resizedSize; 2576 px / 4784 tokens for Claude 4.7 and later, 1568 /
1568 before.
- OpenAI patch models (GPT-5.2 and after, the minis): 32 px patches
times the model's multiplier, in the side and patch budget each
detail sets (low/high/original/auto per model, as the vision guide
lists them).
- OpenAI tile models (gpt-4o, gpt-4.1, o1/o3, gpt-5/5.1): base plus
512 px tiles after 2048 and 768 fitting; low is the base.
A link, a file, a document, an unreadable image and a Gemini request
stay at 1600; the vendor's count still scales them all (calibrate).
The 475K Codex never reached is Codex's own: 95% (its
effective_context_window_percent) of the 500K its bundled catalog gives
gpt-6.1-terra. magpie writes no auto_compact_token_limit for Terra
unless the user set one (Working keeps its own 500K). Codex compares
the usage the vendor reported (~381K), which was under it, so nothing
compacted until /compact. No workaround added.
Tests: TestPromptImageTokensByVendor builds real PNG and JPEG bytes
(image/png, image/jpeg Encode) and checks each vendor's own doc
numbers: Terra 800x500 auto 480, 2880x1800 high 2949, gpt-5.5 low 192,
gpt-4o 1024x1024 high 765 and low 85, Claude 1920x1080 2691 (high
tier) and 1560 (Sonnet 4.5), 3840x2160 4784, a JPEG behind a 40 KB
APP1 330, \/-escaped base64 480. TestPromptImageSizeReadsHeaderOnly
reads 2880x1800 from the first 4 KB of the base64 and falls back to
1600 for a link, a file and undecodable bytes.
Broken by hand: imageTokensOf replaced by the constant, all 10 cases
of TestPromptImageTokensByVendor red at 1600.
Run at this head (e67b0f4fa, rebased on origin/main
|
||
|
|
ed405d1d78 |
gateway: an Azure key that answered before, refused 401, rests suspended till it answers (canlee886 on X)
An Azure subscription with a spending limit (a student's $100 a month, a trial's) is disabled by Azure when its credit runs out and enabled again on its own when the credit renews. Meanwhile every request 401s "Access denied due to invalid subscription key or wrong API endpoint", the words a wrong key gets. magpie read that as any 401: failOther on the 1-minute backoff climbing to 10 minutes, never asked in the background, so the key was asked again by requests for weeks, and the reporter turned the provider off and on by hand around the reset day. Now restAfterMarked reads a failOther 401 as failSuspended when azureSuspended holds: no account, Provider.IsAzure, and the key has answered a request before (provider.LastServed at provider.ServedID, served.json, 30 days) or is resting suspended already. It rests suspendedRest (a day) by "suspended", and probeable takes it whatever its status: keepProbingRests asks the resource's deployments list with the key at 1, 2, 5 and then every 10 minutes (refused the same while the subscription is off) and lifts the rest as soon as the list answers, or when a request does. Its group's requests go to the next member meanwhile, Azure not asked. Product calls (mine to make, delegated): - One 401 is enough, not "repeated" ones: a 401 is about the credential, never the model or the request content. On a key that worked, a transient 401 is lifted by the first ask a minute in, the same as the old one-minute backoff let it back. - A bad key stays a bad key: a key 401 from its first request (new, mistyped, or edited, its KeyID then another) has no answer on record and rests as before, failOther/backoff, shown "401 · failed", never asked in the background. served.json unreadable is no answer on record too (a failed read is unknown, not "it worked"). - Azure only: a 401 says nothing of why on other vendors, and a list that answers without the key (OpenRouter's is public) would lift a key its vendor still refuses. - No "back on day N" setting: the probe finds the day Azure enables the subscription, so there is nothing for the user to type in, and no Advanced field. GUI: the key list says "Resting · 401 suspended by the vendor · back at … · checked in the background, back as soon as it answers"; Routing's restHow says its key answered before, so the vendor has most likely suspended it (an Azure subscription out of credit). KEY_FAIL and the routing plugin's FAIL gain "suspended", in en, zh, zh-TW, ja and de. keyDead is unchanged, so "Remove failing" doesn't offer a suspended key. docs/subsystems/gateway-routing.md has the rule beside the rest probe. Not covered: a 403; a key whose last answer is over 30 days old after a restart (rests are in memory); the last candidate of a request, which rests only for quota, credit or a timed rate limit, so a lone Azure provider is asked again by each request, as before, and answers as soon as Azure does. Run on mica (mote had other sessions' full suites), at b4c88d44e unless named, rebased on |
||
|
|
aeca7ae074 |
usage: a Claude Enterprise seat's 5 hours come from Claude Code's usage rows; a plan with none says so
@andy_chen1997 on X signed a Claude Enterprise account in, and the Usage
card said "Allowance unavailable", with the reason "Claude Code's /usage
is temporarily unavailable". magpie reads Claude usage only from `claude
-p /usage`. Claude Code 2.1.328 draws that text from the usage endpoint's
five_hour, seven_day, seven_day_sonnet and model-scoped weekly rows. When
it draws none of them, the text is just the subscription line, and
parseClaudeUsage read that as a failed read. An Enterprise seat gets there
in two ways:
- its 5 hours come only as a limits[] row (kind "session") in the JSON
usage_report, with five_hour null. The gateway now adds each session,
weekly_all and model weekly_scoped row as /usage's own line, and only
when the text drew no window of its own. The ISO reset is parsed
(RFC3339Nano). A row of another shape is skipped, and it never loses
the extra usage line.
- its plan has no meters: limits is [], or the seat is usage-based
(Claude Code's vmr/fD: oauthAccount seatTier "enterprise_usage_based"
or billingType "usage_based" in .claude.json). The card now shows
"5-hour and weekly limits: None on this plan" as a text row, set aside,
beside its usage credits. This is not an error, so it isn't used up and
routing holds nothing against it.
A real fetch failure (rate_limits null, or limits null) still says
temporarily unavailable. magpie still never calls /api/oauth/usage
itself.
Our earlier reply ("Enterprise shows only the 5-hour window") holds for
seat-based Enterprise. It was wrong for usage-based seats, which have no
5-hour or weekly limit at all.
The marker line is "Usage report: no meters on this plan", because a
first wording with "usage limits" was read by claudeUsageDenied as an
account error. The new test caught it.
Run on mote. At the pushed head (on origin/main
|
||
|
|
e4e9eb0928 |
usage: a ZCode call to a provider added by hand at magpie's address is not a local session's (jiangshangmuyun on X)
The Usage page listed one ZCode call as "new-provider · 本地会话" among the
gateway's own rows for the same Trae CN DeepSeek calls. The reporter has one
ZCode window and routes everything through magpie.
Cause: the user added magpie to ZCode by hand as a provider of their own
("new-provider", base URL magpie's gateway), not through magpie's connect,
which writes the id "magpie". ZCode records that id beside each reply, and
readZCodeCalls left out only "magpie"/"dial" (ocGatewayProvider). Its calls
were read from ZCode's database as well as logged by the gateway, and only
hidden again where pairing by session, tokens and end time matched; a call
whose counts didn't agree was listed twice as a "local session".
Fix: zcodeGateway also takes any provider whose base URL, in ZCode's
config.json or provider_config.json, is this machine (loopback, localhost,
0.0.0.0, one of its own addresses) on the gateway's port (MAGPIE_ADDR or the
saved port). Such calls are left out before pairing, as "magpie" ones are.
zcode's call parse version is 4, so cached shards are read again. Like
workbuddyGateway it reads the configuration as it is now. The label itself
is unchanged: a call that did go straight to a vendor is still a local
session's.
Siblings filed, not changed: OpenCode/MiMo (ocGatewayProvider), Pi
(piGateway) and dsh still match the gateway by provider name only (#7193).
Go run on mote at this change on base
|
||
|
|
992f88d634 |
usage: a stand-in reading says why the read behind it failed
@tmr11235 on X (tweet 2123334817991520577, magpie v0.1.4520): agy-cli's card showed "截至 2026/11/15 14:19:19,暂时无法获取最新额度" days later, with nothing to say why. keepLast stands the last good reading in for a read that fails with a passing error (timeout, 429, 5xx, network) and dropped that error, so a stand-in that lasted four days read the same as one a minute old. The reading now carries the error as readError (SubscriptionQuota, and Quota for `magpie quota --json` and the gateway report), and asOfText puts it after the date: "… 暂时无法获取最新额度 · agy usage query timed out." A deferred read (not asked) has none, and the short "As of" line on cards stays short. Every provider's stand-in gets it, not only agy-cli's. Run (mote, at origin/main |
||
|
|
c01988e439 |
routing: a group's Small context first sends a request to the smallest window that holds it
yg6888 on X (tweet 2123308968848379920): in a group routed Smart, Cursor Plus's Composer and Grok 4.7 were never used. Not a bug: Smart orders by allowance tier, then soonest renewal, then listed order, and never weighs the context window, so the 1M members listed ahead always answered. The small ones were only ever reached as a fallback. Smart itself is unchanged; changing its order would move every Smart user's traffic. A group gets a new routing instead, `fit` (Small context first; 小上下文优先, 小上下文優先, 小さいコンテキスト優先, Kleiner Kontext zuerst): - routes.SmallFirst takes Smart's order and sorts it stably by band (a provider set to be used first, the rest with room, the all but used up) and then by window, the smaller known first, an unknown one last. - Its strategy sets ByWindow, so weighRouted fills Seat.Window from windowIn (the provider's own Contexts, else the catalog's). - roomy already leaves out every member the request is estimated past, so the first left is the smallest that holds it: a small model is never asked for a request too long for it, and keeps its last-resort place as under every routing. - The trace's rows carry `context`; the Routing page says "its 200K context window is the smallest that holds this request". - A group's only: provider.normalize already drops it from a provider and the CLI refuses it there. GUI menu, hint, why-lines, TUI and CLI (`routing=fit`, small-first) carry it; docs/reference.md, the gateway-routing and plugin-runtime pages and the en/zh/ja start pages say it, with the search index rebuilt (via docs-index.mjs; #7065). Run first at the tree rebased on origin/main |
||
|
|
8564238065 |
remote magpie: a model is asked on the API the remote asks it on best (OoopsHh on X)
With another magpie as the provider, Pi's models.json had only codex/* on openai-responses; an OpenAI key's openai/* and a routing group's auto/* went on openai-completions, and effort max was turned away there while Responses takes it. Cause: the remote's /v1/models gives native_endpoints, every API the model goes on as it is, in its provider's speaking order (Chat first), and nothing for a routing group. Here Provider.Native took the first one the remote magpie provider speaks: Chat, for every model but a ChatGPT sign-in's (listed on /v1/responses alone). The remote's own choice (Native: ResponsesFirst or the Base URL's API; a group's GroupAPI) was lost on the wire. Now the remote's list (X-Magpie-Drawers) says magpie_prefers, the path it asks the model on best (provider.PreferredEndpoint). The local magpie keeps it as catalog.Model.Prefers and Native takes it first for a remote magpie (RemotePrefers), so every agent wired one API per model (Pi, omp, droid, dsh, grok, hermes, liveagent through catalog.Model.APIs) asks it there, and the gateway's usable translates another API's request to it once instead of to Chat. A user's own API set on the model still wins; a remote from before says nothing and stays as it was. Not changed: a Chat request a client sends itself for such a model is still relayed as Chat to the remote, which decides as it does for its own clients. Run (mote, at this tree): - TestRemoteMagpiePrefersResponses (gateway: two magpies on one gateway, a fake vendor that turns away reasoning_effort max on Chat) and TestPiAsksARemoteMagpiesModelWhereItPrefers (agent): green; both red with the RemotePrefers check in Native and usable turned off (openai/* and group/auto on chat, Pi's api nil, a Messages request relayed as Chat). - Two real magpie serve processes in sandbox HOMEs, a fake vendor, an OpenAI key there with its Base URL given as Responses, a group auto and the first magpie as the second's Remote magpie: Pi's models.json has office/openai/gpt-6.2-astra and office/group/auto on openai-responses with max, and /v1/responses effort max reaches the vendor's /v1/responses for both. The same script at the base commit wrote both with no api (the provider's openai-completions). - At base |
||
|
|
504db2206e |
kiro: the docs say what the Routing page shows, and the min names the ACTIVE, outlasting trial
The ported change said the Routing page shows "on credits · after the others"; nothing in the GUI renders Weighed.CreditsLast, so the docs now say the mark is read by affinity only. The plugin (0.1.41, review follow-up on plugins#1352) says credits only while an ACTIVE bonus has credits left that outlast the month's reset; the docs and the mover's note say so. |
||
|
|
5a83f0ae6c |
gateway: a plugin's account on its trial credits is asked after the accounts with plan credits left
A plugin window may say credits: used up, the account goes on past it on credits its vendor spends after the window's. Kiro spends a month's plan credits before a trial's, and the plan's are lost at the month's reset while a trial's last a year, so such an account goes after the provider's accounts with room and before those used up, under every routing but Pick account by hand.
Ported from StringKe's branch (StringKe/magpie kiro-trial-last, 23e084262;
yetone/magpie#7179, with plugins#1352, kiro 0.1.41). Kiro's billing docs
say "Kiro uses your plan credits first, then your trial credits" and that
trial credits last 12 months. Opt-in per plugin window (credits), so a key
or a Codex account routes as before: creditsLast and CodexCreditsFirst
stay Codex-only, behindOthers moves only plugin: accounts, and no other
plugin package sends credits. The Kiro mover's min goes to 0.1.41, on npm
(gitHead 0ae116db1).
Run at this stack's head on mote: go test -timeout 45m ./... with go vet
./...: every package ok but internal/gateway, red on
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (red 3 of 3 alone on
origin/main
|
||
|
|
9bf5848c1f |
gateway: a Kubernetes rolling update runs two pods on one volume safely
@justforlxz on X asked for a RollingUpdate (maxSurge 1, maxUnavailable 0) with no request dropped. The docs said strategy: Recreate, because the work only the serving magpie may do (renewing sign-ins, check-ins, moves, plugin updates, WhileServing) was kept to one magpie only by the gateway's port: a second couldn't bind it. Two pods each bind their own network namespace, so in an overlap both did it, and two renewals of one refresh token can spend it (a single-use token rotates). Design: both pods answer requests at once (each refresh and file write is already locked across processes: filelock, host.js lockRenew); the serving work is held to whichever gateway holds gateway.serving.lock (flock on the config folder, serving.go). The new pod retries every second and takes the work over as the old pod's gateway ends (its drain lets go first). A file system without locks is read as no other magpie, as before. Pods share the volume but not a pid namespace (both run magpie as pid 1), so the locks that judged a holder by its pid now judge it by host: - host.js lockRenew records host (hostname + pid namespace); a lock of another host is stale by age only, never by "pid 1 is alive here". - lockMoves (migrate.go) the same. - gateway.json records Host; forgetListening removes only its own, so the old pod's end no longer removes the new pod's file (same pid, same Started second was enough before). - temp and run-mark names get a random part (writeDurable, Claude run marks, gateway.json's temp file). While draining (SIGTERM), every reply says Connection: close, on the gateway and on magpie web's page port, so an agent that kept its connection to the old pod alive dials the Service again for its next request. Without it, the real rollout below had one broken pipe per kept-alive connection, ~5.8s after each SIGTERM, when the drain's end closed them. Docs (en/zh/ja docker, reference.md): RollingUpdate maxSurge 1 / maxUnavailable 0, the readiness probe, a required podAffinity on kubernetes.io/hostname (a ReadWriteOnce volume mounts on one node), and one Recreate update from a version before this one, whose old pod doesn't take the lock. Run: - Real overlap, podman 4.9.3 in WSL magpie-desktop: three pods (pa -> pb -> pc) on one volume, each its own container (pid 1, own hostname and network), a Service proxy over a readiness-probed endpoint list (1s probe, endpoint removed 1s after SIGTERM as kube-proxy does), 12 agents streaming 3s SSE turns through it, half keeping connections alive, no retries. Before Connection: close: 226 ok, 10 failed (broken pipe, kept-alive). After: 209 ok, 0 failed; second run 207 ok, 0 failed. Each new pod logged "another magpie serves", then "let go" as the old pod's gateway ended; gateway.json named the last pod. - Broken by hand, each red then green: TestServingWorkWaitsForTheOther- Magpie, TestServingWaitEndsWithItsGateway, TestForgetListeningKeeps- AnotherPods, TestMoveLockOfAnotherPod, TestRenewLockOfAnotherPodIs- WaitedFor, TestDrainingRepliesCloseTheirConnection, TestPagePortClosesWhileDraining. - Full suite, go test -count=1 -timeout 45m ./..., at 85305a82d (this change on |
||
|
|
72f7c1f41a |
agents: Nowledge Mem's own AI runs on magpie (xiaomaomiloulou on X)
Nowledge Mem asks for "选择一个 AI" on its first page and in Settings >
AI, and Mem 0.10 has a provider type of magpie's own. Picking a magpie
model for the new agent nowledge-mem now sets it up from magpie:
- Mem keeps its providers in remote_llm.json with each key encrypted, so
the file is only read. Changes go through its backend (nmem-server,
127.0.0.1:14242, $NMEM_API_URL when it names this computer), as its
Settings and `nmem config provider` do: POST /remote-llm/config saves
provider "magpie" at the gateway's /v1 with agentKey("nowledge-mem")
and the model, which makes it active and turns the AI on.
- Mem puts temperature, max_tokens and timeout back to its defaults
when a save leaves them out, so every save sends the provider's own.
- What Mem had is stashed once: the active provider, whether the AI was
on, and a "magpie" provider the user made, which keeps its key and
gets its model, base and parameters back. Stepping out activates the
provider Mem had (unless one was picked in Mem since), removes
magpie's provider and turns the AI off again if it was off.
- Mem has to run to change it (errMemDown); a sync moves the base only
when the gateway's port moved. Detected by its config folder or the
installed app (co.nowledge.mem.desktop). Icon from its icon.icns.
Run (mote):
- go test -count=1 -run 'NowledgeMem|TestEveryAgent|TestListOnly|TestSync|Desktop'
./internal/agent ./internal/library ./internal/agentenv ok; -run Icon
./internal/gui ok.
- GUI: icon-one-tone, icon-tile, routing-client-icons, i18n-keys in
Chromium and WebKit, 58 of 59; the red is icon-tile's dim-color, red
on origin/main since
|
||
|
|
681f2ee7f0 |
templates: a cheaper small model beside a near flagship is the cheap one (@qinzhidaoa on X)
The reporter's DeepSeek provider has deepseek-v4.1-flash and deepseek-v4-pro, and the Routing groups page greyed out "Hard to strong, easy to cheap" and "Cheap first" with "Needs a model cheap beside DeepSeek-V4-Pro". Both prices are known (models.dev's DeepSeek, as the bundled catalog has it: V4 Pro $1.98 out, V4.1 Flash $0.60 through its canonical id), so it was not a missing price. cheapest() took a model as cheap only at a quarter of the strongest's price or less, and Flash is 3.3 times less. Sonnet beside Haiku (3x) and Gemini Pro beside Flash (~3.4x) failed the same way. Now a model is cheap at a quarter of the price, or when it costs less and its id says small (flash, mini, haiku...) where the strongest's doesn't. A model that costs as much, or one cheaper with no small id at under a quarter, is still not taken. With no price on either side, the size words already decided, unchanged. Prices for the new ids do reach the templates: deepseek-v4.1-flash is priced 0.60 at its maker (maker=true) through models.dev's deepseek-flash canonical, logged by the new test. Run (mote): - TestTemplatesCheapBesideACloseFlagship reproduces with the reporter's ids (deepseek-v4.1-flash, deepseek-v4-pro on the DeepSeek preset) and models.dev's DeepSeek entries from the bundled catalog, written as the test's catalog (testdata/models-dev-deepseek-2026-11-10.json). On the old cheapest() it is red: smart and thrifty need "cheap" of "DeepSeek V4 Pro", members [], and Haiku beside Sonnet, Gemini Flash beside Pro, red the same. Green with the change; the other template tests pass. - gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok. - go test -tags nogui -timeout 45m ./... at 56b3f0780 (this change on |
||
|
|
344253c4e2 |
provider: Codex's Ultra on every GPT Sol, Astra and Terra by family, GPT-6.2 Sol and Astra too
forkhouhou on X: on a relay, gpt-6.2-sol and gpt-6.2-astra stopped at max in Codex while gpt-6-astra and gpt-6.1-terra had ultra. OffersUltra read a hand list (ultraModels), so each new model lacked Ultra until someone added it (#4909 did 6.1 Terra); 6.2 was never added. openai/codex's models-manager/models.json (6c0cee502, "Add GPT-6.2 Sol and Astra to model catalogs (#62106)") lists ultra on every Sol, Astra and Terra from GPT-5.6 to 6.2, and on no Luna, GPT-5.5 or older. So the rule is now the family: catalog.FamilyOf names gpt-sol, gpt-astra or gpt-terra with a version. It is asked of every spelling the catalog matches through a new catalog.IsOneLike (found/lookupIn moved onto a getter, their map forms unchanged), so a provider prefix, :official, [A], a dated suffix and gpt-6-1-sol keep working, and -fast, -pro and Luna stay out. Ultra still goes upstream as the entry's multi_agent_reasoning_effort or max (fitEffort), and turns Codex's V2 subagents proactive. It changes no sandbox or approval. Run: - Red on the old code (mote): OffersUltra false for gpt-6.2-sol, gpt-6.2-astra, relay/gpt-6.2-astra, gpt-6.2-sol-2026-11-17 and gpt-6.3-terra; copilot/gpt-6.2-astra's entry stopped at max with v2=false. Green after. - Sandbox HOME e2e (mote, -tags nogui, fake relay, never live configs): old code: relay/gpt-6.2-sol and -astra low..max, no v2, in /v1/models, /v1/codex/models, `magpie models` and ~/.codex/magpie-models.json. New: low..max,ultra with multi_agent_version v2 in all four; gpt-6.1-sol unchanged (ultra), gpt-6-luna unchanged (none). config.toml's enabled-reasoning-efforts has ultra. A POST with effort ultra reached the relay as reasoning_effort max. - GUI: `magpie web` on that sandbox HOME, read with Playwright Chromium: /api/state's Codex effort and subagent effort fields on relay/gpt-6.2-sol offer low..max,ultra. No GUI code changed. - Full suite, `go test -tags nogui -timeout 45m ./...` on mote at ad3a8b1d3 (this change on |
||
|
|
7f11dfc77f |
gateway: a Gemini CLI sign-in goes without Claude Code's billing line, so Gemini's cache reads its prefix
Reported on X by @niyezaimenglima: Claude Code on a Gemini model through magpie showed a cache hit rate of 0. Cause: Claude Code's first system line, x-anthropic-billing-header, carries a cch= that changes every turn (#1600). On a Gemini CLI sign-in (Code Assist, Account.Agent "gemini") magpie kept that line at the head of systemInstruction, so no two turns shared a prefix and Gemini's implicit cache never matched. dropsBillingLine now drops it there. forwardTranslated also built the Code Assist body from req instead of sent, so a dropped line went out anyway; it builds from sent now, as buildFor does. Scoped to that one route: - The built-in Antigravity account's cloak already removes the line, and its refusal check (#666) judges the system as written. Unchanged. - The antigravity, agy-cli and zed plugin cloaks cut the line to its end, and Claude Code's identity sentence (joined onto the same line) goes with it. Cutting only the fields in magpie, as a first version of this did, left "You are Claude Code..." on line 1, and a real Antigravity plugin account answered its 429 refusal (400 to Claude Code). Plugins keep the line. - Other vendors: unchanged (dropsBillingLine's non-Code-Assist branch is as before). Measured on a real Antigravity plugin account (sandbox HOME, copied credentials, antigravity/gemini-3.8-flash-low, three Claude Code-shaped turns, ~8.3k tokens): - old code: turn 1 cache_read 0, turns 2 and 3 read 6238/6278 (in ~2084). - a per-turn changing line near the head of the system (what Gemini CLI's kept billing line is): cache_read 0/0/0, in 8297/8331/8381. This is the reporter's 0. - new code on the plugin route, stream and non-stream: 6248/6242/6274, so the route is unchanged; usage.jsonl matches the response. - history in the first user message instead of the system: 6246/6288, so conversation content is cached too. The last ~2k tokens are never cached (Gemini's chunking). Tests (both red on the old billing_line.go): - TestBillingLineLeftOutForCodeAssist: a Gemini CLI login end to end, two turns with different cch; neither GenerateContent body has the line and systemInstruction is the same in both. - TestBillingLineCodeAssistOthers: Antigravity built-in and an Antigravity plugin keep the line; Gemini CLI drops it. Run: - Full suite, go test -timeout 45m ./..., on mote at 72e6f9542 (this change on |
||
|
|
2926b7beff |
usage, routing: the model id a request went out under is kept and shown
daoche_wuzui on X asked how magpie serves Antigravity and whether a
request goes out under a suffixed model: nothing showed the id actually
sent. Antigravity's plugin turns gemini-3.7-flash at high effort into
gemini-3.7-flash-high, and a relay's upstream name (ModelWires) renames
a model too; the ledger and Routing showed only the routed model.
- A plugin's reply may carry X-Magpie-Sent-Model
(provider.SentModelHeader). forward() reads it from plugin providers
only (a non-plugin's header is ignored) and deletes it, so it never
reaches the agent. Without it, provider.SentNameOnIn (the upstream
name, or Antigravity's variant) is used.
- wireName keeps the id only when it differs from the model. It goes in
usage.Record.Wire (`wire`, omitempty), the trace's Try.Wire, the
ledger cache and a last CSV column, sent_model (docs/reference.md).
- Usage › Requests: the Sent cell and the detail show the sent id when
there is one, with "model → sent id" on hover. Routing: a try sent
under another id gets one aside line, "Sent to the vendor as {model}"
(zh, zh-TW, ja, de).
- Antigravity's mover min is 0.2.4: plugins 67fb1258 sets the header on
every reply (stream, whole and errors); its tgz is on the plugins
repo's dist branch.
Run at this head (
|
||
|
|
ddc78405cf |
gateway: a magpie's /v1/models offers Ultrafast where its accounts do
OoopsHh on X: a magpie in Docker could pick Ultrafast on a model, but another magpie that has it as its Remote magpie provider was offered Fast alone on that model. The remote's list takes its service tiers from provider.CodexTiers through codexcat.Entries, and CodexTiers only ever added "priority". Ultrafast came only from Codex's own catalog, which a magpie with no Codex beside it (Docker) does not have, and the codexcat branches for Fast and OwnTier models dropped any tier m.Tiers added. - CodexTiersWith adds "ultrafast" after Fast where provider.UltraOn says the key or account offers it (an OpenAI key's Ultrafast models, a provider added by its address on OpenAI's Ultrafast models, a Codex account whose live list has it), and on a group where a member does. UltraModels is read at most once a list, and only after a model already shows Fast. - codexcat keeps those tiers (withTiers) and names "ultrafast" "Ultrafast" when Codex's own catalog doesn't. - The asking side already sends ultrafast to a Remote magpie (RemoteTiers), and the remote already asks a member without it for priority (tierMate). Both ends need this version: the remote to list it, the local one to read it. A provider added by its address serving gpt-6.1-sol now lists Ultrafast in /v1/models, /v1/codex/models and magpie-models.json, as its editor's CanUltra already said; TestModelsListTiersForEveryClient, TestRemoteMagpieOffersItsTiers and TestCodexCatalogTiersReachDisk expect it. Tests: - TestRemoteMagpieOffersUltrafast: a relay's gpt-6.2-sol and a group of it list "priority ultrafast"; a Remote magpie provider reading that list has CanUltra on both, and an ultrafast ask through it reaches the vendor as ultrafast. Red on |
||
|
|
c1934262ab |
routing: a group member sent Ultrafast says Ultrafast, not fast
OoopsHh on X: with Ultrafast picked on a routing group's member, the group list's card still said "· fast". The Routing page's summaries (the card's member line, the member menus' notes and the route view's tag) read Group.Fast alone. They now say Ultrafast where the group sends the member so and an account offers it (memberJSON.Ultra), as the editor's speed button and `magpie group` already did. The TUI's group view did the same and now says Ultrafast too. The route trace's Weighed gains Ultra so the route view's tag can tell the two apart (#7095). Fixes #6881 and #7095 (paul-tian). ggbdpq took #6881 and posted a patch on it; its TUI test and the Codex GPT-6-Astra fixture are ported here with credit. Siblings checked: `magpie group` (groups_cli.go) and the Agents page (agentspeed.js) and search tags (fastTag) already said Ultrafast; the tray has no group speed summary. Tests: - group-member-fast.test.cjs: a group "Astra" with an Ultrafast member; its card says "gpt-6.2-sol · Ultrafast" / "· 极速" (en, zh; Chromium, WebKit). Red on |
||
|
|
ef997d186c |
serve: a SIGTERM finishes the requests in flight, for Kubernetes rolling updates
@justforlxz on X runs magpie in Kubernetes and every update cut the
requests in flight. A SIGTERM ended the gateway like Ctrl+C: the
listener closed at once and Shutdown cut what was left after 2s, an
agent's stream included, with no unready phase for the Service to see.
Now a SIGTERM to `magpie serve`, `magpie web` or `serve --web`:
- GET / answers 503 {"draining":true} at once, so `magpie healthcheck`
(the image's HEALTHCHECK, and the readiness probe the docs give) fails
and the pod leaves its Service's endpoints;
- in a pod (KUBERNETES_SERVICE_HOST) it keeps accepting for 5s while
that reaches kube-proxy and the ingress, then stops accepting;
- the requests in flight, streams included, get up to MAGPIE_DRAIN to
finish: unset, 20s in a pod (k8s' default grace is 30s, with room to
save after) and 7s elsewhere (docker stop and Compose kill at 10s,
and a drain past that would lose the state saved at the end);
seconds or a Go duration; 0 ends after 2s as before; an unreadable
value logs and uses the default. magpie web's page port (which
serves /v1 too) shuts down within the same grace.
Ctrl+C and SIGHUP end as before. Nothing to configure.
A request still answering at the end of any drain was logged as "cut"
but kept running, its upstream call too, until the process exited:
Shutdown doesn't close active connections. The gateway now closes them
after a failed Shutdown, so a gateway restarted in-process (the GUI's
restart, a test) leaves nothing holding the provider catalog
(holdCatalog). TestDrainEndsAtItsGrace's cut request, still in flight
after it returned, made the next test, TestGrokGetsAgentMessageAsUser,
read migrations.json through that hold and fail in a full gateway run
on WSL; the test now waits for it to end, and without the Close that
wait fails at 30s.
PID 1: the image's ENTRYPOINT is exec form, so magpie is PID 1 and gets
the SIGTERM itself (it calls signal.Notify). As PID 1 it exits 2 rather
than 143 after the drain, the same on the old code.
/config shared by two pods (a RollingUpdate overlap) is not verified
safe: files are flock'd and written by rename, but the serving magpie's
sign-in renewal, plugin sign-in renewal and check-ins would run in both.
The docs say one pod per volume with strategy: Recreate (an RWO volume
on another node also stalls a RollingUpdate). Requests sent between the
old pod's end and the new one's start are refused; the drain covers what
was in flight.
Docs: a Kubernetes section (Deployment with an exec readiness probe,
terminationGracePeriodSeconds, Recreate, the RWO note) and a
MAGPIE_DRAIN row on docker.html in en, zh and ja; docs/reference.md's
Docker section; site index regenerated.
Run:
- TestDrainedGatewayFinishesItsStream, TestDrainEndsAtItsGrace,
TestHandedOverGatewayFinishesItsStream, TestReadOnlyKeyEveryRoute,
TestDrainGrace, TestDrainOnSignal and the cli Signal tests: ok (mica).
- Broken by hand: without Drain's grace in drainFor,
TestDrainedGatewayFinishesItsStream fails "the gateway ended with a
stream in flight".
- Real binary (before the 7s default, which applies outside a pod
only, and the Close), sandbox HOME, fake SSE upstream streaming 10s, SIGTERM
at +2s, KUBERNETES_SERVICE_HOST set, magpie as PID 1 in its own pid
namespace (unshare) on Linux (WSL magpie-desktop), serve and web:
new: healthcheck fails while draining, a new request 1s after SIGTERM
200, the stream completes at +10s, exit at +11s. origin/main: the new
request is refused, the stream is cut at +4s after 4 chunks. Also
serve on macOS (mica): same, exit status 143.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., go build: ok (mica), before the 7s default
and the Close.
- Full suite, go test -count=1 -timeout 45m ./..., on Linux (WSL
magpie-desktop; mote and mica were each running another session's
suite) at the first version of this change on
|
||
|
|
1c9c359f9d |
gui: Usage cards keep their place as they come in (liuzhengdong99 on X)
liuzhengdong99 on X: 用量界面每张卡片取数的时间不一致,导致卡片渲染时高度一直 跳动——滑到上面看某张卡片,视图会被拽回下面. The allowance cards come in at different times: each vendor's read (the page asks again every 1.5s while X-Magpie-Reading says a read is under way), then the curves' history. Every answer redraws the cards (renderQuotas), and packUsage grows the ones above the card being read. Nothing kept that card in place: the view's scroll guard (keepInView) only knew elements by node, and the cards are new nodes on each draw, so the browser's anchoring was the only thing holding them. It anchored on nodes that were being replaced, and the reader ended up dragged down. Fix: - The Overview keeps the card being read in place: the highest card (or part of the page under the cards) that starts in sight, found again by its data-key after a redraw (keepInView's new `only` mode with pinnedAt), and followed after every packUsage (followPin). The browser's own anchoring stays on while nothing is kept: at the page's top, on another tab, and while the cards are dragged or moved by keys (unpin, so a dropped card lands where its slot showed). - Placeholders from the last known height: each card's height drawn in full is kept by its key (localStorage magpie.usageCardTall, 1s debounce, 200 keys at most). A card still waiting on its read or its curve (usageWaiting: quotasReading, the new flag loadQuotas sets, or no history answer yet) is packed and held at least that tall, in the column count the cards were last whole in at that width. On the next start, no card in sight moves. - loadQuotaHist counts its first answer even when it is empty, so a user with no history isn't left waiting (found by usage-pack: the cards held their first packing at 560px). No new animation, nothing scrolls the page on its own (click-scroll passes), and the layout is unchanged once the cards are in. Run (mica, Playwright 1.62.0, Chromium + WebKit): - usage-cards-steady.test.cjs (new): 20 tests, all 5 languages, 1100px and 420px. On the old assets (MAGPIE_ASSETS) it was red 8 of 8 in en and ja. With the hold disabled, the second visit goes red. - At |
||
|
|
426a707a19 |
library: each subagent is kept in a Markdown file to edit, or one of the user's own in a git repo (JonahFu on X)
JonahFu asked on X (tweet 2123236872940073039) for each subagent's local path in Library > Subagents, to edit it with an LLM, or to keep a subagent in a git repository. Each subagent of the library (not a plugin's) is now kept on this computer in <library>/subagents/<name>.md as well, in Claude Code's shape (name, description, model, skills, mcpServers, the prompt), or in a file of the user's own set under the editor's Advanced (folded unless one is set), in a repository say: - FileHash is what the file said when magpie last wrote or took it in. An edit there (by hand, by an agent, a git pull) is taken in at the next sync and before a change made on the page, and every ticked agent gets it. While magpie runs, KeepLinked's loop syncs when a file's hash differs, once per edit. - An edit that can't be read as a subagent (no front matter, another name, no prompt) is left as it is, the agents keep what it said before, and the editor says why. magpie writes a file only when it is missing, or still as magpie left it; never the user's edit. - A file of the user's own that is there already is what the subagent says (a bad one refuses the save). It must be an absolute .md path, not a folder, not inside the library, not one another subagent uses, and not a file magpie writes for an agent. - Rename and remove take the library's own file only while it is as magpie wrote it; the user's own file always stays. - File and FileHash are this computer's: Collect leaves them out, Put keeps this computer's. The editor shows the path (click reveals it, Copy copies it), a line that edits there reach the agents, and the error when one wasn't taken in. i18n in zh, zh-TW, ja and de. docs/subsystems/library.md: a row for the subagent's own file and its tests. Run at the tree before |
||
|
|
3132fa1cd9 |
library: Rules, a folder of rules given to Claude Code, Cline and Kiro CLI (JonahFu on X)
JonahFu asked on X (tweet 2123237371739316685) for Claude's rules folder in the Library. A new Rules tab keeps rules once and gives each to the agents ticked for it, in the folder each reads by itself: - Claude Code: <claude dir>/rules/<name>.md. `paths` is the only front matter key it reads (code.claude.com/docs/en/memory). Checked on real 2.1.327 in a sandbox: it reads every .md under the folder, loads one without paths at launch, and one with paths when Read/Write/Edit touches a matching file. - Cline: <cline dir>/rules (CLINE_DIR, else ~/.cline). Cline 3.0.70 reads every rule always and has no paths key, so a rule with paths isn't written for it; the agent gets a problem and the editor says why under the paths. - Kiro CLI: ~/.kiro/steering, `inclusion: fileMatch` + `fileMatchPattern` for paths, else always. A rule named "agents" is refused there (it would be AGENTS.md on a disk that ignores case). - Not listed: Cursor (user rules live in its settings; .cursor/rules is per project), Codex (its rules are execpolicy), Droid (command permissions), Gemini CLI, Qwen Code and OpenCode (no rules folder). A body starting with --- gets an empty front matter first. Files are recorded with their hash in Applied.Rules through the same syncOwnFiles as subagents and slash commands: a file of the user's own by that name, or one magpie wrote that the user edited, is never written over or taken away. Bundles (backup, WebDAV) carry rules; a bundle from an older magpie leaves this computer's alone. The editor lists each agent's file to reveal. No CLI yet. docs/subsystems/library.md: a Rules row and its tests. Run (mica-run, at this tree): - go vet -tags nogui ./internal/library ./internal/gui ./internal/davsync ./internal/cli: ok. gofmt -l: none. - go test -tags nogui -timeout 45m ./internal/library ./internal/davsync: ok (TestRulesEachAgentsFile, TestRulesKeptToTheirPaths, TestRulesLeaveTheUsersFiles, TestRuleCheck, TestRulesCarried). - node --test library-rules, library-subagents, library-commands, library-hooks, library-loading, library-groups, i18n-keys, i18n-en-no-cjk (Chromium and WebKit, 420 and 1100 wide, en zh zh-TW ja de): 78 of 78. - The full suite and cross-OS vet ran at the next commit, which this one is under. - Real use: Claude Code 2.1.327 in a sandbox HOME loaded a rule without paths at launch and one with paths only on touching a match; a sandbox magpie on mica wrote ~/.claude/rules/go-style.md with paths: ["**/*.go"]. Not tried: Cline and Kiro CLI loading the files for real, project-level rules (.claude/rules in a repository), Copilot and CodeBuddy (not verified, not listed), Windows and Linux. |
||
|
|
3869aee3b0 |
sessions: agy's calls in T3 Code are on Usage → Requests
zzzkl on X: requests from Antigravity in T3 Code weren't on Usage → Requests, while a plain agy's were. T3 Code (pingdotgg/t3code, read at 00c6adbd) runs agy for each Antigravity instance as an ACP server on the instance's own Google sign-in: `agy acp --gemini-dir <profile> --app-data-dir antigravity-acp` (antigravityAuthSupport.ts), the profile being <T3 Code's folder>/userdata/providers/antigravity/<sha256 of the instance id>, the folder $T3CODE_HOME or ~/.t3 (dev for its dev server). Those requests go to Google, never through the gateway, and magpie's agy reader looked only in ~/.gemini/antigravity-cli, so nothing counted them. agy writes the same transcript_full.jsonl there as in its own folder (agy 1.5.10 run that way in a sandbox against a fake Gemini endpoint; the fixture is its bytes). agyCallFiles now reads every T3 Code profile's antigravity-acp too, and Found lists agy for those folders, so the read consent covers them. T3 Code's folder is appdir.T3Code, shared with agent's t3Base. Siblings: `agy acp` from any other ACP client with the defaults writes to antigravity-cli, already read (agy acp --help). T3 Code's magpie instances (Claude, Codex) go through the gateway and are counted there. Run: TestAgyCallsInT3Code (default folder, T3CODE_HOME, ~/ form) red on the old calls_agy.go/access.go with 0 calls, and with Found() = [claude codex] when only access.go is old; green with the change. gofmt -l clean; go vet (darwin, GOOS=linux, GOOS=windows) of appdir, agent and sessions on mote. Full suite (go test -timeout 45m ./..., mica, at |
||
|
|
9768b384e4 |
router: find_tools finds tools for a query in Chinese, and names every tool when none matches (Passings_z on X)
Passings_z asked on X (tweet 2123227759409586219) why, with the MCP router's tools on demand, some tools never get used. An agent given find_tools and call_tool that asks in Chinese found none of the tools there were: - hubWords split only at characters that aren't letters or digits, so 帮我截个图 was one word, and hubWordIn looked for it whole in the description, which an English one never has. - hubMatch.clears needs two thirds of the query's key words, so 截图 screenshot failed on a tool named screenshot too: 截图 counted against it. - With nothing matched, the reply named 8 tools a server, so a model had no way to the rest. Now: - hubWords also cuts where a spaceless script (Han, kana, Hangul) meets another (截图screenshot is 截图 and screenshot). A spaceless word is cut at characters that say nothing of a tool (hubStopRunes: 我 帮 个 を …), each piece a key word (帮我截个图 is 截 and 图), found in a text when it is one character there or at least half of its two-character runs are (hubPhraseIn). - Key words are matched against the tool's router name, its server's own name (a server named in Chinese) and its description. - A key word with letters not in ASCII counts only for a tool whose name, server or description has such letters, so 截图 screenshot is screenshot to an English tool. An English query matches what it did. - No match names every tool of each server when that fits in hubSayMax (2000 characters), else 8 a server and that find_tools with an empty query names every tool. A query not in ASCII when no tool has such letters is told the tools are named and described in English. Siblings: hubNear (call_tool's close names) shares hubKeyWords and hubMatchOf, so it takes the same words. The GUI's searches are substring filters (includes), not this tokenizer; nothing to change. find_tools' and call_tool's descriptions and the instructions, the text that goes to the vendor, are unchanged. docs/subsystems/mcp-router.md: Tools on demand says the new matching and the no-match reply. Tests (internal/gateway/hub_find_cjk_test.go): - TestHubFindInChinese: 截图 screenshot, 截图screenshot, 帮我截个图, 截取屏幕, 发消息到群聊, 截屏 (a server named 截屏工具) find their tool first, and not each other's. - TestHubFindNotFoundNamesEveryTool: all 12 of a server named, the English hint, and past the budget the empty-query hint. - TestHubFindEnglishAsBefore: 30 English queries match exactly what they matched at |
||
|
|
7d5db0f29a |
cli: a command that ends ends its plugin hosts, and one that doesn't serve starts none (#7146)
athemeroy (WangYeruo on X) runs `magpie serve` as a LaunchAgent with the
magpie-google-ai-studio browser plugin and 11 accounts. Each
`magpie --version`, `version`, `licenses` or `group <id>` run beside it
left a second magpie-bun host with PPID 1, holding the Chrome profiles
the gateway's host wanted ("Chrome exited before starting WebView").
Their analysis was right on each count:
- plugin.Cached starts a background list of the plugins' providers
whenever this process hasn't listed them (provGood is in memory), so
every short command reaching provider.Catalog (startUp's RenameLegacy,
groups, models, ...) started a host.
- Main ended through os.Exit and never stopped it. A host whose stdin
closes leaves only once nothing is pending, and a plugin holding a
browser keeps Bun up meanwhile, so the host outlived magpie, adopted
by init. SIGTERM (launchd stopping serve) orphaned serve's own host
the same way.
- --version and licenses were answered after startUp.
Now:
- Cached asks the plugins in the background only when
plugin.ListInBackground is on; run sets it from servesPages (app,
web, serve, TUI). Other commands read the list on disk.
- Main ends through exit(), which runs plugin.EndHosts first, on
success and error; die does too on SIGINT/SIGTERM/SIGHUP, bounded by
hostsOnSignal (20s, past the 15s a renewing host gets).
- provider test returns exitError instead of os.Exit(1).
- -v/--version/version and licenses answer before any start-up work.
Audit of the os.Exit calls in internal/cli: data_cli.go:135 and the
CheckEnv exit in Main run before anything can start a host;
claudeLetGo already called EndHosts.
Tests (red on the old code, the non-test sources reverted to
|
||
|
|
a18ed4995f |
memory: a memory of several lines keeps them, folded to its first line (_meouwu on X)
_meouwu on X: a memory added by hand in several lines showed as one line with its breaks gone; it should keep its format and, folded, show the first line and an ellipsis. Cause: the store never lost the breaks. A memory file's body is m.Text as written (encode/apply trim only the ends). They were lost where it was shown: the Library row clamped the name to two lines with white-space normal, the digest given to agents went through oneLine (strings.Fields), and so did memory_search / memory_list in the memory MCP. Now: - Library: a folded row and a suggestion show firstLine(text) (first line, " …" when more follow); an open row shows the whole text pre-wrap. The editor already kept "\n". - Digest and memory MCP: memory.Indented keeps each line, the lines after the first indented two spaces so the memory stays one list item. - Dream and distill listings stay one line on purpose: the model's reply is read line by line, and a user's memory is Fixed, never rewritten by them. Written in docs/subsystems/memory.md. Memories saved before: their files already hold the breaks, so after updating they show, edit and reach agents in their own lines. Nothing to redo, no migration. Run at 3fabaf8f2 (on origin/main |
||
|
|
b332ef7efe |
memory: a project's own instruction files win over memory, and its rules go there (flying_crp on X)
flying_crp on X: with memory on, the digest in the agent's instructions
disagreed with the project's own rules, and things that belong in the
project were saved to memory instead, while the user keeps the
project's docs tidy themselves.
- The digest's header (internal/memory/digest.go) now puts the
project's own instruction files (AGENTS.md and the like) and docs
first: where a memory disagrees, the agent follows the files and
says which memory is out of date. A project's rule or fact belongs in
its files; memory keeps what holds for the user across projects.
- memory_save's description says the same, and a new save made in a
project whose root holds AGENTS.md, CLAUDE.md, GEMINI.md,
.github/copilot-instructions.md or .cursorrules ends with a note
naming the files found: for a memory of the caller's project (any
kind but profile and preference), to offer to write it there and
forget the memory once it is; for a global rule or procedure, the
same when it holds only in this project (projectFilesNote). The save
itself is kept.
- Distillation's instructions leave a project's rules and conventions
to its files, and drop what disagrees with them.
- The texts name neither magpie nor a vendor (checked in each test).
The only filenames named are AGENTS.md "and the like" in the fixed
text, and in the save note the files actually found on disk.
- docs/subsystems/memory.md says all three.
Tests, each red on the old code (the three source files put back to
origin/main by hand, tests kept), green with the change:
TestDigestDefersToTheProjectsFiles (internal/memory), TestWhatIsSent
(internal/memdistill), TestMemorySavePointsProjectRulesToItsFiles
(internal/gateway, -tags nogui).
Real agents, sandbox HOME and CLAUDE_CONFIG_DIR, model through the live
gateway as an endpoint only, nothing live written:
- Digest: a git project whose CLAUDE.md/AGENTS.md say "Python code here
is indented with tabs", and a digest in the sandbox CLAUDE.md with a
project memory "Indent Python code with 4 spaces". Asked to write
add.py, with the old header Claude Code (haiku and sonnet) both used 4
spaces, following memory; with the new header both used a tab and
said the memory was out of date.
- Save: a sandbox `magpie serve` built from this tree on 127.0.0.1:3471,
Claude Code (sonnet) with its memory server over --mcp-config, asked
to "remember for this project: tests always run with pytest -x". The
save came back with the note naming AGENTS.md, CLAUDE.md, and the agent
offered to add the rule to them and then delete the memory.
Full suite (`go test -timeout 45m ./...`, mica):
- at a9696f14d: mica's disk filled during the run; reds in 17 packages
were "no space left on device". Not counted.
- at 8647ac995 (origin/main + this): 101 ok, 3 red, each filed and not
in code this change touches: internal/dirent watch tests (#7031),
internal/gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes
(#7117), internal/gui TestGatewayModeListsNoOwnSessions (#7064).
- at d67beb049 (this commit's tree, on origin/main
|
||
|
|
06428541ac |
agent: Dim's Magpie provider names each model with its provider, so two vendors' DeepSeek are told apart (T_t__biu on X)
T_t__biu on X: in Dim alpha, models of its built-in Magpie provider
can't be told apart by the magpie provider behind them; two vendors'
DeepSeek read the same.
Cause: Dim names a listed model by the display_name (or displayName,
name) of the endpoint's /v1/models (crates/dim-app-server
provider/remote.rs), shown in its Models page, `dima models` and the
picker's search. magpie's /v1/models gives display_name the name alone
(PlainName) to every client but Cindy and Claude Code's discovery.
- /v1/models asked with Dim's key gives display_name the name the
agents' lists give the model (provider.LabelsFor("dim"): its
provider's after it, as the Provider in model names setting says),
as Cindy's already is.
- Dim takes names only when it lists the models again
(provider.refresh). dim.json now keeps dimListed (a hash of the ids
and names) of the last listing, and Sync, while Dim's daemon runs,
lists the provider again when it changed: a provider renamed or
added, the setting changed, and a Dim connected by v0.1.4497, which
kept none, on its first Sync.
- A name the user gave a model in Dim (provider.models.edit) is a
descriptor override, which Dim's refresh keeps. No other provider of
Dim's is touched; disconnect is as before.
Run at this commit's tree (rebased on origin/main
|
||
|
|
4e24994a6e |
gateway: a key let use Magpie Memory reaches it from another computer
Niapyaya on X reaches their own MCP servers through the MCP hub from a remote machine, but not magpie-memory: memory answered the agents on this computer alone, on /mcp/magpie/memory ( |
||
|
|
d01e0a465a |
agent: Dim's built-in Magpie provider is filled in, so a plain dima runs on magpie (T_t__biu on X)
T_t__biu on X: Dim alpha has a provider named Magpie built in, and magpie's one-click connect left it empty, relying on DIM_* variables a shell function set for each run. Dim launched any other way (its app, a terminal opened before, an IDE) was not on magpie. Dim keeps providers in a database only its daemon writes, so magpie now talks to the daemon the way Dim's own clients do (JSON-RPC 2.0 after a hello of protocol 4, on <home>/rust/daemon.sock, or on Windows through Dim's pipe bridge `dimcode-server app-server --connect-pipe`; read from Dim's crates/dim-app-server and dim-client source). Picking a magpie model: - writes the gateway's /v1 (the port magpie is on), magpie's key and enabled onto the `magpie` provider only, each against the record's version (provider.update); - refreshes it, gives a model its token limits when the gateway doesn't know them (provider.models.edit), and makes it Dim's pick (provider.select against the pick's version); - records first, in magpie's own dim.json (temp+rename), what was there and the pick to give back. A key or address the user set on that entry themselves is kept: magpie writes nothing to the provider and only picks the model. Sync writes the port and key again when they change. Disconnect (`magpie dim default` or the switch) turns the entry off with the key cleared (Dim clears a key only on a provider turned off), puts the address back, and puts back the model Dim was on. No other provider is read or written. The per-run env and shell function stay only as the fallback when Dim's daemon can't be reached or started. Run at this commit's tree (on origin/main |
||
|
|
de58a3879b |
sessions: a cold read packs idle Claude sessions' calls into one file
shangyuan0818 on X: on Windows, Usage -> Sessions took 18 to 25 s with long Claude Code sessions. The cause: a cold read wrote a calls-v15 .gob shard and a .rev for every Claude session, about 21k files for 12k sessions, and Windows Defender scans each file as it is closed. Sessions not changed within the hour are now written into one calls-v15/*.pack per pass (MPCALLS1 magic, the frames, a gob index of path/offset/count, length, CRC32, magic). It is written to a temp file and renamed, and flushed at the end of a pass, at checkpoints, in Saved and every 32 MB. A session's own shard is read before the pack, so a session that grows gets its own shard and its lines are appended there as before. A bad pack means the source is read again. The hourly prune sweeps packs no session points at. Working sessions keep a shard and a .rev as before. Measured on xiaomi-gpu (Windows 11, Defender on), fixture of 12,016 Claude session files, no magpie cache, first /api/sessions reply, the runs alternating old and new: origin/main build: 31.67 s, 25.26 s, 20.74 s this change: 5.92 s, 5.85 s, 5.65 s restart with the pack written: 1.97 s and 2.16 s; then 0.25 to 0.31 s. The cache held 1 .pack and 4 .gob. Tests (call_pack_test.go): TestColdSessionsReadWritesOnePack, TestPackedCallsServeRequests, TestPackedSessionGrows. With the pack branch turned off by hand the first fails (.gob:63 .rev:62) and the second finds 0 packs. Run at 4ace48feb (this change on origin/main |
||
|
|
fcbc1a2d02 |
gateway: Claude Code's deferred tools are declared in full where a load would lose the cache
Seapawn1 on X: GPT in Claude Code loses its prompt cache with tool search on. A tool ToolSearch loads joined the top-level tools on the next request on every route but Anthropic's and a Responses upstream that loads in place (LoadedInPlace, #2660). An OpenAI-style cache is a prefix with the tools before the messages, so each load (2.1.327 defers WebFetch, WebSearch, Monitor and the other built-ins too) read the whole conversation again uncached. A sandboxed Claude Code 2.1.327 through a fake upstream showed it: on Chat and on a Responses relay the tools changed at req1 and req3; in place they held. On such a route a Claude Code request carrying DeferredToolPlaceholder is answered 400 invalid_request_error naming tools.defer_loading, locally. The real Claude Code 2.1.327 answers that (after its beta-strip retries, 3 refused requests) by declaring every tool in full for the rest of that conversation, --continue included; a new conversation, on a Claude model, tries tool search again. The message doesn't name the beta header, which Claude Code would remember everywhere. Only while the reminder names 50 deferred tools or fewer: an MCP router's hundreds keep tool search, and a request whose reminder can't be read keeps it too. Anthropic routes and in-place Responses upstreams are unchanged. The refusal is not a member's fault (retryable/shapeRefused false), so a group doesn't fall over or rest. Not handled: a user who set ENABLE_TOOL_SEARCH themselves can't be told apart on the wire; additional-tools=on keeps search on a relay that takes the item. Run: - mica: go test -run 'TestDeferred|TestLoadedTools|TestKimiIsSent|TestToolSearch|TestDeferredToolBlocks' ./internal/gateway ok. - Broken by hand (the check in translate made false): TestDeferredToolsTurnedAwayWhereTheyLoseTheCache and TestDeferredToolsKeptWhereLoadedInPlace red (status 200, upstream called). - mica: GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/agent ok; gofmt -l clean. - wsl-run (magpie-desktop): go test -timeout 45m ./internal/gateway ./internal/agent started before push; result with the full suite. - Real Claude Code 2.1.327 in a sandbox HOME against a fake 400 naming defer_loading: retried with every tool declared, kept for the conversation and --continue, new conversation searched again. Full suite: run after push. |
||
|
|
91e8146727 |
gateway: words written after a call go before it, so DeepSeek takes the call as answered
wizcheu on X (Claude Code 2.1.327, deepseek-flash at max effort on DeepSeek's own API) still saw "400 due to tool use concurrency issues" after v0.1.4478: "DeepSeek: messages.422.2: `tool_use` ids were found without `tool_result` blocks immediately after: call_00_wIys8uRO8314ixexw3r35173", and earlier messages.71.2. The block index is the clue. Checked against api.deepseek.com/anthropic today: an assistant message with a text block after a tool_use is refused with messages.N.K, K the text block, even when the next message answers the call ([T, tu, X] -> messages.1.2; [X, tu, T, X] -> messages.1.3; [tu, X, tu] -> .2; an empty text after the call too), while [T, tu, T, tu] and [T, X, tu] pass. A system message between a call and its result ( |
||
|
|
2ab2f69132 |
agent: Codex's status line shows the account's quota or the relay's balance (opt-in)
lyj1115 on X asked for the current account's quota, or the relay key's
balance, under Codex's chat box, off by default. Codex's TUI draws its
footer from a status line provider from 0.171.0-alpha.12 on: a stdio
MCP server whose tool advertises a statusline entrypoint, picked in
[tui] status_line_provider behind [features] tui_extensions_statusline.
Codex reads it about once a second with the thread's id. Nothing is put
into the prompt or the model's reply.
- `magpie statusline --codex` is that server. Each read asks the local
gateway for the thread's latest route and the kept quotas (no vendor
read). It answers `→ provider/model` and that provider's account that
answered last, with its windows or a key's balance. A gateway that is
down gives a null tree, never an error, because an error stops Codex's
reads. The tool's name and words name neither magpie nor a vendor,
since the tool is listed to the model.
- A status line square on Codex's row (`magpie codex statusline on`)
writes the flag, [mcp_servers.quota_line] (this magpie by full path,
args statusline --codex, env_vars = ["MAGPIE_ADDR"]) and the
provider. Every write is read back, and the file is restored on a
mismatch. Off and Disconnect take out only magpie's keys, and the flag
only when the stash says magpie wrote it.
- Nothing of the user's is written over. A provider of their own, a
quota_line of theirs, the flag turned off or an unreadable file keeps
the square away and refuses on.
- The switch is offered only when a Codex CLI here is 0.171.0-alpha.12
or newer (0.170.0 reads the keys and draws nothing), and only on this
computer, not in a WSL distro.
- In the GUI, the status line square's title takes the note of its
field's on option, which Claude Code's field already sent with the
same words TOGGLES kept, so Codex's says its own words in en, zh,
zh-TW, ja and de. TOGGLES' copy of Claude's note went, and app.js
stays under its budget (30 bytes of room) without a raise.
The Codex desktop app has no such footer. cockpit-tools reaches it
through a debug port, and magpie doesn't.
Run (WSL magpie-desktop, since mote's load was over 18):
- go vet -tags nogui ./...; GOOS=windows go vet of agent, cli, provider
and gui; gofmt -l clean.
- go test -tags nogui of ./internal/cli and ./internal/provider: ok.
- ./internal/agent -run "CodexStatus|Statusline|StatusLine|TestCodex|
TestWSLCodex": ok.
- ./internal/gui -run "CoreScript|Budget|I18n|Keys" and node --test of
codex-statusline, claude-statusline and i18n-keys (both engines, every
language, window and panel), with vet (and GOOS=linux and windows
vet) of agent, cli, provider and gui, on mote at the rebased head
(on
|
||
|
|
f6a538ece9 |
images: a resolution tier, 1K, 2K or 4K, in Settings and the image MCP (skingstyle48487 on X)
Asking the image MCP for 4K through a relay came back at 2K: nothing told the model how large to draw. Settings › Models › Images now has Image resolution (Automatic, 1K, 2K, 4K; an app menu, saved as imageResolution), and generate_image takes a resolution argument. The agent's own resolution or WIDTHxHEIGHT size wins over the setting. The images API takes `resolution` (or a tier given as size, "4K"), and each vendor gets it in its own field: - Gemini: imageConfig.imageSize (3.x image models; 2.x draws at 1K); - chat image models (Gemini's): image_config.image_size; - OpenRouter /images: resolution; - Grok Imagine: resolution 1k or 2k (its largest); - Seedream (Ark): the size tier the model has, or its pixels for a ratio; - MiniMax H3: area; - GPT Image 2 and other WxH images APIs: pixels at the ratio, within GPT Image 2's limits (edge 3840, 655,360 to 8,294,400 pixels, /16); - gpt-image-1, DALL·E and SenseNova keep their own sizes. A vendor that answers 400 or 422 to a tier is asked once more without it. An unknown resolution is a 400. Both MCPs now say what size each image came back at, and when that is under the tier asked. The row is drawn by videogen.js, after Video generation's, so app.js keeps its budget (it was at 1,088,641 to the byte); the server keeps imageResolution when a save doesn't send it (TestSettingsImageResolution), so prefsKeep doesn't carry it. The menu has no notes: "The model's own" was a plugin's key already. Run (magpie-desktop WSL on xiaomi-gpu; mote was over load 18 all day): - gofmt -l: clean; go vet -tags nogui ./... and GOOS=windows go vet ./...: ok. - go test ./internal/gateway -count=1 (1995s), ./internal/imagemcp, ./internal/settings, ./internal/settingsapi: ok; at this head go vet -tags nogui of gui, gateway and settingsapi, and gateway -run "Tier|ImagesAPIResolution|ImageMCP|Draw|Image", settingsapi and imagemcp: ok. - New: draw_tier_test.go (each protocol's field, a fake upstream for the images API and the image MCP, the 400 retry, the precedence). - At this head (on |