ca7eb9aff744c384ee290e2a3e3c27ae5bf7fe85
1439
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7b09d2c951 |
provider: a model can be listed by an id of the user's at its provider, asked for by its own
zeewell on X (tweet 2116404121930432888): relays serve one model under
ids of their own (deepseek-v4.1-flash-1017, grok-4.6@500k). They want to
give each one their own id at the provider layer. magpie then lists,
routes, groups and finds groups by that id, and the upstream request
still carries the vendor's id.
Choice: a new per-model map, settings' ModelIDs
("<pid>/<local>": "<own id>"), served through the wire names that
already exist. ModelSameAs was not widened. It means "same as another
vendor's model": it lends specs and joins found groups. Making it rename
models everywhere would change every existing user's ids and refs.
ModelWires was not reinterpreted either, for the same reason. ModelIDs is
ModelWires turned round: a wire keeps magpie's id and changes the one
sent, and this keeps the one sent and changes magpie's. Settings.Wires()
merges each entry in as a wire name (wrapped by a "<pid>/*" wire). Every
place that sent a ModelWires name (gateway, usage ledger, request page,
UpstreamName, UpstreamNameAs) reads Wires(), so the upstream id needs no
new path. An explicit ModelWires entry for the same id wins.
- Listed by the local id: Available, liveIDs/liveByID, Serving and
ListPrice translate through OwnModelID. /v1/models, agents' lists,
Resolve, routing groups and found groups (auto/<local>, merged with
every other provider serving that id) all see the local id.
- Only a provider of the user's own (Account == nil) takes one. An
account's or a plugin's request is built from its list's id, which no
wire reaches.
- Two variants of one provider given one id: the latest given it wins,
and the earlier one is listed by its own id again. The CLI names it.
The editor refuses two rows given one id in one save. A model of the
provider's own id that a variant is listed by (plain grok-4.6 beside
grok-4.6@500k) is not listed while the variant has it.
- The user's values are never overridden. SetModelID moves picks,
contexts, fallbacks, groups' members/rules/fast/placed/off/weights/
classifier/pick, the pickers' lists, every per-model setting
(Settings.MoveModel) and gateway keys' models (provider.ModelMoved,
set by access) to the new id, but only where nothing is under the new
id yet. Agents' own files are not rewritten: an old provider/<own id>
still resolves and is sent as it is. Group match patterns and key
patterns stay as written.
- Key limits: a key held to either id passes for both (modelAllowed:
the ref, OwnModelID, ListedModelID). Group members use the same check.
- Usage: model = the listed id, served = the vendor's id from its reply.
The price is the own id's first.
CLI: magpie model id <provider/model> [<id>|--reset], magpie model ids.
GUI: Providers > a provider's editor > Names & levels > "Listed as",
beside Same as. It is staged with the editor's Save and taken back by
Restore default, in zh, zh-TW, ja and de. Accounts have no box.
Docs: providers-accounts.md, gateway-routing.md, and site start.html in
en, zh and ja.
Run (mote-run, at this tree rebased on
|
||
|
|
0407d69e84 |
provider: a group of Kimi models keeps always_thinking, dynamic tools and its default effort
jiabubu on Discord (#feedback): one Kimi Code model put in a routing group so it lists first lost "always thinking" and "dynamic tool loading" in Kimi Code, which the same model straight from its provider has. buildGroupEntries never set AlwaysThinks, DynamicTools or DefaultEffort on a group (the Entry comment said "a group has none of them"), so kimiModelTables wrote the group's table without always_thinking and dynamically_loaded_tools, and default_effort fell back to high. groupSharedKimi now gives a group each of the three when every member's entry says the same, and none of it when one member doesn't or has no entry: a group request can reach any member (rule targets are members too, ruledEntry's of()), so Kimi Code must not shape a request for a member that can't take it. The capability words are Kimi Code 2.4.1's own (catalog-runtime.ts capabilityFromDeclared), already written for direct models; kimi-cli still gets neither. Tests: TestGroupSharesKimiFacts (provider: all share, one without, efforts differ) and TestKimiCodePlanCapabilities now writes a one-member group "top" (the reporter's case: always_thinking, dynamically_loaded_tools, default_effort max) and a group "mix" with a relay model (neither word). Run on mote (mote-run, sandbox HOME): - At 83a630d69 (on |
||
|
|
8413267097 |
catalog: a list's image/jpeg is an image, so OpenCode Go's models that see take images again (zeo9901)
zeo9901 (CC01CC) on Discord #feedback: "magpie 中 opencode go 所有的模型似乎 都无法实现图片输入了". Their screenshot is a routing group of DeepSeek V4.1 Flash at Open Design and at OpenCode Go. Cause: OpenCode Go's own /models (https://opencode.ai/inference/go/v1/models, the same at /zen/go/v1/models) lists what a model takes as media types: deepseek-v4.1-flash's modalities.input is ["text","image/jpeg","image/png", "image/gif","image/webp"], Gemini's adds application/pdf and audio/*, and so on. catalog's live-list reader took the list word for word and asked for "image", found none, and recorded ImageInput = false, an explicit answer. entryFor puts a list's explicit answer over models.dev's (which says image), so with a working Go key every Go model was text-only: a direct pick had its image described or turned away with "model does not support image input", a group member was sent it described or not at all, and agents were told the models take text only. It used to work while Go's list spelt modalities as models.dev does, or said nothing. Fix: catalog.Kinds reads a modalities list as models.dev words it (image/* image, video/* video, audio/* audio, text/* text, application/pdf pdf, each once, an unknown word kept, nil stays nil). imageInput and the live reader's InputModalities/OutputModalities go through it, as do Codex's input_modalities, the labs rows and a decision provider's listed facts (decide.go). A list saved before this, still holding Go's media types and false, is mended when read (mendKinds), so a user sees images from the first read after the update, not the next fetch. A user's own Accepts images answer still wins. Which OpenCode Go models take images, per Go's list on 2026-10-31: deepseek-v4.1-flash, kimi-k3, kimi-k3.1-pro, kimi-k2.7-code, glm-5.3-flash, qwen3.8-max, qwen3.8-flash, qwen3.7-plus, minimax-m3, minimax-m3.1-flash, mimo-v2.6-flash, mimo-v2.6-pro, step-5-preview, gemini-4-argon, grok-4.7, gpt-6-luna, gpt-5.6-luna, claude-haiku-5-5, muse-spark-1.2/1.3-contributor. Text only: deepseek-v4-pro, glm-5.2, glm-5.3, hy3, hy4-preview, longcat-2.0, beam-free, iceman-contributor-free. Tests (fixture: four rows of Go's real list, read without a key, no test reaches the network): - TestOpenCodeGoMediaTypesSee (catalog), TestKinds, TestSavedMediaTypesListSees, TestListedFactsMediaTypesSee (provider). - Broken by hand: Kinds returning its input unchanged turns all four red (deepseek-v4.1-flash, kimi-k3, gemini-4-argon "Images false"); the mendKinds call taken out turns TestSavedMediaTypesListSees red. Run on mote at the working tree on |
||
|
|
ceeb73a0f1 |
app: the desktop app writes its log to app.log; magpie log and Settings › About › Log find it
rayem1w on X (0.1.2330, macOS) was asked for ~/Library/Logs/magpie/serve.log while chasing a Codex "hit a snag" through the gateway, and had no such folder. Only the launch agent (magpie daemon install, written by launchd) and a gateway magpie tui left running wrote a log; the app opened from the Finder, the Dock or the Start menu logged to a stderr nobody reads, on every system. Now runGUI and runPanel (magpie, app, tray, panel, a window view, a magpie: link) call applog.Start before gui.Run. It sends the standard logger (the gateway, the plugin host, providers and Wails' error handler all log through it) to app.log as well as stderr, and points debug.SetCrashOutput at it so a panic's trace is there too: macOS ~/Library/Logs/magpie/app.log Windows %LOCALAPPDATA%\magpie\logs\app.log Linux $XDG_STATE_HOME/magpie/app.log, else ~/.local/state/magpie/app.log portable data/logs/app.log app.log, not serve.log: on a Mac launchd writes serve.log for the service, another process. The file is 0600. At 5 MiB it becomes app.old.log (two files at most); when another magpie (an update's new process) rotated it already, it is only opened again; when it can't be moved it is emptied. stderr goes first, through a writer that never fails, since io.MultiWriter stops at a failed writer and an app opened from Explorer has no stderr. Secrets: the log calls name header names and paths without queries; no key or token was found logged (grep of log.Print* in gateway, provider, plugin, gui, agent). scrub masks bearer/basic credentials, key/token query parameters and sk-, AIza, gh?_ and JWT shapes anyway. How a user finds it: Settings › About › Log, with the path, Copy and an Open that shows its folder (POST /api/settings/log/reveal; the row is hidden in magpie web, which writes no file). magpie log prints where every log is (the app's, app.old.log, the service's, the tui's background serve.log); --path the app's alone, -n N its last lines, -f follows it across a rotation. Docs: reference.md, gui-shell.md, site start (FAQ "Where is magpie's log?" and the CLI table) and privacy (files on your computer), en/zh/ja. Run: At 227ce6074 on origin/main |
||
|
|
fbb1b36d1f |
provider: the Claude keep-alive keeps off accounts, its reading, and its turn (#4532)
stringke read |
||
|
|
03f609e3fd |
redact: a token count is not a secret (Discord, steven_4422; #3775)
steven_4422 in #feedback, with a screenshot of the Masking page: "total
number of tokens are masked as secret". Claude Code's system reminder
<total_tokens>1499872 tokens left</total_tokens> went upstream as
<total_tokens>{{SECRET_dkfgb3bf}} tokens left</total_tokens>, listed under
Secrets and found by the local model. #3775 had the same with AstrLink
Guard (<total_tokens>14902266).
Cause: the model labels the count `secret`; modelFits lets a hex run
(hexRe, which a run of decimal digits matches) through when secretCued
finds a key word right before it, and secretCued takes a cue anywhere in
the name before the value, with letters after it: the tag's name
total_tokens ends "token" + "s", so the count was "called a token". The
same held for "total_tokens": N, max_tokens: N and token_count=N.
Fix: a value of decimal digits alone that the model calls a secret is
masked only where the name right before it (then =, :, is, a tag's >,
quotes) ends with a key's, a token's, a password's or a PIN's word
(numberNamedSecret: api_key=, "token": , PIN:, user_pin=, 密码是,
<token>…). A name that runs on past the word counts what it names.
Rules are unchanged (numeric keys after key=/token: labels, phones,
ID numbers keep their own rules). The eval's token-count case now comes
out right for AstrLink Guard, so its #3775 marker is off.
Tests: TestTokenCountIsNoSecret uses the reporter's bytes in a Claude
Code user message's system reminder (the reporter's 7-digit counts, and
8-digit ones as Claude Code sends on a large window; the model's
len >= 8 secret check already let the 7-digit ones go, so the reporter's
exact values may have been 8 digits as read off the screenshot), plus a
usage object, max_tokens, token_count and "spin:". TestNamedNumber-
SecretStillMasked keeps api_key=, "token":, token is, PIN:, user_pin=,
password:, 密码是 and <token>…</token> masked.
Broken by hand: with model.go as on main, TestTokenCountIsNoSecret is
red for the 8-digit counts, total_tokens, max_tokens and token_count
(PIN:/user_pin= were not masked on main either; now they are).
Run (mote-run, base origin/main
|
||
|
|
b48881f507 |
provider: keep idle saved Claude accounts signed in, by Claude Code itself (#4532)
#4532: a saved Claude account switched on but not needed for weeks (switch-only) had nothing run on it, its refresh token sat idle, and it was found signed out when the switch wanted it. Codex's saved sign-ins already had a keep-alive (RenewLogins, every 8 days, one account an hourly look). The same loop now takes saved Claude accounts that are on, not Claude Code's own, not added by setup-token and not already signed out (claudeKeptAlive). For one that is due it has real Claude Code run /usage in the account's own CLAUDE_CONFIG_DIR, the path a card's refresh takes (readSavedClaudeUsage, inSavedClaudeDir), and syncSavedClaude keeps whatever sign-in Claude Code refreshed. magpie asks Anthropic nothing itself: no OAuth or usage endpoint, as removed in |
||
|
|
2eac916170 |
gateway: short-lived gateway keys, issued by POST /v1/magpie/keys or magpie gateway-key issue
xazaj on X is moving an enterprise LLM gateway onto magpie. Their
orchestrator gives each sandboxed agent a key of its own, and that key
has to stop working by itself.
A gateway key can now expire (Key.Expires) and can be issued under
another key (Key.Issuer). It lives from 1m to 30d. It can be held to a
set of models, a set of accounts, tokens or cost over its whole life
(one "hours" limit as long as its life), and read-only.
- POST /v1/magpie/keys {"ttl":"1h"|3600, name, models, accounts, tokens,
cost, readOnly} answers 201 with the secret once, no-store. GET lists
the caller's keys, masked. DELETE /v1/magpie/keys/{id} revokes one.
- magpie gateway-key issue --ttl 1h [--name] [--models] [--accounts]
[--tokens] [--cost] [--read-only] [--from <id>] [--json] prints the key
alone. gateway-key issuer <id> on|off lets a key issue keys. list shows
until/expired/issued by.
Who may issue:
- a key the user let issue (Issues), from wherever that key is let in,
so a container or CI can;
- with no key, a request that profileRefused passes: loopback, no
forwarding header, no Origin/Sec-Fetch/Mozilla marks, a loopback Host.
Such a request can already use every model with no key and run the CLI,
so it gains nothing.
Never: a page, another computer without such a key, a key not let issue,
an issued or expiring key, or a read-only key (readOnlyGuard).
An issued key never outlives or exceeds its issuer. IssueKey clamps its
expiry and refuses models and accounts the issuer can't use. On every
authentication (access.Check, under Authenticate and On), identityOf
folds the key into its issuer as the issuer is now: models, accounts,
read-only, quotas and expiry. An issuer that is off, removed or expired
refuses its keys. Spend counts against the issuer too: the new usage
field callerIssuerId, budget.read/Append counting both keys, and Reserve
reserving on both. /v1/magpie/limit answers expires and issuerLimits.
An expired or refused key gets 401 with why ("… expired at …: ask for a
new one") on every route, from loopback too. Otherwise a held sandbox
whose key ran out would be let in as no key. Expired keys are pruned
after an hour (every 10 minutes while serving, and on each issue).
rowText packs CallerIssuerID: without it, usage.Visit returned the field
empty and the issuer's limit counted none of its keys' calls.
Docs: gateway-routing.md has "Short-lived gateway keys" and the
/v1/magpie stats API table. site/public/docs remote has "Short-lived
keys" and "Stats API" in en, zh and ja. GitHub OIDC is filed as #4531.
Run at base
|
||
|
|
07a3312c53 |
library: sync and backup files carry the subagents
xixi_Sean_ on X asked why Sync leaves the Library's subagents out. There
was no reason: the library part of a bundle now carries them.
- library.Bundle.Subagents (*[]*Subagent): name, description, prompt,
the skills and MCP servers named, the agents ticked. Collect always
sets it, empty too. Applied.Subagents (which files magpie wrote here
and their hashes) stays out: each computer writes the files into its
own agents on the sync Put runs and records its own, so a file the
user edited there, or one of theirs by the same name, stays theirs.
- Put replaces the subagents with the bundle's, so one taken out on one
computer goes from the others. A nil list (a bundle from a magpie
before this) is unknown and keeps this computer's.
- check refuses a subagent whose name isn't one (it is a file name in
every agent) or comes twice; agent ids are carried as they come, so a
newer magpie's tick for an agent this one can't give subagents to
stays and writes nothing here.
- davsync: an empty list hashes as before the field, so upgrading with
no subagents syncs nothing.
- backup files go through the same Collect/Put; the CLI's backup line
counts subagents. The GUI's sync/export/import ticks say "instructions,
MCP servers, skills and subagents" in every language.
- webdav-settings-refresh's "Agents" tick locator also matched the
library tick's "subagents": it now asks for "Agents' models".
- library.md and sync-backup.md updated. Hooks still aren't carried.
Run (rebased on 0bf5adb11; Go runs at e0c57ffe2, same diff):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
./internal/cli ok; ./internal/library -run 'TestCarry|TestSubagent|
TestLocalServer|TestPutKeeps|TestPutSame|TestRestoreKeeps' ok
- wsl-run (Linux): ./internal/library ./internal/backup ./internal/davsync
whole packages ok
- win-run (Windows): the same three, -run 'Subagent|TestCarry|TestLibrary|
TestSyncLibrary' ok
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four
packages ok; gofmt -l clean
- GUI (wsl-run, Chromium + WebKit, every language): i18n-keys,
github-sync, s3-sync, sync-auto-restore, sync-not-backup,
sync-other-kind, sync-sign-in, sync-spin, sync-usage-error,
webdav-settings-refresh, library-backups-top, gui-de, gui-ja,
gui-zh-tw, settings-search, settings-sections: 170/173, then
webdav-settings-refresh green after the locator fix. The one red left,
i18n-keys "a plugin's words are its own" ("Unmarked" in
plugins/routing/i18n.js), is on main already: #4524.
mote ran five other GUI suites at load 18, where every WebKit
github-sync case timed out at launch, so the GUI run moved to Linux.
Broken by hand: with Collect not setting Subagents and Put ignoring
them, TestCarrySubagents, TestCarrySubagentKeepsUsersFiles,
TestCarryNewerSubagents, TestBackupFileCarriesSubagents,
TestSyncSubagents and TestNoSubagentsHashAsBefore went red; with Put
treating a missing list as empty, TestCarryOldBundleKeepsSubagents and
TestBackupFileCarriesSubagents went red.
Not tried: a real WebDAV/S3/GitHub remote between two real computers;
the fake DAV server carries it between two sandbox HOMEs.
|
||
|
|
59546b3fdb |
gateway: Kimi Code's K3.1 Pro refusing reasoning none on Chat is asked again at its lowest (#3739)
7eleven.eth (Discord #feedback) hit "Kimi Code: K3.1 Pro does not support disabled thinking mode. Please enable thinking and try again, or choose another model." in ZCode. On Anthropic Messages, ZCode's default format, this was fixed in |
||
|
|
79b4be4668 |
redact: a public IP goes as public-ip-<letters>, not a documentation address
akic404 on Discord (#feedback, 10-31): "ip的脱敏策略需要改进,会把公网ip直接
脱敏成内网ip,能不能沿用其他的方法用{ip:…}的代替". Since
|
||
|
|
e6b851b0fe |
update: magpie update in a terminal restarts the app with its gateway handed over
gaubeebangeel on X has an agent run the magpie upgrade at 4am and had
to give that agent its own provider: magpie couldn't serve it through
the upgrade.
Cause: `magpie update` put the new version in and printed "quit and
reopen magpie to use it" (a .app) or "updated to X" (a binary). The
running app never restarted, so the agent (or the user) had to restart
it by hand, and a plain restart closes the port and drops streams.
Measured before, on mote, a sandbox HOME `magpie serve` with a fake
upstream streaming 61 chunks at 100ms, restarted by SIGTERM + start:
- the stream was cut at chunk 15 of 61 (unexpected EOF); SIGTERM to exit
took ~18ms, no drain;
- requests during the restart: 289 answered, 5 refused over 87ms.
Now `magpie update`, once the new version is in, POSTs it to the
running app's /v1/magpie/restart (gateway/restart.go). It is answered
only to a program on this computer over loopback; a LAN caller, a page
(Origin / Sec-Fetch) and another Host get 403. The updater's
restartBeside (gui/update_beside.go) restarts only when its own exe was
the one replaced (replaced() now also compares a .app's binary,
bundleExe), takes the version as ready without the feed, and runs the
same restart as Settings' AutoRestart: at once when it cuts nothing
short, else through waitIdle. On macOS and Linux that restart is the
existing SCM_RIGHTS handover, so the port never closes and in-flight
streams finish in the old process. The command prints what happened:
restarting (handing the gateway over), waiting for N requests, another
copy (current), magpie serve (unsupported), not running, or too old
(404: the first update into this version still needs a manual
restart).
Tests:
- TestUpdateInATerminalRestartsTheAppWithoutCuttingIt (darwin, linux):
a stream through the gateway, the exe rewritten, magpie update's ask
answered "restarting" with handover; the successor serves a request
while the stream runs, the stream ends whole, the old one quits only
after it. Red by hand with the route removed ("magpie update's ask:
404").
- TestUpdateOfAnotherCopyLeavesTheAppBe, TestRestartAskedOnlyFromThisComputer
(refused cases never reach the restarter), TestUpdateAsksTheRunningMagpieToRestart
(each reply, a 404 magpie, none running).
Run at this tree:
- rebased on
|
||
|
|
bdc1617bed |
routing: Accounts and keys count the whole day, not the last kept requests (#3351)
1234fsdc: the live Routing page's Accounts and keys said tried and answered over the requests the page still keeps in memory, so on a busy day the counts were a sliver of what Usage showed for the same accounts and went down as old requests fell off. /api/trace/history (the read the live page already makes every 15s) now carries `tallies`: per account or key, today's tries, answers, fails by reason, models answered, the last answer and the latest rest, read from routing/<today>.jsonl. The page seeds the list with them and still takes the latest rest and readings from the requests it keeps; a day looked at, or a purpose picked, counts its own list as before. The note says "over today's requests" then. Ported from ggbdpq's patch on the issue. Changed from the patch: - The patch parsed the whole day's file under history.mu on every look. A busy day's file is hundreds of MB (#3383) and saveRoute takes the same lock, so every 15s poll would stall the routes being written. DayTallies now folds in only the whole lines added since the last look (it keeps the offset, as History does); a line still being written waits for its end. It starts again when the day changes, the file shrank or was compressed, or the folder moved (another HOME). - What it returns is a copy: the patch handed out the live tallies, and the JSON writer read a Fails map the next fold wrote. - The latest name and rest go by the try's time, so no sort per look. - docs/subsystems/gui-shell.md says how the counts are made and that a request done since the last look is counted at the next one. Run on mote at this change on |
||
|
|
5787d758a7 |
usage: a search a provider's model runs with its own tool is a Web search row
cybercaius on Discord: with magpie's search APIs off, DeepSeek was asked to search, and Usage › Requests showed nothing of it; its purpose list had only All, Connection check and Unmarked. DeepSeek searches by itself on its Anthropic and Responses APIs (searchHosts): Claude Code's web_search_20250305 and Codex's web_search are relayed as sent, and the reply carries server_tool_use and web_search_tool_result blocks (#669), or web_search_call items. magpie read only the reply's tokens. Its Chat API has no search tool, so a Chat client's request there, with the searcher and the APIs off, gets no search at all. searchTally (search_native.go) counts what the reply shows: Anthropic's server_tool_use blocks named web_search and usage.server_tool_use.web_search_requests, the Responses API's web_search_call items. What a stream named as it went (a block's start, an item done, by id), what a whole reply or the stream's end listed, and what the usage said are counted apart and the most is taken, so an item named added, done and again in response.completed is one search. The relay's usage sniffer and both translated readers feed it into an unexported Usage.searches; after the request's own row, logNativeSearches writes one row per search (at most 20): Source search, Kind web_search, the request's agent, provider, host and model, status 200. No query is kept and nothing goes to telemetry: the rows ride the probes' lane as the search API rows do (listed, counted nowhere, not exported). An event is parsed for it only when it holds server_tool_use or web_search_call. The purpose filter needed no change: a search row's kind already gives it Web search (TestSearchRowsListTheirPurpose guards that, and passes on the old code too). The Requests tab shows the row with its model and provider as it shows a plan's own search. Run (mote, at this tree): - go test -count=1 -timeout 45m ./internal/usage ./internal/gateway: ok - go vet ./internal/gateway ./internal/usage, GOOS=windows and GOOS=linux go vet ./internal/gateway: ok; gofmt -l clean Broken by hand: - without this change TestOwnProviderSearchesAreLogged fails: "anthropic whole: 0 search rows, want 1" - counting every streamed web_search_call event instead of the done ones by id: "responses stream: 4 search rows, want 2" Not tried: a real DeepSeek account (the fixtures are #669's DeepSeek reply and Anthropic's documented stream shape); the translated readers' counting has no test of its own; no GUI file changed, so no GUI run. |
||
|
|
5218119456 |
redact: every reply gets its values back, a turn that masked nothing too
yapechan123 (Discord) saw a table the model wrote come back as
{{PERSON_kb32hzkg}}、{{PERSON_iye66366}} and {{PERSON_isyrz5ih}}、
{{PERSON_j5kluh3x}}, all four in canonical form. Every way a placeholder
could come back unrestored was probed with those literal bytes, on each
protocol's stream split at every byte and at 1..7 runes, and whole:
- The gateway put no restoring writer on a reply when the request in
hand masked nothing (redactedHits, redactedPromptHits returned early
on n == 0). A vendor that holds the conversation (Codex's compacted
history, a server-side session) answers with placeholders of earlier
turns while the request carries no value, so they went back as
written. Most likely the reporter's path. Now every reply on a masked
route is read.
- Responses streams: each event's random "obfuscation" string could end
like a placeholder start and take the stream's one held tail from its
delta, so the placeholder after 、 stayed (4 of 140 text runs, 6 of
tool args runs). The writer now holds a tail per string path and
never for obfuscation or kept keys.
- Kept keys (name, type, data, status...) were never restored in a
stream, so a Gemini functionCall args object {"name":"{{PERSON_…}}"}
kept it. Every string is restored now but signatures, data: URLs and
opaque blobs (sealedText).
- A whole body skipped restoring unless it held "{{", so a model's
PERSON_kb32hzkg or {PERSON_kb32hzkg} stayed; heldIn looks for any held
placeholder's hash.
- makeRoom let a random half of 200k values go though its comment said
the oldest; now the least recently used half (touch on every mask and
hit), so a value just masked is never the one let go.
- A binary reply (audio/, image/, video/, octet-stream, pdf, zip) goes
through as it comes instead of being held.
Not fixed by design: values are in memory only (README's privacy
promise, TestNoValueOnDisk), so a placeholder from before a restart that
only the vendor still holds can't be restored. Masking switched off
later also restores nothing.
Tests (all red on d159314e3's code, green now, run on mote):
TestReporterTableRestoredOnEveryStream (responses-text 4, responses-tool
6 fails before), TestPlaceholdersRestoredWhereverTheySit,
TestFullValuesKeepTheNewest (499 of 1000 newest lost before),
TestBinaryReplyIsNotHeld, TestReplyToAnUnmaskedTurnIsRestored (gateway,
real stack: first turn masks an email, second masks nothing and the
fake vendor answers with the first turn's placeholder).
Run: gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... on mote: clean. The full go test -tags nogui
-timeout 45m ./... on mote, one step before this head, found a nil
masker in redactedPromptHits with masking off (image drawing:
TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn, internal/cli's
image MCP); fixed here (m == nil returns as before). At this head
internal/redact and internal/gateway pass on Linux (wsl-run, 594s).
That run's other reds are outside this change: internal/gui
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll) and
TestColdTurnsTaken, internal/proc TestNoCommandBypassesProc
(internal/claudetui/child_unix.go uses os/exec). The full suite runs
again at the pushed head after the tag.
Not tried: a real Codex compaction round trip with a real account, and
the reporter's agent (unknown).
|
||
|
|
bfd4e9a5bf |
search: "Models that search by themselves" is always there, dimmed with why when magpie has nothing to search with
cybercaius on Discord, after v0.1.2309: "开关在哪个位置". They had turned
their search APIs off, so the row was hidden and couldn't be found.
The row is now always in Settings › Models › Web search. With no search
API on and no provider searching for other models, both choices are
disabled and dimmed (as the update rows are), and its line says why and
where to add one: "magpie has nothing to search with: add a Search API
above, or pick a provider under Searches for other models". Nothing else
on the page moves. zh, zh-TW, ja and de have the line.
Run:
- search-all (new case: a Search API turned off, provider search off, at
560px: the row is there, dimmed, says where, both buttons disabled, a
forced click saves nothing, nothing scrolls sideways), search-first,
search-order, i18n-keys: WebKit on Linux (WSL), 36 pass; with
searcher-pick, Chromium on mote, 46 pass.
Broken by hand: with the old settings.js, the new case fails in all five
languages.
searcher-pick in Chromium fails 1 of 2 runs at
|
||
|
|
88ecae1738 |
routing: By weight spreads a subscription's requests over its accounts
rubbzha on X (tweet 2116346330625036794): a Claude Max account and a Pro
one signed in to one subscription should share its requests by how much
each allows. The provider editor's Routing now offers By weight for
subscription accounts as it does for keys. With it picked, each account
in use shows "Weight N · S%" beside its name, the key weight's chip, and
a click edits it in place (POST /api/provider/accountweight {id, account,
weight}). CLI: `magpie provider account-weight <id> [account [n|default]]`.
The weight is kept per account by its lower-case name
(Provider.AccountWeights), and is moved with a rename (moveAccountSettings).
The gateway's keyWeight reads it from the candidate, with no file read, so
the smooth weighted pick treats accounts as it treats keys: Stays keeps a
conversation on its account, and a resting account is passed over while
the others share its requests. The default is 1. Nothing is prefilled from
the plan, and 1 is stored as no entry, so a value the user set is never
overridden.
Re-derived: ROUTINGS' weight text and routingsOf (the editor), the Routing
page's MODES, provider-row options and its "why first" text for an account,
the routing and accounts subsystem pages, the start docs (en, zh, ja), and
i18n in zh, zh-TW, ja and de (i18n.js and plugins/routing/i18n.js).
app.js is 74 bytes smaller than before (a long comment cut, keyWeight
reused), so neither script budget is raised.
key-weight.test.cjs read #status before accountAction's second round trip
(/api/state) had written it. The same race is now waited on in both tests:
with a 400ms delay injected on /api/state, the old read is red and the
new one is green.
Run (rebased on 03f3e1528; then on
|
||
|
|
f63cf0bfc2 |
affinity: a DeepSeek conversation stays on its key past five minutes, as DeepSeek keeps it cached for hours
On X: "Claude code 通过 Magpie 链接 DeepSeek 缓存命中率只有 50% 怎么解决呀".
Measured with a real DeepSeek key, Claude Code 2.1.314 in a sandbox
HOME through a sandbox magpie (usage cache_read / in per request):
- one interactive conversation on one key, Anthropic path: 0% on its
first request (13.7k system + tools), then 90–99% on every turn; the
Chat path (a chat-only provider) the same, 90–99%;
- masking on (redact + personal + local model): 98–99%;
- left idle 7 minutes: 99%, 98%; left idle 26 minutes: 99% (14336 of
14468);
- the misses are Claude Code's own requests: each session's first one,
the title call, an Explore subagent's first (5.6k, 0%), the auto
mode classifier's first (31.7k, 0%, and it misses again when Claude
Code changes its rules in that prompt), and --resume, where Claude
Code drops the thinking blocks from the history (76% on that turn).
A session with auto-mode tool calls and a subagent came to 76%.
Cause in magpie: affinity treated every vendor but the ChatGPT backend
as cold after five minutes (cacheCold). With two or more DeepSeek keys
or accounts (or a group over them), a conversation paused over five
minutes was handed to routing again and could go to another key, which
reads none of it from cache. DeepSeek's kv_cache guide (read 10-31)
says an unused cache is cleared "usually within a few hours to a few
days", and the 7 and 26 minute pauses above read 98–99% back.
Fix: coldAfter gives DeepSeek's own API (api.deepseek.com, Anthropic and
Chat paths alike) an hour, deepseekCold, as chatGPTCold does for Codex.
A group's rules read the same window for keepsEffort. Other vendors,
Anthropic included, keep five minutes. Nothing sent upstream changes.
Run (mote):
- TestDeepSeekConversationStaysPastFiveMinutes and TestDeepSeekColdAfter
red on the old code ("DeepSeek, 6 minutes on: why "cold" kept false";
"DeepSeek's cold is 5m0s"), green with the fix, beside the ChatGPT
cold, effort and affinity tests;
at this tree, rebased on origin/main
|
||
|
|
d159314e35 |
gui: a hidden window's WebView2 goes on its low memory target on Windows
molamaker11 on X: "magpie后台占用快接近600MB了。win端 这个能优化一下吗。比如剔除一些动画".
Cause. On Windows the tray panel and the main window are both made at
start and only hidden when closed, so two WebView2 renderers, the GPU
process and the browser process stay up in the tray. They were kept at
WebView2's normal memory target, so a hidden window held what it last
drew: after the window had been open, the GPU process kept ~85 MB and the
main renderer ~70 MB. Animations are not the cost: hidden pages run no
layout or style (LayoutCount/RecalcStyleCount 0 over CDP), the JS heaps
are 5 to 8 MB each, and the Go process is ~40 MB private (liveHeap 25 MB).
Fix. lowWhileHidden (memtarget_windows.go) sets
ICoreWebView2_19::put_MemoryUsageTargetLevel to LOW on each hide and on a
page that comes while the window is hidden (both windows are made hidden,
and get no hide), and back to NORMAL on each show. The page stays loaded
and running, unlike lightweight mode, whose default the owner turned off
on 10-21 because reopening reloaded the page. The vtable slot is 120:
ICoreWebView2_19's vtable holds every inherited method, counted in
WebView2.h of SDK 1.0.2210.55 (a first build that used slot 4 called
get_Source and crashed at start). zoom_windows_arm64.go's reflection walk
to the controller is now chromiumPart, shared with it. macOS and Linux:
WKWebView and WebKitGTK have no memory target magpie can set, so
memtarget_other.go is a no-op.
Numbers. xiaomi-gpu, Windows 11, WebView2 156.0.4314.50, a release build
of each (-tags production,comlauncher -H windowsgui) in its own sandbox
profile with the same seeded sessions and usage (~248 MB of Claude
projects, 72 Codex rollouts, a 4.2 MB usage.jsonl), tray start. The whole
process tree (magpie plus msedgewebview2), private working set (Task
Manager's Memory column) / commit, MB:
v0.1.2297 this change
fresh tray, window never opened 205-209/316-332 81/323
window open, every page clicked 304/482 236/467
1 min after closing it 265/479 69/459
5 min after closing it ~203/~476 64/453
idle 15-30 min later (sampled /5min) 200-214/474-481 -
1 min after closing, by process: GPU 85 -> 2.6, main renderer 70 ->
7.3, panel renderer ~50 -> 1.3, browser ~30 -> 6.2; magpie itself
~47 either way.
The commit charge barely moves: WebView2 trims the pages out of RAM to
the standby list and the page file rather than freeing them, so the
saving is RAM other apps get, not address space.
Reopening. Three trials, each window closed 3 to 5 minutes first, the
time for a view switch and two frames over CDP: the first trial took
901 ms on the first switch after reopening (v0.1.2297: 47 ms), then
12 to 31 ms; the other two trials were the same on both builds (first
frame 132 vs 131 ms, first switch 28 vs 30 ms, then 9 to 46 ms either
way).
Run: gofmt -l internal/gui (clean); on mote GOOS=windows go vet ./...,
GOOS=windows GOARCH=arm64 go vet ./internal/gui, GOOS=linux go vet -tags
nogui ./..., go vet ./..., go build; go test -timeout 45m ./... on this
tree (057c21b30, this commit with a draft message, on
|
||
|
|
b09349d179 |
search: magpie can search for a model whose provider searches by itself too
cybercaius on Discord: "能否强制支持联网搜索的供应商模型走代搜 API". Nothing
did this before: a provider that searches by itself (Codex, Copilot and
Grok accounts on Responses, a relay marked Searches, the search hosts) was
always sent the client's web_search, and "provider search off" and
"Search APIs first" only order magpie's own search.
Settings › Models › Web search gets one row, "Models that search by
themselves": their own (as before, the default) or magpie's. On,
settings.SearchAll makes magpieSearches true while magpie can search
(canSearchFor), so searchedForIt and translate treat the model as one that
can't search: the searcher and the search APIs answer, and the provider is
sent no search tool. With nothing magpie can search with the provider keeps
its own, and the row isn't shown. magpie's own searcher request
(searchingKey) is never turned around. The value is set on its own
(POST /api/settings/search-all) and carried by a save of the rest of the
page, so app.js is unchanged and the core budget holds. With provider
search off and this on, the searcher's note says the APIs answer every
model.
Run:
- go test -run Search ./internal/gateway ./internal/settings; ./internal/gui
TestSettingsSearchAllSetOnItsOwn, TestSettingsSearchProviderOff,
TestSettingsPageSave*, TestCoreScriptBudget (on mote): ok.
- TestSearchAllTakesTheSearchFromAProviderThatSearches: on with no search
API, relayed as sent with web_search_20250305; off, native and Tavily not
asked; on, Tavily asked and no native tool sent.
- go vet darwin, linux, windows on gateway and settings, windows on gui; gofmt.
- GUI: search-all (new), search-first, searcher-pick, search-order,
i18n-keys in Chromium (47 pass), en zh zh-TW ja de, 1100 and 560px.
The WebKit run was still going at the push (owner: ship at once); any
red it shows is filed.
Broken by hand: magpieSearches returning false, and without the
canSearchFor guard, the gateway test goes red; without the merge line in
api.go TestSettingsSearchAllSetOnItsOwn goes red ("a save of the page
dropped searchAll"); the old settings.js and i18n fail 15 of 20 GUI cases.
search-first now reaches its row before clicking, since the new row moved
it below the fold.
Not tried: real Codex, Copilot or Grok accounts with it on. Codex sign-in
turns relayed as sent (codexAsSent) and sealed relays keep the native
search; the Routing page's webSearchOf still says native.
|
||
|
|
c420559fdf |
usage: a search API's asks, and a plan's own searches, are rows of the request log (#3528)
cybercaius on Discord: "能记录代搜 API 的用量信息吗,在使用过程中看不到它用了哪些代搜 API". Nothing recorded which search API answered a search, how often, or whether it failed. Each ask of a search API (askSearchAPIKeys) and each search sent to Kimi Code's or WorkBuddy's own search service (ownSearch) is now a row of Usage › Requests, source "search" (usage.SourceSearch, kind web_search): the vendor or plan, the host asked, ok / found nothing / refused / the error, and the time. The row is a probe: it is listed, never counted in a total or a chart, and never exported. Telemetry reads no usage rows, so nothing is added to it. The query is not written: an error's text is scrubbed of it (url.Error reduced to op and host, and the plain, QueryEscape and PathEscape forms replaced). The Usage page badges the row "Search API", or "Web search" under a plan's provider, muted. Run (rebased on |
||
|
|
2f40cf4280 |
gateway: an In order group gives a conversation back to its first member at the next turn
yyhhyyyyyy on Discord made an Opus 5.5 group In order: an API key first,
a Claude subscription second, and 8 of 10 Claude Code requests went to
the subscription. With both healthy the plan is in order and every
request goes to the key. The cause is affinity: one failure of the key
(a 429, a 5xx, a rest) sent a conversation to the subscription, and Auto
affinity's "cache" kept it there at every turn after, since each turn
reads what the last wrote, while the key stood first and ready. A
provider's fallback already gave a conversation back (backToMain, "main");
a group's later member never did.
Now, in a group routed In order with Stays left on Auto, a new turn goes
back to the first ready member when that is another member than the one
that answered last (backToFirst, Affinity.Why "order"). Another key or
account of the same member, or a group in the group, keeps its own
affinity. Within a turn the conversation stays, on the reasoning the
later member sealed, as with "main". Stays: Session and Strict are the
user's own setting and keep it where it is. Smart and the other routings
keep it by its cache as before.
The Routing page says why it moved, for "order" and for a fallback's
"main", which showed no reason at all before (affWhy), in en, zh, zh-TW,
ja and de.
What was run (at the rebased head unless said):
- go test ./internal/gateway -run 'TestOrderedGroupGivesTheConversationBackToItsFirstMember|TestGroupMemberKeepsTheConversationOnceAnotherIsBack|TestFallbackGivesTheConversation|ChatGPTCold|LoginSwitch|LoneAllowance|Affinity' on mote: ok.
- 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 on mote, before the rebase: all ok.
- GUI in WSL magpie-desktop, Chromium and WebKit, 1100 and 420 wide,
every language: routing-affinity-order, routing-affinity-cache-write and
i18n-keys 44 of 44 before the rebase; routing-affinity-order and
i18n-keys again at the rebased head.
Broken by hand:
- the "order" case turned off (old behaviour): the new Go test fails,
"answered by ssssssssss, want ssskkkkkkk" and why "cache", want "order".
- the Within and Session guards removed: "the key failed once" fails with
skkkkkkkkk, and "Stays: Session" with skkkkkkkkk, want ssssssssss.
- client.js put back: routing-affinity-order 0 of 10 in Chromium
("order: goes in order not in").
Not tried: the reporter's own key and subscription (the subscription is
the test's fake Claude Code); that a failure of the key is what moved the
reporter's sessions is the likeliest cause the code shows, not confirmed
from their trace.
Full suite: go test -tags nogui -timeout 45m ./... on mote at the
pre-rebase head: 80 packages ok, two red. TestRuleTimeWindowAtTurnStart
("a 5 b 2") was this change: its group is In order, so turn 2 of "sess",
after the rule's hours, now goes back to a; the test now asserts that
turn's answerer and counts a 5 b 2. TestNoCommandBypassesProc
(internal/claudetui/child_unix.go:32) is red on main, #4491. At the
rebased head, go test ./internal/gateway -run
'Rule|Affin|Order|Group|Stay|Sticky|Cache|Turn|Fallback|Main|Cold|Login|Lone'
on mote: ok (107s).
|
||
|
|
03f3e1528b |
gateway: Qwen-Image and Wan 2.7 image models draw on DashScope's own API, so qwen-image-3.0-pro no longer draws nothing (judi0713)
judi0713 on Discord (v0.1.2288): qwen-image-3.0-pro draws when called
directly, but through magpie answers 502 "qwen-image-3.0-pro drew
nothing". DashScope documents its Qwen-Image and Wan 2.7 image models on
its own multimodal-generation API only (docs.qwencloud.com "Qwen-Image
text-to-image", and the Token Plan's "Integrate multimodal generation"):
a POST to <host>/api/v1/services/aigc/multimodal-generation/generation,
answered with the images at output.choices[].message.content[].image.
magpie sent them to the OpenAI images API at /compatible-mode/v1 and, on
its 404, to chat completions, whose answer holds no image it reads. Which
of the two answered the reporter is not seen from here.
Now, on a DashScope provider (dashScope(): Bailian, Model Studio, the Qwen
AI platform and Qwen Cloud, pay as you go and Token Plan, by preset or
host) a model named qwen-image* or wan2.7-image* draws there
(draw_dashscope.go, from drawImages):
- the prompt and any input images (data URLs) as one user message,
parameters watermark false, n when over 1, size as W*H;
- every image of every choice is read; with none, the error says what
DashScope said (message and code), the model's text, or the
finish_reason;
- a mask or a ratio size is a 400 saying what to send instead, with no
request made.
The root is the provider's Chat (or Anthropic) base cut at
/compatible-mode/, /apps/ or /api/v1. Every other provider and model is
unchanged (TestDashScopeDrawsScoped). /v1/images/generations and
/v1/images/edits both go through drawImages, and magpie's generate_image
MCP draws through those two, so all three are covered.
The fixtures are the documented response bytes, not a live answer.
Run (mote, at b06df2557 on
|
||
|
|
0d5df496aa |
library: a server kept direct is given to Codex as its command, so Codex starts it in the thread's folder (#4382)
cuipengcx90 on #4382 (and nifengfanpan0853 on Discord): with cocoindex set
to direct, Claude and Pi start it in their own folder, but Codex on magpie
was still given `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`. magpie's
/mcp/run (#3885) starts the command from home, so cocoindex answered "Run
`ccc init` in your project root". syncMCP now leaves a direct server out of
runVia, so Codex's entry is the server's command, args and env, as it is
for every other agent, with the hub on or off. runSpecOf, which serves
/mcp/run before a sync has recorded what it gave, no longer runs a direct
server either. A shared server is still run by magpie for Codex, as before.
No `cwd` is written: Codex's codex-mcp make_rmcp_client builds its
LocalStdioServerLauncher with the session's config.cwd as fallback_cwd,
used when the entry has no cwd (openai/codex 67f0994,
stdio_server_launcher.rs launch_server). RawMcpServerConfig takes command,
args, env, env_vars and cwd for stdio.
Siblings: runVia is the only place a command server becomes a URL
(runsFor needs fmtCodex). Every other format is given the command and
starts it itself; npxDirect (node in place of npx) and side (WSL image
server) keep it a command; magpie writes no cwd for any agent. Project
MCP files never went through runVia.
Run:
- TestRunDirectServerIsCodexsCommand (new): red on the old code with the
issue's exact entry, `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`,
when the syncMCP guard was taken out by hand; red again with only the
runSpecOf guard taken out ("before a sync /mcp/run would start the
direct server true"); green with both.
- mote-run: go test -tags nogui ./internal/library (ok, at the rebased
head
|
||
|
|
1a2ce7b8ef |
agent: a model picked in Claude Code's /model beside a Claude main runs at its own window, not 200K
young02036 on Discord put Codex Plus gpt-6.1-sol (500K) and Claude opus 5.5 (1M) in one routing group, with Context set to the smallest member's (500K). Each model picked on its own showed its window. The group showed 200K. Cause: with the main model one of Claude's own, marked [1m], magpie tells Claude Code no window. Anthropic runs that model at its own window, so claudeWindow is 0 and no CLAUDE_CODE_MAX_CONTEXT_TOKENS is written. writePicker still lists every magpie model and group in /model. Claude Code 2.1.314 runs an id it doesn't know as Claude's at that MAX, and with no MAX at its own 200K. So group/mix and w/gpt-6.1-sol picked there ran at 200K. Fix: pickerApart takes desktopPlan's path when four things hold: - the main is a Claude model or a group of them; - claudeWindow is 0; - /model offers a row that is unmarked; - that row isn't Claude's and has a known window. desktopPlan also counts the picker rows (pickerRefs). The top MAX is then the largest window, and each smaller row gets its own modelSettings.<id>.autoCompactWindow. A group gets its smallest member's window, the same as every other agent; under Full window that is 500K uncapped. Every other main is as before. A told window still serves a /model pick, and a main of no known window keeps the last one. Codex, OpenCode, DSH, Pi and the rest already list the group at 500000: they read the catalog's Context, which for a group is its smallest member's. Real Claude Code 2.1.314, in a sandbox HOME against a fake Anthropic server, with `-p --model X "/context"`: - old layout (no MAX): group/mix 200k, w/gpt-6.1-sol 200k; - new layout: group/mix 272k, gpt 272k, glm 204.8k, claude [1m] 1m; - new layout without the group's entry (Full window): group/mix 500k. - go test -tags nogui ./internal/agent/: ok (289s), on the base before the rebase ( |
||
|
|
d35509b65b |
agents: a custom provider's picked API is the one its models are asked on, and a model named like a routing group stays plain (nb5p)
nb5p on Discord: (1) a custom provider set to Responses had its models
wired into dsh on magpie's Chat Completions route (`magpie`), so dsh sent
Chat and magpie translated; (2) in dsh's models, mygateway/gpt-6.1-sol was
"GPT-6.1 Sol" while mygateway/gpt-6.1-terra was "GPT-6.1 Terra · MyGateway".
Cause 1: Provider.Native never read BaseAPI, the API the user gave the
Base URL as. Detect fills in every API that answers, so a relay picked as
Responses also had a Chat URL, and Native returned Chat (out[0]). Native
now takes BaseAPI after the vendor rules (ResponsesFirst, MessagesFirst),
when the provider serves it. dsh supports it: dsh 0.2.1-rc.2 bundles
@earendil-works/pi-ai, whose KnownApi includes "openai-responses", and
magpie already has the `magpie-responses` route (dshKinds). Siblings
reading m.APIs from magpieModels move with it: dsh, Pi, omp, droid,
Grok Build.
Cause 2: provider.Labels counted collisions over models and routing
groups together. A model two providers serve gets an auto group with the
model's name, so the shown model collided with its own group and kept
"· Provider" (terra: served by a second provider too, hidden for dsh;
sol: one provider). Models and groups are counted apart now: a model
keeps its suffix only when another model reads the same, and a group
named like anything else keeps "· routing group". Labels feeds every
agent's list, so this holds for all of them.
Not changed: the gateway's usable() still orders a translated request
Chat first and doesn't read BaseAPI (#4508).
Tests (each red on the old code, broken by hand in a worktree on
origin/main: all new cases red; reverting only Native red on the route,
reverting only Labels red on terra's name; the old dsh output reproduced
the report exactly):
- internal/agent TestDshCustomResponsesProvider (new): both models on
magpie-responses, none on magpie, named "GPT-6.1 Sol"/"GPT-6.1 Terra".
- internal/provider native_test: Responses picked beside Chat, Chat
picked, Responses picked for a Claude where Messages is served, and
Responses picked with no Responses URL.
- plainnames/plainown_groups/suffix_mode expectations updated to the rule.
Run on mote, at this change on
|
||
|
|
3e5aa11519 |
provider: Qwen Cloud, Alibaba's international Qwen platform, is a preset with its regions and Token Plan (judi0713)
judi0713 on Discord (v0.1.2288) asked for Qwen Cloud (qwencloud.com).
Its keys are its own, made at home.qwencloud.com, and serve neither
DashScope's nor Bailian's hosts, so none of magpie's Qwen presets took
them.
Two presets, the way Alibaba's other pay-as-you-go/Token Plan pair is
modelled, because each key gets 401 at the other's host:
- qwencloud: pay as you go, sk-ws- keys, at
https://{region}.maas.qwencloudapi.com/compatible-mode/v1 (Chat) and
/apps/anthropic (Messages), in six regions named by their ids as
Alibaba's docs name them: ap-southeast-1 (the default), us-east-1,
eu-central-1, ap-northeast-1, cn-hongkong, cn-beijing. Catalog alibaba.
- qwencloud-token-plan: sk-sp- keys, token-plan.maas.qwencloudapi.com,
Singapore only, with the plan overview's text models.
Endpoints, regions, key prefixes and the plan's models are from
docs.qwencloud.com ("Regions and endpoints" and the Token Plan
overview), not guessed. Responses is left out, as in the other
Qwen presets.
The gateway's dashScope() now knows both presets and the
*.maas.qwencloudapi.com hosts, so a Qwen Cloud stream gets the same
enable_thinking handling a DashScope one does. Import (presetAt), the
CLI's region= and magpie://import?preset=qwencloud®ion=... map to it.
docs/reference.md, the CLI help and the site's import page (en, zh, ja)
name them. Region names are ids, so no string is new to i18n.js and
nothing in the GUI changed.
Run (mote, at 708213f65 on c272e5582; after it the commit was rebased on
|
||
|
|
7fe191cec0 |
gateway: OpenCode Go's bare 400 (a model name, no error) is a 502 that rests nobody (#3740)
OpenCode's gateway answers some of s-leeq's turn-start requests with a
400 whose body is {"model":"deepseek-v4.1-flash"} and nothing else: no
error, message, code, type or param, nothing in or out, no reply id.
retryable() read it as the request's own fault, so a group stopped there
and a lone provider's turn ended on it, with a 400 nothing retries. Their
log ties it to the request, not the key: 30 of 214 requests carrying
~246K tokens of tools failed so, none of 420 under 1K, and the same
request was answered 200 some 13s to 25s after the first refusal.
openCodeBareRefusal (ported from ggbdpq's patch on the issue) reads a
400 from an OpenCode host whose body is a JSON object naming no error
field as the 502 it stands for (asBadGateway). A group asks its next
member; a lone provider is asked again within its patience (60s, with
replan pauses), which outlasts the reporter's window. Any 400 that names
something, a body that isn't a JSON object, and every other vendor's
400 go on as they came.
Changed from the patch:
- restAfterMarked rests nobody for this 502. The patch rested the key
for fallbackCooldown in a group (a scratch test showed ocgo resting
60s), over a refusal tied to request content: one heavy prompt would
have set aside a key that serves every other request.
- The body is read through a 64KB limit and put back with a
MultiReader, so nothing is cut; a body at the limit is left alone.
The patch read it whole.
- TestOpenCodeGoBare400ToldAs502 asserts at least 3 asks, not exactly
3: on current main the lone provider's patience asks 15 times.
Run on mote:
- At the pushed head (on
|
||
|
|
c272e55825 |
gateway: any model's 8.0 in a call's arguments reaches the agent as 8, not only Grok's (#3152)
1024MrL's Codex, on opencode-go/muse-spark-1.3-contributor through the
gateway, had every tool_search turned away before it ran ("failed to
parse tool_search arguments: invalid number" over {"limit": 8.0}), and
exec_command the same ("floating point `2000.0`, expected usize").
grok_integral.go's whole-number rewrite (#1431) already fixes exactly
this, but it ran only when the model was Grok's.
Decision (delegated by the owner): the rewrite runs for every model,
not narrowed to Grok. Why:
- The defect is the model's, not a vendor's: Grok (#1431) and muse-spark
(#3152) both write it, and no list of models would stay complete.
- The rewrite changes only a number written with a fraction of zeros and
no exponent, to the same JSON number. Strict parsers break on 8.0
(Codex's serde u64/usize/i32, Go's json into an int), while every
float-typed field takes 8 (serde f64, Go float64, JS). The one visible
difference is a Python client's json.loads giving int 8 for float 8.0,
which any `number` schema allows.
- Strings, keys, other fractions (2.5, 2.50) and exponents (1.0e3) stay
as written, held by integralCases' edges case.
- The reporter ran it end to end on Windows with real Codex 0.163 and
muse-spark: 6 of 7 and 20 of 21 calls refused without it, 0 with it in
two runs (thread, 10-23).
Gemini routes are left as they were: their call arguments are an object
the client decodes itself, and no report shows the shape there.
What changed:
- passthrough installs intTidy on every Responses, Chat and Messages
reply; translate's Request.Grok and grokServed are gone, encoder wraps
every reply in wholeEncoder and render runs wholeResult. grokModel
stays for grok_schema.go.
- crTidy (glm-5.3-flash*'s stitched CR, #4256) now runs before intTidy,
in the stream, the held-tail chain and the drain. With intTidy on every
route, a whole reply it held went from its flush past crArgs, so the
CR cure never saw it (added in this port: the patch's comment gave a
different reason).
- intTidy's flush says a whole reply with no call marker as it came,
without decoding it (added in this port), since every model's whole
reply now reaches it.
- TestOnlyGrokCallsGetIntegers (which held the old scope) became
TestOtherModelsCallsGetCodexIntegers; TestGrokCallsByUpstreamName is
gone; TestToolSearchWholeFloatLimitGivesCodexIntegers is the report's
shape; TestStitchedCRAndWholeFloatsBothGo (added in this port) holds
both cures on a glm-5.3-flash route, whole and streamed. Its whole
case reads the input's fields as written, not through a decode and
encode, which would print 8.0 as 8 and pass on the old code.
Run at this head (rebased on
|
||
|
|
df1c3dace3 |
gateway: a relayed stream cut mid-line sends no half event ahead of its error (#2580)
A passthrough stream the upstream reset inside an event (YonQua: Z.ai's
glm-5.3 under pi) sent the half event's data line on to the client, and
pi's SSE parser died on its JSON ("malformed server-sent event JSON")
before it reached the error event magpie appended after it (#2446 put
that event on its own line; the half line ahead of it was still there).
passthrough's write now holds a stream's last unended line back until
its rest arrives; only lines that ended go out as they come. A reply
that ends whole puts the held line out as it came. When a failure is
appended (streamFailure, or the finish_reason filled in for Gemini's
OpenAI-compatible API) the held line is dropped first, unless its data
parses (whole JSON, or [DONE]): that one is no half event and goes out
before the failure, as on main. A non-stream reply is written unheld.
Changes made to gua2100's patch (ggbdpq/magpie hunt/2580-midstream-reset
30288fe28), both regressions it brought, each red with the patch as
posted:
- a gathered stream (a plugin's Responses account asked for one body,
plugins#112) returned before the held line was put out, so a stream
whose response.completed had no newline after it became a 502 "ended
before it was complete": TestGrokPluginNonStreamLastLineUnended.
- a reset after an event's JSON was whole but before its newline dropped
that whole event, which main delivers:
TestChatStreamCutAfterWholeEventKeepsIt.
Tests: TestChatStreamCutMidLineLeavesNoHalfEvent (gua2100's; severed
gained a Chat shape) red on origin/main 5c1ccec4a's gateway.go:
"passthrough_severed_test.go:190: a half event the upstream never ended
went to the client as data". The two above pass on main and fail on the
posted patch. Broken by hand: dropHalf's parse check made always true
(every half line kept), TestChatStreamCutMidLineLeavesNoHalfEvent red
again; restored, green.
Run at this head (rebased on
|
||
|
|
82ff889338 |
gateway: a Chat tool call naming no function is dropped, not sent for the client to refuse (#1475)
AricRedemption on #1475: a long Qoder turn ended with an upstream tool call whose function.name was no string, and the AI SDK refused the whole reply ("Expected 'function.name' to be a string"), not retryable and with the call already in the history, so every "continue" died there while the gateway logged status=200 done=true. The parsers for calls a model writes into its text already refuse a nameless one, but calls an upstream made itself went out as they came. A call whose function names nothing in a JSON string (absent, null, another kind) is dropped on every path a relayed Chat reply leaves by: a stream (chatTidy.nameless, its later fragments with it, and the id mend no longer gives the dropped fragments an id back), a whole reply (wholeNameless in chatWhole) and a whole reply given as the stream the agent asked for (chatWholeEvents). A finish of tool_calls with no call left ends stop. An empty string name goes as it came. Translated routes are unchanged: their names are Go strings by construction. Changed from gua2100's patch (hunt61-a-1475-unnamed-call, d851d922f): - chatWholeEvents turned the finish to stop whenever any call was dropped, so a named call beside a nameless one went out with finish stop and the client ended its turn without running it; it now does so only when no call is left. The calls it keeps are numbered 0.. with no gap where a dropped one stood, and a call with no function object is dropped there too, as wholeNameless already did. - chatWhole turned any whole reply ending tool_calls with no named call into stop, a reply that came with no tool_calls at all included; it now does so only when wholeNameless dropped a call. New tests for both: TestNamelessCallBesideAGoodOneWholeAsStream, TestToolCallsFinishWithNoCallsStaysWhole. Run at this head (451c7e929 on |
||
|
|
9345318ff7 |
gui: Codex's Long conversations lines fit the core budget, no raise (zgjfjfl on Discord)
|
||
|
|
5c637f17b2 |
gui: Long conversations says what makes Codex compact before it (zgjfjfl on Discord)
zgjfjfl set Long conversations to "Compact at 544K", and Codex still
compacted every conversation at about 128K. The model is gpt-6-A, with no
context size set on the provider, on v0.1.2281.
Codex 0.165 compacts at min(model_auto_compact_token_limit, 90% of the
window). magpie writes the model's window into the catalog and writes
auto_compact_token_limit only when Long conversations is below that
window. Two things put Codex under 544K, and the row said neither:
- ~/.codex/config.toml's model_context_window or
model_auto_compact_token_limit, at the top or in a profile, which
Codex reads before magpie's catalog. The row now names each key, with
its profile and value, and "Take it out" removes those lines
(agent.CodexCompactHeld, DropCodexCompactHolds,
POST /api/settings/codex-compact-held/drop). Nothing is removed unless
the user clicks.
- The model's own window. gpt-6-A isn't in models.dev, so its window
comes from the provider's own /models list (context_length). A relay
that lists it at 128K makes Codex compact at ~115K, and no Long
conversations value can raise that. The row now names the model Codex
runs (agent.CodexModel, from config.toml's model and the picked
profile) and the window magpie tells Codex, and says a larger one is
set in the provider's Context window (codexWindowUnder).
Which of the two the reporter has is not known: their config.toml and
their relay's list weren't seen.
Run (worktree at origin/main
|
||
|
|
06c2c35d13 |
claude: the interactive mode's start is waited for, and a hung one goes to -p (#4504)
derrors (Linux Docker, 2 vCPU, v0.1.2281): every new Claude Code run
failed "Claude Code has not answered magpie's initialize request in 10s"
and the turn was 502 after 6 tries, while -p runs on the same account
answered.
Cause: the claude-tui-helper answers the bridge's initialize only once
the interactive Claude Code shows its prompt (claudetui.ready, up to
45s), or as -p after it falls back. The bridge gave it the 10s of any
control request and then ended it, so a Claude Code slower than 10s to
start was killed before its own -p fallback could run, and nothing was
marked: each try started the interactive mode again.
Fix:
- startRun waits tuiInitWait (claudetui.ReadyWait + 2x controlWait, 65s)
for a TUI run's initialize, and gives up on the request's context.
- a helper that still answers nothing is ended, the machine is marked
(claudetui.MarkBroken), and start runs the turn again as -p.
- claudePrintWhy goes -p at once while the mark holds ("the interactive
mode failed to start lately"), so no helper is started.
- the mark counts failed starts in a row: 30m after one, doubled to a
day (brokenFor), so a machine where it never starts waits about once a
day. A start that shows its prompt removes the mark.
- the helper falls back at once when Claude Code asks how to sign in
(a container signed in for -p only, CLAUDE_CODE_OAUTH_TOKEN), which
it otherwise took for the prompt or waited 45s on.
Every other control request keeps its 10s; initialize is the only one
a TUI run is sent (cliControl's one other caller is setSafeguards,
and a run with safeguards or cache marks is -p).
Run (mote, at this tree):
- go test ./internal/claudetui/ (whole package) ok
- go test ./internal/gateway/ -run Claude ok
- GOOS=linux and GOOS=windows go vet ./internal/claudetui/
./internal/gateway/ ok; gofmt -l clean
- wsl-run (magpie-desktop, Ubuntu 24.04): go test ./internal/claudetui/
./internal/gateway/ -run 'TestShim|TestBroken|TestClaudeTUI|
TestClaudeEndedRunSaysWhy|TestClaudeUnloadable' ok
Broken by hand (each red, then restored):
- TUI initialize waits controlWait, no mark, no retry (the old code):
TestClaudeTUISlowStartAnswered 502 "Claude Code has not answered
magpie's initialize request in 10s", the reporter's message
- TUI initialize waits controlWait only: marked broken, red
- no MarkBroken in the bridge, or no retry in start:
TestClaudeTUIHungHelperGoesPrint 502
- no sign-in check: TestShimFallsBackToPrint/asks_to_sign_in timed out
- no clearBroken: TestShimStartClearsBroken red
- brokenFor not doubling: TestBrokenGrows red
Not tried: a real Claude Code in a headless container, or any real
account. Why derrors' Claude Code was slow or stuck is not known: the
sign-in screen is a guess from -p working where the interactive mode
didn't; the helper's line now logs the screen it stopped on. No full
suite.
|
||
|
|
c59c547c5b |
claudetui: Claude Code's interactive mode on Windows, in a pseudo console
A Claude run on Windows was always claude -p, the entrypoint the plan counts at about twice the interactive mode's. The helper now starts Claude Code in a ConPTY there (child_windows.go): CreatePseudoConsole on two pipes, CreateProcess with the console attribute and STARTF_USESTDHANDLES with no handles. Without that flag a child takes the helper's own standard handles (the bridge's pipes) and draws into them, not the console. A .cmd claude is quoted by proc.Command as the -p run's. Ending closes the console, then kills after 3s; the -p fallback runs Claude Code as a child, as Windows has no exec. The pty code moved to child_unix.go unchanged, and tui.go has no build tag. Windows ends a run by killing its job, which no handler hears, so a turn's images folder is now removed once its message is sent, and a helper starting removes magpie-claude-images-* folders over an hour old (dropLeftImages). The gateway's gate lets Windows through (WSL stays -p), and the setting's text no longer says Windows is always -p (en, zh, zh-TW, ja, de). Doc updated. Run: - go test ./internal/claudetui on macOS (mote), Linux (magpie-desktop WSL2) and Windows 11 26200 (xiaomi-gpu): ok. The fake Claude Code on Windows is a claude.cmd, its console made raw with SetConsoleMode. New: TestDropLeftImages, and TestShimPastesImages checks the folder is gone after its message. - go test -run Claude ./internal/gateway on mote, and the TUI tests on Windows: ok. - i18n-keys and claude-tui-setting (chromium and webkit, en/zh/ja/de, 1100 and 420): 20 of 20 on the Windows box. On mote chromium passed and every webkit case timed out in browserType.launch, beside other sessions' GUI suites running for up to 20 hours (load 22). - go vet -tags nogui of claudetui, gateway and cli for darwin, linux and windows; gofmt -l clean. - Real account on xiaomi-gpu: a sandbox HOME gateway (port 3462) with the Claude Max account, real claude.exe 2.1.281, haiku-5-5. One tool call, two in one message, text then a call, and two image turns (twice): all right answers. 81 transcript rows, every one "entrypoint":"cli", no "-p" line in the log. Images noted as C:\Users\...\magpie-claude-images-*\image-N.png and no folder left. Killing the gateway ended its four resident helpers and claude.exe. The token wasn't refreshed; the copied credentials were deleted. (This ran before the 1809 check in start was added; the claudetui tests on Windows and GOOS=windows vet ran again after it: ok.) Broken by hand: STARTF_USESTDHANDLES removed, TestShimTurnsInteractive on Windows red (3 lines of 5 in 30s: the fake's drawing reached the shim's stdout). Not tried: an npm claude.cmd install with the real account (only the fake .cmd), Windows 10 before 1809 (no CreatePseudoConsole: the start checks for it and falls back to -p), a run ended mid-turn by the client on Windows. A stray "The system cannot find the path specified." showed once in the Windows test output; it wasn't on the shim's stderr, and three reruns didn't show it. |
||
|
|
c8f199695c |
gateway: DeepSeek's reasoning is held for a refusal after it; WorkBuddy plugin min 0.2.4 (plugins #540)
itspig (plugins #540): deepseek-v4.1-flash on WorkBuddy, through group/tiered, reasoned ~5s, said "Sorry, I can't respond to this question.", and ended finish_reason content_filter with 0 output tokens under a 200. The try was recorded done/200, none of the 15 members behind it was asked, and DeepSeek Harness failed "The model refused to complete the request". Two halves: - workbuddy 0.2.4 (plugins 4883f94) takes the filter's canned line out of a streamed chat that ends content_filter with nothing else said. - refusesAfterThinking now holds DeepSeek's reasoning too (as Claude's, GPT's and Gemini's), only while another candidate could answer: with it let through as it came, a refusal after it could never go to the next member. DeepSeek's own API documents finish_reason content_filter. The cost: in a group with a member behind it, DeepSeek's thinking reaches the agent once its text begins (kept alive meanwhile), as Claude's does; on the last candidate it streams as before. GLM, Kimi and others are unchanged. - The workbuddy mover's min is 0.2.4 (npm view --prefer-online: 0.2.4). Run on mote at this tree: go test ./internal/gateway -run 'TestDeepSeekRefusalAfterThinkingFailsOver|TestThinkingHeldFor| TestRefusalAfterThinkingFailsOver|TestThinkingStreams' ok; go test ./internal/provider ok; gofmt -l clean. The full ./... suite was started at this tree minus the one-line min and is still running; its result goes on plugins #540 (owner rule: tag without waiting). Broken by hand: without the deepseek prefix, TestDeepSeekRefusalAfterThinkingFailsOver/refused goes red (DeepSeek's reasoning reached the agent, b never asked) and TestThinkingHeldFor red for the three DeepSeek ids; /answered stays green. Not tried: a real WorkBuddy refusal (no prompt reproduces it on demand); the upstream's literal chunking isn't in the issue, so the fixture is built from its fields (reasoning, content_filter, 0 tokens). |
||
|
|
bca0d6d69a |
claudetui: a turn's images are pasted as files, not sent to claude -p
A request with images ran claude -p, and a turn with one ended the interactive run. The helper now writes each base64 image to image-N.<ext> (0600) in a magpie-claude-images-* temp folder and pastes its path alone, which Claude Code 2.1.314 reads into the message as [Image #N]; a path inside other words stays words. Claude Code reads the file after the paste returns, so the helper waits for [Image #N] past the last one before pasting the next piece. The folder is removed when the helper ends. Only an image known by its URL still goes to -p (urlImages), and tuiPromptMost counts words without images. Run: go test ./internal/claudetui ./internal/cli on mote and in WSL magpie-desktop, ok; go test -run 'TestClaudeTUI|TestSubscription| TestClaudePrint' ./internal/gateway on mote, ok; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build, gofmt -l, ok. Real account (Claude Code 2.1.314, haiku, sandbox HOME) through the sandbox gateway with tools: a red then a blue square in two turns, 3 of 3 answered red, blue; the transcript has image blocks in both user rows, entrypoint cli, and the second turn went on in the same run. Broken by hand: without the wait for [Image #N], TestShimPastesImages loses the second image. Not tried: an image over Claude Code's size limit; Linux with a real account. |
||
|
|
9d4a4bfd3f |
gateway: a late Claude Code call tells the client after 500ms, not 1s
In Claude Code's interactive mode a call of a client's tool waits callFirst for its message in the transcript before the call tells the client itself. Measured on a real account (a probe build logging the time from the MCP call to the transcript's tool_use), a message written before its call was read 118 to 162ms after the call came in, 8 calls of 8. 500ms leaves it room and halves what a late message costs. Run: go test -race -count=3 -run 'TestClaudeTUI|TestSubscription' ./internal/gateway on mote, ok. Real account (claude-haiku-5-5, sandbox HOME, interactive TUI): 9 runs of the one/two/text scenarios, all ok, every call told once with its own id; 1 took the late path, none fell back to -p. Not tried: sonnet/opus, Linux. |
||
|
|
e647a1fd54 |
plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.
The GUI row is in registry.js, imported when Discover draws it, so the
core script budget isn't raised (plugins.js is 292 bytes smaller than
before, one long comment there condensed).
Left out: bunfig [install.scopes] for magpie's own lookups (bun reads them
for installs), .npmrc _auth and username/password, NPM_CONFIG_USERCONFIG
and npm's global npmrc, and internal/agent/cliupdate.go's agent CLI update
lookups, which still ask npm's own.
Run (mote and wsl-run). First at this change on
|
||
|
|
45de2ddb96 |
provider: a provider the user counts free goes first under Free first (jiabubu on Discord)
jiabubu asked on Discord #help for a way to mark a provider, model or key
as free, so that Free first routing spends it first. Their example is
ModelScope, which has a free daily quota. Until now routes.Seat.Free
came only from the vendor catalog's Free flag, and there was no way for
the user to set it.
Provider.CountFree ("Free for me" in the provider editor's Advanced fold,
`magpie provider set <id> free=yes|no` in the CLI) makes FreeModel true
for every model of that provider. Routing therefore treats it like a
vendor's free model: Free first uses it before paid ones, and Cheapest
first weighs it at nothing, because PriceAt, which only routing reads,
returns 0 for a free model. Prices shown (ListPrice and the model list)
and the costs Usage counts (EffectivePrice) are unchanged. The mark says
what to spend first, not what a call cost, and a quota that runs out
still bills at the listed price. Key and account (subscription)
providers both carry it, through withPicks, the account literal and the
copy merge.
Tests:
- internal/gateway TestFreeFirstSpendsTheProviderTheUserCountsFree:
- a Free first group [paidv/m, mine/m] sends its first call to mine
once mine is marked, and the trace row says Free;
- EffectivePrice is still the listed 3/15;
- Cheapest picks mine first;
- unmarked, paidv goes first again.
- internal/gui TestProviderSaveKeepsCountFree: the preset and typed-in
providers save the mark and clear it, and /api/providers reports it.
- internal/cli TestProviderSetFree: free=yes and free=no work; the value
shows in `provider <id>`; free=maybe, an empty value and --help are
refused and change nothing.
- GUI internal/gui/tests/provider-count-free.test.cjs covers the
ModelScope preset, a custom provider saved with the mark, and a Codex
account. It runs chromium and webkit, in en, zh, zh-TW, ja and de, at
widths 900 and 440. It checks the Advanced fold, the check and save
POST bodies, that the row fits with no sideways scroll, and that each
string has a translation in I18N.
Core script budget: rebased on
|
||
|
|
c799934e1b |
claude: the gateway logs why a run is -p
Finding why the real-account runs went -p (the previous two commits'
end-to-end) took reading a run's stderr by hand: the bridge keeps Claude
Code's stderr for an error only, and claudeTUI said nothing of why it
chose -p.
claudeTUI's conditions move into claudePrintWhy, which names the one
that held ("Claude Code in WSL", "a JSON schema", "the interactive mode
is turned off", ...), and claudeTUI logs "claude: this run is -p: <why>"
(not in the tests' binary, claudeTUIRuns off). lockedWriter logs the
helper's "claude-tui: ...; this run is -p" line (a failed start, an
untrusted folder, the 30-minute mark) as "claude: ...". The rest of
Claude Code's stderr is kept as before and not logged.
Run:
- mote: go test -count=1 -run TestClaudeTUI ./internal/gateway ok:
TestClaudeTUIChosen now checks each case's reason,
TestClaudeTUIFallbackLogged the helper's line logged and nothing else.
go vet ./internal/gateway on darwin, linux, windows; gofmt -l clean.
- Real account, sandbox HOME, a gateway on this build: before the trust
fix, the helper's line is what named the cause ("Claude Code ended
before it showed its prompt (exit status 1): B").
Broken by hand: the log in lockedWriter taken out:
TestClaudeTUIFallbackLogged red (logged "").
Not tried: the log on Linux.
|
||
|
|
123d72be68 |
claude: a call Claude Code makes before writing its message is the reply
In the interactive mode the bridge learns of a call from the session's
transcript. Claude Code sometimes writes the message holding a client's
tool_use only after that MCP call returns (4 of 8 real runs before this).
The call waits on the client, and the client waits for the call it was
never told of: a deadlock until the run's timeout.
mcpCall now hands each call to run.onCall, which readOutput sets for a
TUI run. If callFirst (1s) after the call it isn't in the transcript yet
and still waits, the call itself becomes the reply: a message with one
tool_use and stop tool_use, with the MCP helper's id, name and arguments
(the id is the transcript's, from _meta "claudecode/toolUseId"). The
message written after such calls is the late one: its rows aren't told
again (lateID), a call in it not yet told is told by its own turn
(written), and its usage is counted in the next reply. Such a reply has
no words or thinking; the model's text before its call is lost to the
client. -p runs don't set onCall and are unchanged.
docs/subsystems/claude-subscription-bridge.md has the paragraph.
Run:
- mote: go test -count=1 -race -run TestClaudeTUI ./internal/gateway ok
at this tree; earlier, -race -count=5 of the new tests ok.
- TestClaudeTUICallBeforeItsMessage (output 47 = late 40 + answer 7),
TestClaudeTUICallAfterItsMessage (told once, output 7),
TestClaudeTUIParallelCallsBeforeTheirMessage (written after both, and
between).
- mote: go vet ./internal/gateway on darwin, linux, windows; gofmt -l
clean. go test -timeout 45m ./internal/gateway ./internal/claudetui
./internal/claudebridge ok before the previous commit's rebase
(gateway 522s); a run with all three commits is going.
- Real account, sandbox HOME, a gateway running this build, haiku: "two
calls in one message" logged "Claude Code called get_secret before
writing its message; the call is the reply" for both calls, and the
client got red then blue as two replies and the answer naming both
secrets. One call, and words then a call: answered from the
transcript. Every row "entrypoint":"cli".
Broken by hand: onCall never called: the three tests red ("deadlock").
lateID never set: the late message told again, red.
Not tried: sonnet or opus in the real run (haiku only); a call whose
client takes longer than the run's timeout.
|
||
|
|
faaba45236 |
claudetui: the folder-trust question is answered Yes only once Yes is drawn
The real-account end-to-end through a running gateway found every interactive run going to -p. The gateway's working folder (magpie-claude-work-<uid>) wasn't yet trusted under the account's config dir, so Claude Code 2.1.314 asked whether to trust it, with "No, exit" chosen. The helper pressed down and then, 300ms later, Enter without looking. Its down was lost when sent as the question was first drawn (the question is drawn again on No), Enter chose "No, exit", and Claude Code ended with status 1 (screen: "B"). The start failure marked the interactive mode broken for 30 minutes and every run went to -p, so v0.1.2266's default did nothing on a fresh account. ready() now reads the choice as the last of "❯ No, exit" / "❯ Yes, I trust" drawn, presses down (at most once a second) while No is chosen, and Enter only on a Yes that stayed drawn for 300ms (trustSettle). The test's fake asks as the real one does: words placed by cursor moves, No chosen first, keys in its first 150ms lost, and drawn again on No; Enter on No exits 1. Run: - By hand: real Claude Code 2.1.314 in a PTY in the gateway's folder, sandbox HOME with a real account's config dir: the question opens on No; a down sent at once is undone by the redraw, one sent 0.3s or 1.5s in moves to Yes. - mote: go test -count=3 -run TestShim ./internal/claudetui ok; go test ./internal/claudetui ok; go vet ./internal/claudetui on darwin, linux, windows; gofmt -l clean. - Real account, sandbox HOME, a gateway running this build (and the next commit's), haiku: a tool call, two calls in one message, words then a call: all answered, every transcript row "entrypoint":"cli", no broken mark. Broken by hand: the old ready() with the new fake: TestShimTrustsWhenTold red, "Claude Code ended before it showed its prompt (exit status 1)", the real failure. Not tried: Linux with a real Claude Code; a Claude Code version whose question words differ (it then waits out 45s and goes -p, marked). |
||
|
|
2ac423f4f2 |
kimi: a Kimi Code plan model is told always_thinking, dynamically_loaded_tools and its default effort, as Kimi's list says (jiabubu)
jiabubu on Discord (Kimi Code 2.2.0, Windows): Kimi Code's own provider
gives K2.8 Preview and K3.1 Pro the capabilities thinking,
always_thinking, image_in, video_in, tool_use and
dynamically_loaded_tools; through magpie they had thinking, image_in and
tool_use, so Kimi Code offered a thinking switch the models refuse to
turn off, and started K2.8 on high where Kimi's own starts it on max.
Kimi Code 2.4.1's managed provider (packages/oauth managed-kimi-code.ts,
capabilitiesForModel) derives them from /coding/v1/models:
supports_thinking_type "only" -> thinking + always_thinking,
supports_dynamic_tools -> dynamically_loaded_tools, supports_video_in ->
video_in, think_efforts.default_effort -> the default. magpie now reads
the same fields (flat, or nested reasoning.type, tools.dynamic_load,
reasoning.effort.default) into catalog.Model (AlwaysThinks,
DynamicTools, DefaultEffort; kimiFacts), carries them through
provider.Entry and the agent's model list, and the new Kimi Code's table
gets always_thinking, dynamically_loaded_tools and default_effort at the
vendor's default (else high, as before). Only Kimi's list sends these
fields, so another vendor's model is written as before; kimi-cli, which
refuses unknown words, gets none. A routing group has none of them.
default_effort is now recorded in the stash as magpie's (kimiOwn), so a
level the user picked stays while the model has it. A table with high
and no record is read as the high magpie wrote before it kept one, and
becomes the vendor's default (max on K2.8, high on K3/K3.1).
Left out:
- video_in: with type="kimi" Kimi Code uploads a video to
{base_url}/files (purpose=video) and sends the ms:// id. The gateway
has no /files route, and the id belongs to the account that stored it.
Filed as #4485.
- dynamically_loaded_tools works (Kimi Code's tool select is behind
KIMI_CODE_EXPERIMENTAL_TOOL_SELECT): the loaded tools' system message
is lifted into the request's tools (liftMessageTools, #2322), so they
stay callable (TestKimiCodeLoadedToolsReachKimi), but each load
restarts Kimi's prompt cache. Filed as #4486.
- max_output_size: Kimi's own provider writes none; magpie keeps writing
the model's known reply cap (32768 on K2.8 per models.dev), unchanged.
This also covers #3399 (K3.1 offered thinking off): Kimi's list says
"only" for both K3.1 models.
Real list: tests read Kimi's /coding/v1/models reply of 2026-10-31
(internal/catalog/testdata/kimi-code-cn-models-2026-10-31.json, read
with the owner's kimi-code-cn key, no key in the file).
Run (mote, at this commit on origin/main b62fa332f; the agent-wiring.md
line was added after the run, docs only):
- go test -tags nogui -count=1 -timeout 45m ./... : 79 packages ok;
internal/proc (TestNoCommandBypassesProc) and internal/sqlitedb
(TestOnlyThisPackageReachesSQLite) red on a Go module cache my e2e
sandbox had left inside the run folder (vendor files under
e2e-kimi/sb/home/go/pkg/mod); with it removed both ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... ok; gofmt -l clean.
- Real Kimi Code 2.4.1 (npm) in a sandbox HOME/KIMI_CODE_HOME on mote,
with a sandbox magpie serve (MAGPIE_ADDR 127.0.0.1:34652), the
kimi-code-cn preset pointed at a fake upstream that serves the real
list: magpie wrote the six tables (K2.8: thinking, always_thinking,
image_in, tool_use, dynamically_loaded_tools, support_efforts low/high/
max, default_effort max; K2.7 Highspeed without
dynamically_loaded_tools), Kimi Code took the config, and `kimi -p`
reached the upstream with thinking enabled and reasoning_effort max
(K2.8) and high (K3.1 Pro).
- Rebased onto 43966a53f..f2eb56c6b (claude, GUI budget, usage; none of
them touch these files) as f5a82f215, then again at this head:
internal/agent, internal/catalog, internal/provider ok, internal/gateway
-run 'Kimi|MessageTools|Lift' ok. The full suite was not rerun there.
Broken by hand, each red then green:
- kimiFacts not called: TestFetchKimiCodeFacts and
TestKimiCodePlanCapabilities red.
- fields not carried in route.go / entryFor: TestKimiCodePlanCapabilities
red.
- the unrecorded-high rule off: TestKimiCodeOldHighBecomesTheVendorsDefault
red.
- always_thinking without the !legacy guard: the kimi-cli case red.
Not tried: the TUI picker by eye (that the thinking switch is gone);
tool select with a real MCP server and the experimental flag; Windows
(the reporter's system; nothing here is OS-specific); a real Kimi
upstream through magpie (the list was real, the chat was a fake).
|
||
|
|
43966a53fb |
claude: a subscription's run is Claude Code's interactive mode, -p only as the fallback
The owner (10-31): a Claude subscription ran `claude -p`, whose
requests Anthropic labels sdk-cli and counts at about twice the
interactive mode's cli (anthropics/claude-code#97074). Running the real
interactive Claude Code is what its terms describe and uses the plan as
a person does. Wanted inside magpie, on by default, with a way off.
`magpie claude-tui-helper <claude> <-p args>` (internal/claudetui)
stands where `claude -p` stood and speaks the same stream-json. It
turns the -p arguments into the interactive mode's (no -p, no
--dangerously-skip-permissions: --permission-mode default with only
mcp__magpie, and the WebSearch -p was given, allowed; --no-chrome;
--session-id or the --resume given), starts Claude Code in a
pseudo-terminal of its own (no tmux), pastes each message into its
prompt and presses Enter, and tells the session's transcript back as
-p's lines: whole assistant messages, an API error as the turn's error
result with its rate_limit_info, turn_duration as the result. Nothing
sets CLAUDE_CODE_ENTRYPOINT, and the user's ~/.claude and
~/.claude.json are never written. The folder-trust question is
answered only for magpie's own folder or a saved account's config
directory (MAGPIE_CLAUDE_TUI_TRUST).
A Claude Code that doesn't start or show its prompt in 45s becomes
`claude -p` on the same pid, its input still unread, so the turn is
answered all the same; that is remembered for 30 minutes
(<cache>/magpie/claude-tui-broken). An untrusted folder goes to -p
without the mark.
claudeTUI keeps -p for Windows and WSL, Settings › Models › Replies ›
Claude Code's interactive mode Off (claudePrintMode), safeguards,
client cache marks, a JSON schema, images and a first message over
400KB. A TUI run ends instead of taking an image turn, a rewind or an
effort change, and letGo doesn't take one back. The gateway's tests
run with claudeTUIRuns off: their binary has no claude-tui-helper.
docs/subsystems/claude-subscription-bridge.md has the section.
The core's scripts grow 725 bytes with the setting's row;
coreScriptBudget is raised to the exact size, 1,537,356, with no room
added.
Run (rebased on
|
||
|
|
b62fa332f3 |
provider: Send requests unmasked for subscriptions and plugin providers too (isee1_1)
isee1_1 on Discord uses a community translation plugin as a provider and asked why "Send requests unmasked" (请求不脱敏) isn't offered for it. |
||
|
|
7bc602236b |
library: the MCP hub is called the MCP router
The owner asked why it was a "hub". Composio calls the same thing a Tool Router; "router" says what it does (one server that routes each call to the right one), and "gateway" is taken by magpie's LLM gateway. Only the words change: MCP router / MCP 路由 / MCP 路由 / MCP ルーター / MCP-Router, "Router address", and the CLI's `magpie library mcp router on|off`, where `hub` still works. The URL /mcp/magpie/hub, the mcpHub setting, the servers/hub API and the Go names stay, so nothing a user or an agent config holds changes. docs/subsystems/mcp-hub.md moves to mcp-router.md and the pages that link it follow. #4382's new words follow too: "Through the MCP router", "Not through the router" and their hints in every language, and the CLI's `magpie library mcp router <name> shared|direct` (`hub` works there too; library_hub_test.go says router for direct, hub for shared). Run at e2583df31 (this stack on |
||
|
|
b78b1de003 |
library: magpie-image is behind the MCP hub, saving into the calling agent's project
magpie-image was the one MCP server the hub left out, because it saves what it makes on disk and needs to know whose project that is. The hub now serves its tools like any other server's and tells it where the caller works: 1. the hub answers a tools/call as SSE and asks the agent roots/list on that stream (3s), as Claude Code answers; 2. else Codex's _meta x-codex-turn-metadata.workspaces (git repos only); 3. else the Codex thread's cwd from its session file (sessions.CodexThreadCwd), only with session consent; 4. else none, and the image goes to ~/Pictures/Magpie as before. The hub passes `magpie/roots` and `magpie/client` in the call's _meta; imagemcp saves into the first root and names the agent on its usage row. Its result carries `magpie/model`, which the hub's own usage row takes, so the row says which image model drew it. A WSL agent keeps magpie-image as its own entry (the hub can't reach a path inside the distro). docs/subsystems/mcp-hub.md (mcp-router.md after the next commit), gateway-routing.md and gateway-sessions.md say so. It is rebased on #4382 ( |
||
|
|
d77da5bff3 |
claude bridge: a caller elsewhere whose environment is a message is told the last one given is where tools run
packinggoods on Discord, again after v0.1.2093: a Mac Claude Code through a Windows magpie's Claude subscription still has its commands wrapped in PowerShell. The bridge's run is the real Claude Code on the Windows box, and it puts its own environment (Platform: win32, its shell, a temp folder) in a <system-reminder> at the start of the run's first message. |
||
|
|
2570efb5f7 |
gateway: an image the picked model can't describe is described by the next model that sees (kelvinjason11 on X)
kelvinjason11 on X: "图片识别好像只支持一个模型识别 没有fallback". When
the describer (Settings' Image recognition model, or AutoVision's pick)
failed, the turn failed with it, though other models that see were there.
Now describeWith asks the pick first, always. When it fails for any reason
but the client's own cancel, magpie asks the next model that sees: the
first ready one of seersRanked, AutoVision's own order (ready, then
Claude account, Codex, API key, other, then cost), leaving out each model
already tried and each one that turned an image away (sightRefused). At
most 3 models (visionTries), and all of them within visionWaitMost
together: each try gets what is left of it, not a fresh visionTimeout.
- The text header names the model that described the image
("as other/bigeye describes it"), not the pick.
- The Routing row of the stand-in carries Instead, Why and Picked
(describingInstead, the same fields web search's searchingInstead
sets), and the Routing page says in every language that the pick
couldn't describe it, why, and which model did instead.
- When none answers, the error is the first failure as before, then
"nor could X, asked in its place: why" for each other model tried.
- Spent/allowance: each try goes through serve as before, so autoSpent
and spentModel judge every stand-in the same as they judged the pick.
- vision_mcp's describe_image tool gets the same fallback.
Cache (s.sights): a description is kept under the pick and the image,
whichever model described it, with the describer's name beside it. The
same image sent again asks no one, the stand-in's text is reused, and
its header still names the stand-in. A new image asks the pick first
again, so a pick that comes back is used at once. Failures are not kept.
Settings' text ("When the model in use can't see images, this one
describes them to it") is left as it is: the pick is still asked first
for every image.
Tests (internal/gateway/vision_fallback_test.go):
- TestPickedDescriberThatFailsGivesWayToTheNextThatSees
- TestAutoDescriberThatFailsGivesWayToTheNext
- TestNoDescriberAnswersNamesEach
- TestPickedDescriberThatAnswersIsTheOnlyOneAsked
- TestCanceledDescriptionAsksNoOther
TestDescriberThatCantSeeIsntAskedToDescribe now expects the next model
that sees to describe in place of a text-only pick, not a 502.
GUI: internal/gui/tests/vision-instead.test.cjs (every language, 1100
and 520 wide).
Run on mote at 45739f15b (this tree, on origin/main
|