53c81a2700a96944faf00a71a3829406aa922278
6647
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
53c81a2700 |
redact: 白名单 is read as a word, not a name (tianyk, #4087)
With the local model on, 白名单 went out as a name placeholder 821 times
in three days: the model took it for a name, and the reader's list of
ordinary words (zhWords, zhNounEnds), which every Chinese-name find is
checked against (zhWordNotName), had no word for it. 白名 is now in
zhWords and 单 in zhNounEnds, so the model's find goes as written and
never becomes a known value.
Of the report's other rows: node_modules and 连续 are already left as
written at this tree (probed with a fake model finding each as a name
and a path). 时按 and 时隐藏, the model's finds cut across two words
(超时+按住, 超时+隐藏), are still masked; this change does not cover them.
Changed from the contributor's patch: its second half, a gate in
knownSpans that let a known PERSON value go wherever it reads as a word,
is not taken. Every PERSON finder already asks zhWordNotName, so the
only values that gate let go are names masked where a role said a person
was meant: with it, "联系人:白名单" masked and the next request's
"白名单说明天到" went out as written. The test now checks that case and
resets the known values around itself.
Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok), -shuffle=on ./internal/redact/ (ok);
go vet -tags nogui ./internal/redact/...; gofmt -l (empty).
Broken by hand: with the old zhname.go, TestModelMisreadsNotMasked and
TestKnownWordTakenForANameGoesAsWritten fail (开启{{PERSON_…}}之后);
with the patch's knownSpans gate put back, TestKnownWordTakenForANameGoes
AsWritten fails ("a name masked once left as written: 白名单说明天到").
Not tried: the reporter's real AstrLink Guard model on their requests.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
e4b0555a17 |
redact: a timestamp under a token's field name is not masked as a secret (#5002)
"access_token_expires_at": "2026-08-30T11:44:31.312645+08:00" went out as
"{{SECRET_…}}:44:31.312645+08:00": the field's name has token in it, and
the SECRET rule took the timestamp's head up to the hour (its colons are
not a secret's characters), so 2026-08-30T11 was masked and the rest was
sent as written. The same happened after 令牌是, 密钥为, token 是,
SERVER_KEY: and DB_PASS:, and in a tool call's arguments the whole value
was masked by its field's name (namedSecret).
An RFC 3339 timestamp, whole or its head to the hour, is now left as
written there (timestampValue, beside versionValue and pathValue in
fieldAt, keyAt and namedSecret). The exemption is by the value's shape,
not the key's name: a value that only starts as a timestamp
(2026-08-30T11x9k2abc) still masks, and a secret beside the timestamp in
the same tool call still masks.
Changed from the contributor's patch: the patch deleted fieldAt's doc
bullet for the next-field rule (nextField), which still exists; it is
kept.
Run (mote): go test -tags nogui ./internal/redact/... ./internal/pii/...
./internal/masking/... (ok); go vet -tags nogui ./internal/redact/...;
gofmt -l (empty).
Broken by hand: with the old fieldvalue.go, json.go and redact.go,
TestTimestampIsNoSecret fails on the reporter's line with the same
output as the report ("{{SECRET_2ojutfrk}}:44:31.312645+08:00") and on
the other lines.
Not tried: the local masking model on the reporter's whole request.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
0f0484c515 |
davsync: a WebDAV server that breaks on a conditional read is read without one (123pan, #4993)
After the first sync, magpie reads the backup with the version last seen
(If-None-Match, or If-Modified-Since on a server without ETags) so an
unchanged file costs a 304, not a download. 123pan answers that GET 500
after about 30 seconds (the reporter's curl: a plain GET 200, HEAD 200
with a valid ETag, GET with If-None-Match 500), and every sync failed
with "reading magpie.magpie-backup from the WebDAV server: HTTP 500".
A conditional read answered 5xx is now asked again without the
conditions, and the version is marked NoCondRead (kept in the sync
state), so that server is not asked with a condition again. The ETag the
plain read returns is still sent as If-Match on the write, so a write
from another computer in between is still refused as changed. A plain
read that fails is reported as before.
Changed from the contributor's patch: the mark is set on every version
a plain read returns, not only on the fallback read's. In the patch a
sync that read plainly saved an unmarked version, so every second sync
sent the condition again and waited 30s for the 500. The sync test now
runs three more syncs and checks no condition is sent, and checks that
the merged write carries the plain read's ETag as If-Match.
Run (mote): go test -tags nogui ./internal/davsync/ (ok, 56s);
go vet -tags nogui ./internal/davsync/; gofmt -l (empty).
Broken by hand: with the fallback disabled, both new tests fail with the
reporter's own error ("reading magpie.magpie-backup from the WebDAV
server: HTTP 500"); with the contributor's version of get,
TestSync123panConditionalRead fails ("3 conditional GETs after more
syncs, want 1").
Not tried: a real 123pan account (the fake answers as the reporter's
curl showed); whether 123pan honours If-Match on PUT (writes were never
reached in the report).
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
b33633d593 |
codexcat: every reasoning level in magpie-models.json says a description (#5024)
Codex fails the whole model_catalog_json on one supported_reasoning_levels
entry without a description ("missing field `description` at line 189"),
so Codex would not start. The entries magpie writes from a vendor's own
Codex entry (a sub2api's) kept the vendor's levels as written, the
description only where the vendor gave one, and levels made for an effort
of the user's the vendor doesn't list were {"effort": ...} alone. Every
level of such an entry now says a description: the vendor's own where it
gave one, else the effort's display name. Entries magpie makes itself
already wrote one.
Changed from the contributor's patch: the levels are read with a checked
type assertion. The patch's bare .([]any) panicked ("interface {} is nil,
not []interface {}") on a vendor entry with no levels for a model with no
efforts, which would have taken down the whole catalog write; the test has
that case now.
Run (mote): go test -tags nogui ./internal/codexcat/ (ok);
go test -tags nogui ./internal/provider/ ./internal/usage/ ./internal/catalog/;
go vet -tags nogui ./internal/codexcat/; gofmt -l (empty).
Broken by hand: with the old listedEntry, TestCodexListedLevelsSayDescription
fails ("level medium says description \"\", want \"Medium\"", and the
same for high, low, xhigh); with the patch's unchecked assertion it panics.
Real Codex (codex-cli 0.165.0, sandbox CODEX_HOME): a catalog whose levels
lack description fails "missing field `description`"; the same catalog with
descriptions loads and Codex starts.
Not tried: Windows (the reporter's OS); nothing here is OS-specific.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
ce2a59daa9 |
usage: the chart's tooltip says counts short, as the axis does (skyhuang1994)
The Usage page's bar chart tooltip wrote each row, the sum and the
request count in full (31,846,455 · 32,292,989). It now uses the page's
compact formatter: K/M in every language, 万/亿 (萬/億 in zh-TW) when
Chinese units are on. Cost and speed keep their long forms.
usage-compact-counts.test.cjs gets a chart point with the reporter's
numbers and hovers it in every language, at 1100px and 420px.
Run on mote:
- usage-compact-counts, chromium and webkit: 15/15 each.
- Related GUI files in both engines (gui-de/ja/zh-tw, i18n-keys,
number-units, panel-units-follow, panel-usage, quota-curve,
usage-chart-*, usage-ledger*, usage-speed*, usage-ttft-rounding,
usage-compact-counts, usage-model-at-provider, usage-sum-whole,
click-scroll): 674/681. The 7 reds are i18n-keys "a plugin's words
are its own" (#5332, #5426) and usage-ledger "newest live route needs
no return-to-live button" in both engines (#3104). Both are red the
same way at origin/main
|
||
|
|
e1d4dca967 |
gateway: a Chat reply's leading <thinking> block is read as thinking
A Chat reply may open its reasoning with <thinking>…</thinking> in the text. thoughtTags held only <thought> and <think>, so neither tag matched: chatDecoder.text took the block for the answer's own text and no thinking block went out (#5106). In a recorded day on one OpenAI-compatible host, 47 of 2832 turns carried a literal <thinking in the answer's text, 44 of them at offset 0 (neighbads). <thinking> is added beside the two, closed by </thinking>. It shares no whole prefix with <think> (they part at the seventh byte, 'i' against '>'), so the wait in text covers the shared lead and no lead can name two opening tags. markedThought reads the same map, so a Gemini-marked chunk opening with <thinking> is thought's text too. afterThought, which strips a leading block from the titles, descriptions and predictions Codex asks for (codex_titles.go), now reads the same map instead of its own <think>, so a <thinking>- or <thought>-led reply no longer leaves the block in a title (added in the port; the patch left it as a sibling). Run (mote): go test -tags nogui -count=5 -run 'TestChatThoughtTags| TestMarkedThought|ThoughtTag|TestAfterThought|Title|Description' ./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui ./internal/gateway/ clean. Broken by hand: chat.go put back to origin/main, the four <thinking> cases of TestChatThoughtTags FAIL and TestAfterThoughtCloseInCode FAILs on the <thinking> and <thought> leads. Not tried: a live model that sends the tag (the reporter's model sends it in about 1.7% of turns, not on demand). The plugins repo's think-tags middleware keeps its own list and is not changed here. The tag and the whole/split cases are neighbads' patch on their fork; ggbdpq added the open-tag-alone and never-closed cases. Fixes #5106 Generated-by: GLM-5.3-Flash (ZCode) Co-authored-by: neighbads <16126598+neighbads@users.noreply.github.com> Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
cbd379e1b7 |
gateway: a Gemini request's generationConfig keeps the fields magpie doesn't read (#3937)
parseGemini read a generationConfig of the fields magpie knows — maxOutputTokens, temperature, topP, stopSequences, the structured output ones, thinkingConfig, and, since #3820, imageConfig — and buildCodeAssistSent built one of the same, so a translated request (a Gemini client's generateContent asked of a Gemini API in one body, and every request to Code Assist or Antigravity) went upstream without the rest of what the client asked: topK, seed, candidateCount, presencePenalty, frequencyPenalty, responseModalities, mediaResolution, speechConfig, responseFormat (#3937, yinwu01). The request now carries the keys magpie doesn't read or write (Request.GenConfig), and one built for an upstream that speaks Gemini's own API — the Gemini one, and Vertex AI — is sent them beside what magpie rebuilt, as they were sent, camelCase and all (geminiCamel). A field magpie sets itself stands: a draw model is still asked for ["TEXT","IMAGE"] whatever the client's own said. Code Assist's and Antigravity's envelope is sent none of them: their spelling of these fields isn't documented, and no other API takes Gemini's names. candidateCount is not carried (changed in the port): magpie reads a Gemini reply as one answer, and codeAssistDecoder runs every candidate's parts into it, so a second candidate would be mixed into the first answer's text. It stays dropped, as before. Run (mote): go test -tags nogui -count=1 -run 'TestGeminiGenConfig|TestGeminiImageConfig|Gemini|Vertex|CodeAssist' ./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui ./internal/gateway/ clean. Broken by hand: gemini.go put back to origin/main, both new tests FAIL (nothing but magpie's own fields reached the relay); candidateCount taken out of genReadOrBuilt, the reporter's-fields and snake_case cases FAIL with candidateCount sent. Not tried: a live Gemini API or Vertex AI key (none here); safetySettings and cachedContent, top-level fields the issue also names, are still dropped on a translated request. Fixes #3937 Generated-by: GLM-5.3-Flash (ZCode) Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
104103b05e |
gateway: an images API size asks a Gemini image model past its 1K
An images API request (and the image MCP tool, which goes through it) for a Gemini image model had its OpenAI size folded into an aspect ratio alone, so the model drew at its default 1K and no size above 1K could be asked (#3936): drawGemini sent generationConfig.imageConfig without an imageSize, and drawCodeAssist sent no imageConfig at all. Both now build the imageConfig an images API size asks a Gemini image model for: the ratio the size is nearest, with an imageSize beside it when the size asks past the model's 1K default - the smallest of Gemini's buckets whose long side covers the size asked (2048 -> 2K, 4096x4096 -> 4K). Only 2K and 4K go out: a size at or under the 1K default is drawn at anyway, and imageSize isn't every image model's (Vertex lists 1K, 2K, 4K), so nothing is asked for what the default gives. drawCodeAssist carries it in Request.ImageConfig, the field a Gemini client's own imageConfig arrives in, which Code Assist's envelope already forwards. Chat completions is left as it is: OpenRouter's image_config documents an aspect_ratio only, and an undocumented field risks a strict relay's refusal. A Gemini 2.x image model (gemini-2.5-flash-image) draws at 1K only, and Google documents imageSize for the Gemini 3 image models, so a 2.x model is still sent the ratio alone (added in the port; the magpie tool's own example size, 1536x1024, would otherwise ask it for 2K). Run (mote): go test -tags nogui -count=1 -run 'TestImagesAPISize|TestGeminiImageConfig|TestAspectOf|TestAspectAmong|Draw|Antigravity' ./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui ./internal/gateway/ clean. Broken by hand: draw.go put back to origin/main, both new tests FAIL (4096x4096 sent {"aspectRatio":"1:1"}, Code Assist sent no imageConfig); the 2.x guard removed, the gemini-2.5-flash-image case FAILs with imageSize 4K. Not tried: a live Google API key or Antigravity sign-in (none here), so whether each back-end draws at the bucket asked is unchecked. Fixes #3936 Generated-by: GLM-5.3-Flash (ZCode) Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
766d2a9f54 |
gateway: a Claude turn sent again while its run is busy with it goes on from a copy of its session (#5405)
A client's connection dropped mid-reply and its request was retried, with no cancel reaching magpie (#5405, margbug01: a gateway between the client and the server magpie retried after "unexpected EOF"). The run the first attempt resumed was still busy with the very turn, so resume and unshelve found nothing, and the retry started a new Claude Code told the whole conversation in one message: only Claude Code's own system prompt and tools read from the cache, the rest (92K to 142K tokens in the report) written again on every retry. retryBranch, tried in start between unshelve and retire, finds a busy run of the account whose last heard request is this one, message for message, and starts the retry's run from a copy of that run's session cut before the turn (cutReply at backLine/backMsg), told only the turn, as a branch off a side question already is. The busy run is left alone; when both park at the same key, keepIdle lets the older go. nil, and the conversation told whole as before, when no run matches, the client places its own cache marks, the run was or is being taken back, it was started for this turn (nothing before the turn to cut at), or the session can't be cut (logged). Changed from ggbdpq's patch: it matched with follows, which also takes a request that goes on past the busy run's turn; the retry is matched by the heard request's key alone. A copy cut for an older run is discarded when a newer one is taken, a failed cut is logged as the patch's notes say, and a run with a reply id but no line yet is cut by the reply, as branchAt does. The test waits for the busy run to have heard the turn instead of sleeping 200ms, and stops the held first attempt in t.Cleanup, so a failing assert doesn't leave it running. The doc's "goes on to step 3" now says step 4. Run (mote, -tags nogui): - TestClaudeTurnSentAgainWhileItsRunIsBusyBranchesOffItsSession (print, interactive) -count=3: ok. - Broken by hand: claude_subscription.go back to origin/main, test kept: FAIL in both modes, "0 runs branched, 2 started anew, want one of each". Restored: ok. - TestClaudeTurnPastABusyRunsTurnIsNotBranchedOffIt (print, interactive): a turn sent past the busy run's own, with a reply the client has, is told whole (one message, or the interactive mode's transcript), not branched off the busy run. -count=3 with the other test: ok; -race -count=5 of both: ok. - Broken by hand: the match back to follows: FAIL in both modes, "the turn past the busy run's was branched off it" (nextTurn gives its run only "now commit it", the turn and reply before it lost). Restored: ok. - -run TestClaude ./internal/gateway/: ok 139s. - -race -count=5 -run of the busy-retry, fork, side-question, given-up, rewind, unshelve and branch tests: ok 52s. - go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of internal/gateway: clean. - gofmt -l on both Go files: empty. Not tried: a real Claude subscription with a real dropped connection. The full suite runs after the push. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
1493acb468 |
gui: Codex's memories default reads right on Codex 0.167.0 and before
Codex 0.167.0 (openai/codex#58091) moved its default memory models:
extraction from gpt-5.6-luna to gpt-6-luna, consolidation from
gpt-5.6-terra to gpt-6.1-terra. The memories square's unset text and the
Settings row's tooltip named the old pair. They now say "Codex's own
memory models", true on either version, in en, zh, zh-TW, ja and de.
The code comments (agent/codex.go, gateway/codex_memory.go,
gateway/codex_follow.go, the tests' headers) name both pairs with the
Codex version that uses them. No behaviour changes: magpie routes these
calls by kind (memgen, memory_consolidation), not by the model name.
Run on mote at the pre-rebase base
|
||
|
|
859b292d91 |
gateway: the Qoder plugin's queue answer ends a group's patience rounds (#5346)
#5346, hardy20260000: a Qoder route of 217 accounts (routing=order) asked one request up to 656 times, 20 GB of re-uploaded bodies a day. When magpie has another candidate, the Qoder plugin answers Qoder's queue code 10605 at once with a 503 + Retry-After (#4049). busy() took that for a moment's trouble, so once every member had given way the group's patience asked all of them again, one whole round after another, re-sending the body on every account each round. Now busy() leaves the plugin's queue answer alone: each member is asked once, and the last one, asked untold, has the plugin wait the queue out as Qoder's own client does (polling its queue status, not re-sending the body), then gets its same-one retries. Changed from ggbdpq's patch: it matched `\bqueue|排队` in any provider's 5xx. A relay's "Request queue is full" or "当前排队人数较多" is the overload a pause mends, and would have lost its patience. The match is the plugin's own words now ("queued the request", "this plan's queue:"), and the tests use the plugin's real errorResponse body for both its forms (isQueued, and the service out as in testdata/qoder_queued_10605.json) instead of an invented message. Not changed: the walk itself. With patience=off (the reporter's setting now) a request still asks each account once until one answers, ~20x on this route; that is the routing group finding a free account, and a per-request attempt budget is a separate decision. Run (mote, -tags nogui, sandboxed by the package's TestMain): - TestQueuedGroupAsksEachMemberOnce/{queued,busy}: 5 asks, 503 told. - TestOverloadedGroupStillReplans/{overloaded,queue full,排队}: ok. - Broken by hand: without `!queued(body)` both queued cases FAIL "a queued group asked 39 times, want 5 at most"; with the patch's broad regex, "queue full" and 排队 FAIL "asked 5 times, want more than 5". Restored, green. - -run Queued|Overloaded|Plugin|Qoder|Patience|Replan|Single|Busy| Fallback|Nested|Affinity|Codex busy|Shared|Retry: ok. - gofmt -l clean; go vet -tags nogui, GOOS=linux -tags nogui and GOOS=windows vet of internal/gateway: clean. Not tried: a real Qoder queue on a many-account route; the full suite. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
baf70992f6 |
usage: a call the vendor answered with another model is priced as the model that served it (#5340)
The ledger priced a call at the model asked for and fell back to the
model the reply named (Served) only when the asked-for one had no price
(#1498). That order is right for a relay that sells kimi-k3 as
moonshot-kimi-k3 and bills by the name it sold, but it also priced a
real substitution: claude-opus-5-5 asked, claude-opus-5 served. The
vendor bills for the model that ran. kaimo455's ledger had 836 such
rows, every one at the asked-for rate: $374.06 reported against
$493.28 at the served model's rate. gateway-key cost limits (KeySpent,
NewCoster) and budgets read the same pricer.
Pricer now prices a call the ledger marks swapped at the served model's
price. That covers a price the user set for the served model and every
other layer of BasePriceIn. A price the user set for the model asked for
still wins, 0 included (new provider.UserBasePriceIn is BasePriceIn's
user layer alone). When the served model has no price, the asked-for
one's stands. Renames, vendor aliases, serving names and region
deployments price as before, and rate windows still read each record's
own time. apiPricer, the API price behind a subscription window's whole,
follows the same rule: the served model's API price first, then the
asked-for one's.
Review changes on top of ggbdpq's patch:
- The swap is judged the way the ledger's Swapped column judges it: on
the model id and on the name that went out (SentNameIn over the
user's ModelWires). A model the user sends under the served one's name
was answered as asked, so it keeps its own price. The patch judged the
model id alone, so such a row was priced as swapped while the Requests
page said it wasn't. The pricers' memo keys now include the effort,
because the sent name depends on it.
- apiPricer (window holds) got the same rule. The patch left it on the
old order.
Tests:
- TestLedgerPricesASwappedCallAsTheModelThatServed (patch, plus a
ModelWires case) checks the ledger and the Requests page.
- TestLedgerPricesARenamedModelAsTheOneServed: the sol row (sol asked,
kimi-k3 served, both priced) is a genuine swap, so it now prices at 3,
not 2.
- TestHoldsPriceTheModelTheReplyNamed: claude-opus-4-7 answered by
gpt-5.5 is priced at gpt-5.5's API price. Answered by an unpriced name,
it keeps opus's.
Run on mote at this tree, on origin/main
|
||
|
|
bfb0d92ca8 |
gateway: a ToolSearch answer's definition goes to DeepSeek as the reference it takes (#5404)
Newer Claude Code builds put the loaded tool's definition itself in the
ToolSearch answer's tool_result.content[] ({"type":"tool_definition",
"definition":{...}}, the same block shape Claude Code's own bundle
handles beside tool_reference). DeepSeek's Anthropic endpoint refuses
it there: 422 "messages[1].content: unknown variant `tool_definition`,
expected `tool_reference`". withoutDeferredTools walked the messages'
top-level blocks only, so the nested definition survived every learned
retry, and a body with no top-level deferred block never learned the
refusal at all.
hasDeferredTools now sees a tool_definition in a tool_result's content,
and withoutDeferredTools hoists each such definition onto the request's
tools (once; one already listed wins) and sends the block as
{"type":"tool_reference","tool_name":...}, which the endpoint takes only
once the tool is declared. A result whose content isn't an array, or a
definition without a name, goes as it came. DeepSeek's own host
(isDeepSeekAnthropic, by host, not preset) now gets the deferred blocks
stripped up front like Kimi (#2042), since it takes a tool_addition at
no position (erlinerd's live check of 2026-11-05).
Review change on top of ggbdpq's patch: added
TestDeepSeekAnthropicIsStrippedUpFront, which drives a provider at
api.deepseek.com (dial redirected to httptest) through the server; the
patch had no test for the forwardOnce wiring.
Run (mote, -tags nogui, -count=1):
- TestToolResultDefinitionRefusedOnceBecomesReference,
TestNestedToolResultDefinitionBecomesReference,
TestDeepSeekAnthropicRecognized, TestDeepSeekAnthropicIsStrippedUpFront:
PASS.
- -run 'Deferred|Kimi|DeepSeek|ToolSearch|ToolReference|RefsOnly|OpenCode|Shape'
./internal/gateway: ok 18.3s.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
of ./internal/gateway: clean.
Broken by hand:
- anthropic_shapes.go at the parent: the refused-once test 422s to the
client, the unit test fails "a nested tool_definition was not seen as
a deferred tool", the up-front test 422s.
- gateway.go at the parent: TestDeepSeekAnthropicIsStrippedUpFront fails
"DeepSeek was asked 2 times, want once".
Not tried: a live api.deepseek.com request (no DeepSeek key here); the
endpoint's answers are the reporter's live checks. Not run: the whole
gateway package or ./... suite.
#5404, erlinerd.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Co-authored-by: erlinerd <10431861+erlinerd@users.noreply.github.com>
|
||
|
|
d84f58fd2b |
claude bridge: Claude Desktop's own annotations are not the user's words (#5403)
Claude Desktop's Claude Code appends notes of its own after tool
results: the scaling note a wide Read gets ("[Image: original 2200x680,
displayed at 2000x618. Multiply coordinates by 1.10 …]"), the Skill
tool's "Base directory for this skill: …" and ToolSearch's "Tool
loaded.". The bridge took each for words the user sent mid-turn, so
the run was told "The user sent a new message while you were working:"
with the note, and the next turn's history marked it [user message].
The model answered messages nobody wrote (#5403, miroku9: about 30
such notes in 13 sessions, two answered).
They join agentNotice, the table #2060 built for hook notices and
token counts, so saidWithResults leaves them out and renderParts
closes the result without the [user message] mark. Wide images read
in parallel bring one note each; miroku9's inner-session queue shows
them joined by blank lines, so the image branch matches one or more
notes (with "Tool loaded.") separated by whitespace, both as one text
and as separate parts. A user's own words after a note still go on.
Patch from ggbdpq; the parallel-notes case and its test are added
here, after miroku9's follow-up on the issue.
Run (mote-run, go test -tags nogui ./internal/gateway/):
- TestDesktopAnnotations*, TestParallelImageNotesAreAgentNotices,
TestAgentNotice*: with claude_subscription.go at origin/main all four
new tests FAIL ("… was taken for the user's words", "[user message]"
before the note); with the fix ok.
- With the patch's single-note regex, TestParallelImageNotes FAILs on
the joined text only (the separate-parts case passes).
- -run 'Notice|MidTurn|SaidWith|RenderParts|UserWords|Claude': ok 74.8s.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
of internal/gateway clean.
Not tried: a live Claude Desktop + inner Claude Code pairing; the note
shapes are the reporter's jsonl verbatim. userWords (routing's view of
a user text) is unchanged: these notes only follow tool results, where
routing doesn't start a turn. A new kind of note from a later Claude
Code needs its own line here.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
5ca9f0f9d7 |
sessions: a ZCode fork's card shows its own title (#5365)
ZCode files a fork as sess_<id> with its parent's id in parent_id (task_type=fork), and ocRoots groups it under the parent's key. A request names the fork by its own id, but Titles only looked up sess_subagent_agent_<id> children, so a fork's Routing card fell back to the folder name though its row has a title of its own. The child index in Titles now holds every ZCode session with a parent, by its sid and its bare id (zcodeBareID), so a fork is named from its own file the way a subagent is. A top-level session is still named by its own group only. The parent's title is unchanged. Changed from the patch: the index holds child sessions only (the patch indexed every ZCode session, so a top-level session's empty group title could be filled from the cache fallback), and the "session_" prefix the patch also stripped is dropped, since no ZCode id has it. Run (mote, sandbox HOME via the package's TestMain): - go test -tags nogui -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok. - go test -tags nogui ./internal/sessions/: ok (20.7s). - go test -tags nogui -run TestSessionTitlesNameOtherAgents ./internal/gui/: ok. - GOOS=linux go vet -tags nogui and GOOS=windows go vet ./internal/sessions/: ok; gofmt -l clean. - Windows box (win-run): -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok. Broken by hand: with origin/main's sessions.go, TestZCodeForkTitlesByRequestID fails: fork by request id: "", want "Fork of The parent session's title". Not tried: a real ZCode database here (none on this machine); the reporter ran the patch against theirs on Windows and got the fork's own title and the parent's. #5365, Flandern1211 (report, patch, test). Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com> |
||
|
|
cf15d79d7f |
gateway: a relay's Gemini refusing a tool's anyOf beside a description hands the request to the group's next member (#5374)
Google's Schema takes an anyOf alone: a tool whose parameters carry a
description beside an anyOf is turned away with "Unable to submit
request because `tool` functionDeclaration `parameters.response` schema
specified other fields alongside any_of. When using any_of, it must be
the only field set." Asked straight, Google points at
function_declarations[N].parameters, which shapeWords reads. A relay
(sub2api, TokenFree) passing Google's words on writes them camel-case,
the field in backticks and no path, so the 400 went back to the client
and the group's later members, a non-Gemini fallback among them, were
never asked (#5374, worksyang, with the two-channel comparison and the
one-line fix).
shapeWords now also reads "schema specified other fields alongside
any_?of" (any_of and anyOf). The next member is asked once and the relay
doesn't rest (failShape), as for every shape refusal. A plain "messages:
field required" and Google's "Invalid function name" 400 stay the
request's.
Run (mote, testenv sandbox HOME):
- TestGroupFailsOverAnAnyOfSchemaRefused with fallback.go put back to
|
||
|
|
4e7661adce |
redact: an app's one-word name the model took for a person's goes as written
Reported by ylorn. on Discord (11-06): choosing apps in Alma, a question
about one app was answered with another's facts. Privacy Filter took the
apps' names (Cicada, Mimi, Phosphor, Parakeet, Muesli) for people's: in a
bare list of them, alone, and in the Markdown list of apps the assistant
answered with (probed on the real model: ~0.99 each). The follow-up
questions ("How about Mimi?", "Phosphor vs Parakeet") it did not flag, so
they went as written while the history held the names as placeholders;
Phosphor and Parakeet (8 bytes) then became known values and were masked
everywhere. The vendor could not tell which placeholder was which app.
Restore was not the cause: placeholders are a keyed hash of kind and value,
one per value, and restore maps each back to its own value in any case
(TestManyNamesRestoreEachToItself, a guard: it passes on the old code too).
personFits now lets one ASCII word go when what is around it says a thing
and nothing says a person (thingNamed, internal/redact/thingname.go): a
person's word beside it (my colleague, Hi, Mr, said, told) masks; a thing's
word beside it (using, switched to, the ... app, vs, apps like, 这个软件)
lets go; else its sentence decides (he/she/relations/greetings/said mask;
app/macOS/subscription/vs/软件 let go); else a list item among items that
speak of apps, or a text of capitalized names only, lets go.
Trade-off, by design: a single first name alone, or a first name in a
sentence that speaks of an app with nothing of a person ("Mimi uses the
app daily"), goes as written. A full name (John Smith), a Chinese name
(张伟), and a first name beside a relation, a greeting, said or a pronoun
are masked as before.
Run (mote, worktree at
|
||
|
|
8b70b7d976 |
usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now keeps what each request received back (down_bytes) beside what it sent up (up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the upload (image_files_saved). Shown in Usage → Requests: - a row's details: "Sent upstream", "Received" and "Saved by image files", each only when it is above 0. A row from before has none of them, not 0; - under the Requests card, the period's "↑ up · ↓ down", with "{n} saved by image files" when there is a saving. Its title gives the exact bytes. A period with no counted bytes shows no line. What is counted: - Down bytes are counted as the reply body is read, after Go's transport has undone gzip, so a gzipped reply counts its plain size, not wire bytes. A plugin's row counts the local hop to the plugin host. A 101 body is not wrapped. Every try counts, so a refused try plus the answering one add up (TestLedgerKeepsDownBytes). - Image files saved, per try: the body before the swap minus the body sent, minus the upload bytes this request itself paid (len(b64)/4*3). It can be negative on the turn that uploads; the GUI shows only a saving above 0. Gaps: an upload that finishes after the wait timeout or ctx-done is not subtracted (as with up_bytes); a joined upload flight is paid by the request that started it; multipart overhead is approximate. - packedRow grows by three int32 (152 bytes, still within the test's bound), clamped to the int32 range. Totals sum all three. - settledCountVersion goes 1 → 2, because Totals now count bytes. The settled page, heat and effort caches recount once, on the first start after the update. The heat key hash includes the new fields. Run on mote at |
||
|
|
84ad780b65 |
gui: DeepSeek's image-files setting in the provider editor's Advanced (#5407)
matrix0487 on Discord (#feedback, 11-05) asked to change image-files from
the GUI:
|
||
|
|
ef176e21f6 |
sessions: a Claude Code session moved with /cd is listed under its new folder
usrname1833 on Discord (#feedback, 11-05): after Claude Code's /cd the
session's file is in the new folder's .claude/projects directory, while
magpie kept showing the session under the folder it was started in.
What /cd does (Claude Code 2.1.316, read in the binary and run for real
in a sandbox CLAUDE_CONFIG_DIR against a fake API): relocateSessionTranscript
renames projects/<old>/<id>.jsonl and its <id>/ folder to
projects/<new>/, and appends {"type":"relocated","relocatedCwd":"<new>"}.
The lines from before keep the old cwd; a second /cd adds another line,
and the last one names the folder.
Cause: a Claude Code session's folder was its first line's cwd only, and
a relocated line went to the default case. Every place that groups or
resumes by folder (GUI, TUI, `magpie sessions`, stats, the resume
command's cd) reads Session.Cwd, so all of them showed the old folder.
- claudeLine reads the relocated line (ccRelocated): the last move's
folder is the session's.
- A parse kept by an earlier magpie isn't read again when the file
hasn't changed. One whose folder isn't the project folder the file is
in (ccStale, with Claude Code's own name: non-alphanumerics as "-",
past 200 cut and a hash added) is read again once. state.CdRead marks a
parse made by this reader, and a kept one in its right folder is marked
on the first refresh, so the name isn't worked out on every poll.
parseVersions isn't raised: that would read every Claude file again.
- A glance (a long file's row before its first read) takes a relocated
line in the last 64 KB too.
- Sibling, magpie's own project move (relocateClaudeJSONL): a /cd'd
session was judged by its first cwd, so moving the folder it was moved
to failed with "a different project cwd", and relocatedCwd was never
rewritten. It now judges by the last move and rewrites relocatedCwd.
- docs/subsystems/gateway-sessions.md says how the folder is found.
Fixtures (internal/sessions/testdata/claude-cd) are Claude Code
2.1.316's own lines from that run, paths written as /w, without request
records, attachments and file snapshots.
Run (mote, at
|
||
|
|
a754660b2a |
gateway: requests that come together spread over a pool's accounts (#5242)
Moody-Sin and Tericerice (#5242, magpie 0.1.3072 on Linux): an antigravity provider with three accounts and affinity turn sent four requests at once all to one account, under In turn and By pace alike, each request with its own X-Magpie-Session. Cause: - Nothing counted the requests in flight when a request was planned. Pace (internal/routes/strategies.go:348) goes by pace, wallet and Tokens, all of which move only once a reply ends; a key's lane counts a request only once its try starts, after planning. Requests that came together were planned on the same figures and all went to the first. - In turn's next turn (affinity.go:685 "new-turn" → after(), :937) reads a stick that moves only when an answer comes back, so a burst of turns of conversations already answered all went to the one next account. - conversationID (gateway.go:9160 on origin/main) ignored X-Magpie-Session, so callers that named their own sessions but opened alike were one conversation and kept together. Fix: - burst.go: burstSpread, called in serve once the candidates are planned (gateway.go:3013), counts each request on the account it goes to until it ends, and puts first, among the accounts routing would as soon pick (burstAlike: In turn any ready one; By pace a pace within a tenth, no wallet told apart, none near its cap; Least used within a point), the one with the fewest in flight. A kept conversation (session, turn's stick, strict), a pin, a lead's account, a checkpoint and a new conversation leastHeld spread are counted where they are, not moved. Fallbacks, reserved, aside, resting, held, barred and capped accounts, other routings (Smart, In order, ...) and a group in a group keep their order. In a group, a member routed its own way is alike only to its own provider's. The one step covers direct models, groups, plugin providers and a remote magpie. - affinityID: the stick key (stickKey), a group rule's key (ruleKey) and the sealed lead's stick read X-Magpie-Session after an agent's own session header. conversationID, which Kilo and a plugin are sent as the conversation, is unchanged, so the caller's session never goes upstream. - docs/subsystems/gateway-routing.md says both. Not done: putting a markedly slower account behind by its TTFT. A first token's wait goes with the prompt's size and the vendor's queue more than with the account, so a small sample would move turns away from a fine account and off its cache; it needs its own design. Run (mote, mote-run): - go test ./internal/gateway -run 'TestABurst|TestBurst|TestMagpieSession| Kilo|Sealed|Rule|Stick|Affinity|Conversation': ok - go test ./internal/gateway ./internal/routes: ok (654s, 0.3s) - GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok; gofmt -l: clean New tests (burst_spread_test.go): six at once over three keys, rotate and pace × affinity turn/off/auto × x-session-id / X-Magpie-Session / same body × fresh and warm; over a group of three providers and of one provider's keys; behind a remote magpie; over a plugin's three accounts (fake plugin, streaming); a kept session stays on one account; paces {10, 9.5} spread and {10, 5} don't; three X-Magpie-Sessions in turn get an account each under session affinity, and conversationID never returns X-Magpie-Session. On the old code every pace case went 6 of 6 to k1, and rotate's warm cases 6 of 6 to the next account. Broken by hand: - reorder forced false: every pace case, rotate's warm cases, the group pace cases, the remote and the plugin tests red. - !aff.Kept dropped: TestABurstKeepsAKeptConversation red (map[k1:2 k2:2 k3:2]). - affinityID without X-Magpie-Session: TestMagpieSessionIsTheConversation red (map[k1:3]); the burst tests stay green, as the count covers them. Not tried: real Antigravity accounts, a run on Linux, a real remote magpie on another machine. |
||
|
|
5ae0ed1ab0 |
claude warm-up: a week left out while the five hours run is one the account hasn't
koohoko5924 (v0.1.3057, Claude Enterprise): the account has only a five-hour window, and the warmer kept warming a week it doesn't have (state Idle, 189 tries). warmNow walks withExpected(q.Windows, expect), which adds the 7-day window whenever a reading leaves it out, since Anthropic leaves a window out until the request that starts it. But any request starts every window a plan has, so a week left out while the five hours are running is not a week waiting to start. warmNow now marks such a window Absent (codex-warmup.json, compared in mapsEqual) and sends it nothing (windowAbsent). The rule: the reading leaves it out, the reading is whole (no partial window), a shorter plan window is running (shorterRunning), and it was never seen with a reset or use. A week seen running before, or left out of a partial reading, is warmed as before. usageRead counts an expected missing window as due only when no shorter window runs. withExpected itself is unchanged: claudeWithUnstarted uses it for the card. Codex has no expect list, so it is untouched. Docs: providers-accounts.md gets the rule. Run (mote, at this tree): go test ./internal/provider -run 'Warm|NotStarted|UsageRead|Claude|Codex' ok; gofmt -l clean. Broken by hand: windowAbsent off and the old usageRead check: TestClaudeWarmLeavesAWeekTheAccountHasnt red (12 "7 days" sends), TestClaudeWarmStartsAWeekThatReset's "never read" warmed, and TestUsageReadLeavesAWeekTheAccountHasnt told five-only@x. With the seen/partial guard taken out, "reset" and "partly told" go red. Not tried: a real Enterprise account or a real warm-up; the state is the report's (Idle 189), rebuilt in the test. |
||
|
|
beba9e8a1f |
claude warm-up: the account it started is read again, its old reading keeping its time
koohoko5924 (v0.1.3057): after a warm-up the card said "just updated"
over windows read before it. claudeWarmedNow cleared the kept
reading's time (e.at) and kept its windows, so claudeReadAt gave nil
and readNow stamped them now. Nothing read the account again either:
claudeWindows' next read waits on when /usage last ran (e.tried),
which the warm-up left alone.
claudeWarmedNow now clears e.tried, which makes the next read due as
for an account never read, and keeps e.at, so until that read the card
shows the reading's own time. Codex's warmed hook only drops its cache
(its usage is a fresh API read), so it has no such sibling.
Run (mote, at this tree): go test ./internal/provider -run
'TestClaudeWarmedReadAgain|Warm|Claude' ok; gofmt -l clean.
Broken by hand: on the old claudeWarmedNow TestClaudeWarmedReadAgain is
red ("the kept reading's time is <nil>"); keeping e.at but not clearing
e.tried, red ("warmed, not read again", the 10% reading kept).
Not tried: a real warm-up on a real Claude account.
|
||
|
|
77031d5817 |
claude usage: a /usage panel with no window is no window started, and a failure says why
koohoko5924 (Discord #help, v0.1.3057, macOS): a Claude Enterprise
account with a five-hour window only. A manual refresh took ~5s and
gave the card no window and the error "Claude Code's usage showed no
usage figures: ▐▛███▜▌ … magpie-claude-work…": Claude Code's banner,
not a reason.
Claude Code 2.1.316's Usage tab (gi) draws a window only once
Anthropic's answer has it non-null, and a window is null until the
request that starts it. An idle 5h-only account's panel loads with
the session's cost, maybe the plan's credit bar, and no window. The
helper told that panel's words, joined from the top of the screen, and
the card took them as a failure with the banner first.
- claudetui: a panel that loaded (tabs, Session/Total cost, nothing
loading, refreshing, stale or failed, no gateway Spend limit) with no
"Current session"/"Current week" is told as NoUsageWindow ("No usage
window has started"). The provider reads that as no window started:
no error, the unstarted 5h window as for any account.
- claudetui: the two rate-limit errors gi draws ("Claude is temporarily
limiting requests to the usage page (not your usage limit)…",
"Usage endpoint is rate limited until …") are failures to load, like
"Failed to load usage data": retried once, then told as an error with
the panel's own "Error: …" text, never the banner. A panel with no
window and no error is told from its tabs on, the session's cost
lines left out.
- provider: "(not your usage limit)" no longer reads as an account
refused (claudeDenied, at every place claudeUsageDenied judged a
reading: the CLI parse, codex_switch, quota_last, subscription_usage).
Counts ("Last 7d · 403 requests …") are taken out wherever they sit in
a line before that check, as the panel's words come on one line now.
A no-figures error keeps every line (600 runes), not the first clipped
at 120.
Tests are built from 2.1.316's own strings (ko/gi/hi in the bundled
cli.js), drawn on the helper's 200x50 grid row by row. Guessed: the
exact bytes of a real Enterprise panel (not captured; no such account
here) and the credit bar's layout.
Run (mote, at this tree): go test ./internal/claudetui ./internal/provider
-run 'Usage|Claude|Shim|Quota|Codex' ok; go vet for claudetui, provider,
gateway; GOOS=linux -tags nogui and GOOS=windows go vet; gofmt -l clean.
Broken by hand (each red, then restored):
- the NoUsageWindow case off: TestShimReadsUsageWithNoWindow red in all
three panels (told the panel's words as success);
- the provider's claudeNoWindow branch off: TestClaudeUsageNoWindowStarted
red ("showed no usage figures: No usage window has started");
- claudeDenied back to claudeUsageDenied: TestClaudeUsageWhyKept red
("read as an account refused");
- usageFailed back to "Failed to load usage data" and the whole screen as
the reason: TestShimToldWhyUsageFailed red in all three (the banner as
the reason; the rate-limit panels told as no window), TestUsageNoWindow
red.
Not tried: a real Claude Enterprise account; a real rate-limited panel.
|
||
|
|
b7631300ec |
claudetui: a successful interactive turn tells its account's allowance
Since the interactive mode replaced -p for Claude subscription turns ( |
||
|
|
0076fb0c9c |
gui tests: the lightweight click fails at once on an option out of sight (#3078)
The red reported on origin/main |
||
|
|
faa69b8319 |
dsh: a dsh test's temp home is given up only once it is really gone
TestDshSetEffortWritesALegacyEntryWithTheCatalog died once at cleanup, not in its body: on Windows, t.TempDir's RemoveAll found .config/magpie not empty (LoKi's box, reported by yetone, #2982). Save replaces providers.json by renaming a file over it, and a scanner holding the file that was just renamed over keeps its entry listed while the entry is pending deletion, so the folder reads as not empty for a moment; t.TempDir's own cleanup retries a sharing violation but not a "not empty" one, so it gave up on the first try. The seven dsh tests that set up such a home now share dshTempHome, which tries the removal until the folder is really gone, for a short while, before t.TempDir's cleanup gets its turn. Not verified on Windows: the failure is one-off under a scanner there, and on macOS removing a folder whose file is still open succeeds, so the race cannot be reproduced on this machine. With the retry taken out the suite is green on macOS as before, so the only change in behavior is the retry itself. Generated-by: GLM-5.3-Flash (ZCode) Review: go test -tags nogui -count=20 -run TestDsh ./internal/agent/ ok on Windows 11 (xiaomi-gpu, win-run, 232s) and -count=3 on mote. The cleanup is registered after t.TempDir, so it runs first (LIFO) and TempDir's own RemoveAll finds the folder gone. Not tried: a Windows box under the load that made the original red. |
||
|
|
24d4425944 |
gateway: TestRequestBuildsProvidersOnce judges the build's ask, not the
request's start (#2965) Cause: the test judged the second request by when it began, letting it want 0 rebuilds only within 900ms of the first, while what decides a rebuild is the hold and the stamp, not the clock from a request's start. Two ways that guess goes red: on a loaded machine a request can begin within the second and reach the build after the hold has let what was built go — "request 2 built the providers 1 times, want 0", seen in full runs at load ~280–400; and since |
||
|
|
d1b0b34430 |
gui tests: sidebar's unroll is counted as its animations are made
"the list opens and folds as it plays" sampled getAnimations() once after the click to see the list's unroll still playing. Under a machine load of ~175 that one sample landed after the whole play was over: a finished animation is out of getAnimations(), so the test read "not animating" and went red once (8be402816's GUI run; it passed on rerun). The list unrolls for 460 ms and its rows come one after another for 636 ms in all - the round trip from the click through the element wait to that one sample is not bound to that window. The animations made are counted instead: Element.prototype.animate is wrapped ahead of the click, and the assert reads that the nav-sub's own unroll was among them. An animation made is a fact that stays put, so the sampling race is gone. The assert is not looser: an opening with no animation still fails it. Run (playwright 1.62.0, idle machine): - this file: 10 runs, 160/160 ok (Chromium and WebKit) - nav-sub-unroll, sidebar-glide and sidebar-tab-top together: 2 runs, 136/136 ok - a 700 ms wait put between the click and the old sample turned it red with the reported "the list unrolls" assertion; with this change the same wait passes, and cutting navSubEnter's animations off turns it red again Not tried: a machine at load ~175 (the load figure is the report's; the delay injection stands in for it). Siblings: provider-advanced-fold's boxMoves() reads getAnimations() once after its own click the same way; it has no observed red, so it stays as it is. Fixes #2950 Generated-by: GLM-5.3-Flash (ZCode) Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady, sidebar and lightweight together, Chromium and WebKit, 30/30 ok. navSubEnter animates the nav-sub box itself, so the wrapped animate sees it. The sibling named above is filed as #5417. |
||
|
|
682848300c |
gui tests: agent-expand-steady checks the slide's animation, not the frames drawn (#2935)
yetone reported the webkit 980px leg going red once under load: "slid
open: 208". The test sampled the row's height every frame for 800ms and
wanted at least three heights between shut and open. A busy machine
drops frames — WebKit drew the whole slide in one frame, the sampler saw
only the final height (208), and the count came up short while the slide
itself was drawn correctly. Alone, the same test passed 3 of 3 at the
same load: a timing assumption, not a broken slide.
The drawn heights stay as an ordering check only; the slide itself is
now checked where it lives. A click drives a height animation on the
row's opened part (sheet() animates it through the Web Animations API),
so the sampler reads the opened part's animations in the same tick as
the click, before any frame is drawn: a keyframe animation carrying
height is the slide's witness, whatever number of frames the machine
went on to draw. The same evidence answers for the slide shut.
Run (playwright 1.62.0, darwin/arm64, node --test):
- agent-expand-steady: 40/40, ten rounds, Chromium and WebKit, 980px
and 560px.
- A probe that starves requestAnimationFrame past the sampling window
(the reported shape: one drawn frame, the final height) is red on the
old assertions ("slid open: 746") and green on the new ones, then
removed.
- agent-connected-unfolded and agent-models, the neighbouring agent-row
files: green, two rounds.
Generated-by: GLM-5.3-Flash (ZCode)
Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok. sheet()
calls box.animate inside the click handler, so reading getAnimations()
right after the click sees the slide. These tests run in English only;
the change adds no text.
|
||
|
|
83fdd09c07 |
agent: the Agents page's re-detect asks where updates come from again (#4980)
latestVersion kept its answer for 6 hours under a constant key, and the
page's re-detect (Rescan) forgot everything but it. A version published
after magpie started showed no update until the memo ran out or magpie
restarted, though a fresh process asked npm at once and saw it.
Rescan now expires the kept latest versions, the way it already forgot
where commands were found and what the slow readers had said. Unlike the
patch's forget, the entries are only expired, not dropped: the value stays
until a new ask answers, so a re-detect while npm is down still shows the
last version known instead of none (a failed ask keeps the old value in
memo.get). An ask already running is left to finish.
Run on mote (macOS arm64, go1.26.8), sandbox HOME:
go test -tags nogui -race -count=1 -run "Rescan|Latest|Update"
./internal/agent/ ok. TestRescanAsksLatestAgain: 1.4.0, then 1.5.0 after
a Rescan, then still 1.5.0 when the next ask fails with a 502 (asked 1, 2,
3 times).
Broken by hand: without the expire in Rescan, red ("1.4.0, asked 1
times"); with an expire that deletes the entry, as the patch did, red ("a
failed ask after the refresh: latest \"\", asked 3 times").
Not tried: the Agents page against the real npm registry; Windows and
Linux.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
59907fd554 |
claude: a /usage count of 401 or 403 is a count, not a denial (SCIYYDy, #4995)
SCIYYDy's Claude account closed /usage with the machine's own activity, "Last 7d · 403 requests · 388 sessions", and magpie read the count of 403 as the HTTP status. parseClaudeUsage scans every line for claudeUsageDenied before it reads the windows (account errors come first, #4532), and the bare \b(401|403)\b in that regex cannot tell a statistic from a status. So a whole reading with valid session and week windows came back "told no allowance" and the card kept none. A count of 401 denies as much. The scan now skips a line that reads, whole, as one of /usage's count lines ("Last <span> · N requests · N sessions", the numbers with or without thousands commas, so "1,403 requests" is a count too). A line that says more ("… · HTTP 403 Forbidden") is no count line, and a real 401 Unauthorized, 403 Forbidden or authentication failure still denies the account, on its own line and beside the windows; the #4532 precedence holds. Sibling (review): a count line with no windows around it fell to the "no usage figures" error, which quoted the panel's first line, so the error text held "403". That error is matched with claudeUsageDenied again in subscription_usage.go, quota_last.go and codex_switch.go, where it would read as a denial after all. A counts-only panel now gets an error that does not quote it, and the test asserts the error does not match claudeUsageDenied. Run on mote (macOS arm64, go1.26.8) at the pushed head, sandbox HOME: go test -tags nogui -count=1 ./internal/provider/ ok (116s). Broken by hand: without the count-line skip, the counts case is red ("told no allowance: Last 7d · 403 requests"); with the patch's narrower regex (no commas), the "1,403 requests" case is red. Not tried: a real Claude account whose /usage shows 401 or 403 requests; Windows and Linux. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
3da58c3dfc |
fix(plugin): end ordinary RPCs' plugin work when their caller leaves (#4678)
A plugin model list's deadline and an ordinary RPC's cancellation released only the caller. inTime raced the hook without stopping it, and host.go marked only gatewayRequest cancellable, so a cancelled usage or providers call never told the host: the plugin's task kept running, the host's pending count kept it, and repeated reads left task after task alive past their callers. Reported with an offline host-script reproduction that shows abort reaching none of three pending usage tasks and five model tasks outliving their deadlines. The cancellation path a fetch and a gateway request already take now carries ordinary RPCs too: - host.go marks every call but init cancellable, so a caller whose context ends has the host told (the existing callAborting write), the way it already tells it of a stopped fetch. init is left alone: a start that overruns is stopped whole. - host.js registers each ordinary RPC's AbortController; an aborted RPC's answer, nobody's then, is not sent. - the handler is handed the signal: usage passes it to the plugin's auth.usage hook as its own options, and a model list's hook options carry it, with the listWait deadline aborting the same controller, so vendor I/O that supports stopping stops at the deadline or when the caller leaves, whichever comes first. Sign-in renewal and its persistence are untouched: fresh() runs before the hooks, and an aborted RPC's handler still finishes what it saves. Refs #4678 Generated-by: GLM-5.3-Flash (ZCode) Reviewed and ported, narrowed: an aborted ordinary RPC is no longer answered "Aborted" at once and dropped from pending. It stays pending until its handler ends, as on main. host.go's stop() closes the host's stdin and then gives a renewing host up to stopRenewing to save the rotated token; with the early done(), host.js's own `pending === 0 && closed` exit ended the process at once under a cancelled call whose handler was still renewing or saving (keepSignedIn, set, signOut, a usage hook mid-refresh). The Go side needs no answer: an aborted call is released once its abort is written. The signal to the usage and models hooks, and the listWait deadline aborting the models hook, are kept as the patch had them. TestCancelledCallKeepsTheHostTillItsHookEnds is new: a usage hook that ends 600ms after its abort, then Settle() closing the host's stdin; the hook's end must reach its trace. Run on mote (darwin arm64, Go 1.26.8, Bun via testenv): go test -tags nogui -count=1 ./internal/plugin/... ok 102.8s; -run Plugin ./internal/gateway/ ok 52.1s and ./internal/provider/ ok 13.3s. Broken by hand: host.js and host.go at main, tests kept: TestOrdinaryCallCancelTellsTheHost FAIL "the host was told of the cancellation didn't happen", TestCancelledUsageReachesThePlugin FAIL "the plugin's usage hook was handed a signal didn't happen", TestModelListDeadlineTellsTheHook FAIL "the models hook was handed a signal didn't happen". host.js as the patch had it (early answer): TestCancelledCallKeepsTheHostTillItsHookEnds FAIL "the host left before the hook ended; trace: {"signal":"live"}...". Not tried: the reporter's replay.py against the built host, and a real plugin's usage hook that passes the signal to its fetch. The reporter's "host lives on after stdin closes with a task pending" row is unchanged by design: that is the renewal safeguard. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
9f6407321d |
library: a project whose folder was deleted outside magpie comes off the list when it's removed (#3510)
RemoveProject empties a project (Skills, Servers, then syncProject) and takes the entry off the list only once nothing magpie placed or wrote is left in it. But the only thing that empties those records, syncProject, gives up on a folder that's gone: it says "the folder is gone" and returns with the records as they were — and the Result RemoveProject hands it is thrown away, so the removal itself says nothing; the toast the user sees is the one the full sync after every change reports. With the folder gone there is nothing magpie can ever take back, so the records never empty and the entry stays for good: the only way out was the keep checkbox, which takes the entry off the list without looking at the folder (#514), though that reads as keeping what magpie wrote, not as the way out of a dead removal. So removal now does what a skill's removal already does when its folder is gone (removeSkill: only the entry goes): a folder that isn't there has nothing of magpie's on disk to take back, so the project and the records of what it placed and wrote go together, and the removal says nothing failed. A folder that is there removes as before; a project gone from disk still shows its "folder is gone" badge and still reports the folder on a full sync; keep is untouched. TestRemoveProjectWhoseFolderIsGone is new: a project with placed skills whose folder is deleted outside magpie, removed without keep — the entry goes, the Result has no problem, the library's skills stay; and a gone project removed with keep goes off the list as it always did. It fails without the change (the removal says "the folder is gone" and the entry stays) and passes with it. go test -tags nogui -count=1 ./internal/library/ pass (28 project and gone-family tests targeted first); gofmt, go vet -tags nogui and go build -tags nogui ./... pass. The cgo warning from internal/gui/trayimage_darwin.go is there before this change. Generated-by: GLM-5.3-Flash (ZCode) Reviewed and ported, narrowed: only a folder known to be gone (not there, or not a folder) drops the records. A Stat that fails another way (no permission, a drive answering with an error) isn't known to be gone, so the removal goes as before and the records stay, to be taken back once the folder answers; TestRemoveProjectWhoseFolderCantBeRead pins it. Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1 ./internal/library/ ok 73.8s. On Linux (wsl-run, magpie-desktop): -run TestRemoveProject ok. Broken by hand: projects.go back at main, tests kept: TestRemoveProjectWhoseFolderIsGone FAIL "the removal said: [... the folder is gone]", the entry left with Placed [.agents/skills/pdf .claude/skills/pdf]. The patch's own check (err != nil): TestRemoveProjectWhoseFolderCantBeRead FAIL "projects: []". Not tried: removing a deleted project from the GUI on Windows, the reporter's system. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
8807f621f2 |
gateway: a relay's DeepSeek model reads max_tokens as its own (#5030)
deepseekTokenField named a chat request's reply length max_tokens for the DeepSeek preset and api.deepseek.com alone; a relay on its own domain serving a DeepSeek model got max_completion_tokens as it came, DeepSeek behind it ignored it and answered with its default, 8K without thinking (#5030, NOMOAX) — the gate the tool-schema normalization's had too (#4852, ethanfly). DeepSeek's quirks are told by the model named in the body now, as Grok's are (grokModel): a model a relay names deepseek-whatever gets the field DeepSeek reads, whoever serves it; another vendor's model through the same relay goes as it came. Generated-by: GLM-5.3-Flash (ZCode) Reviewed and ported. The model's name decides only on a host that isn't DeepSeek's: chatTokenField runs after deepseekTokenField in forwardOnce, so OpenAI's own hosts still get max_completion_tokens and a relay whose 400 names max_completion_tokens is still asked that way from then on. The model test (provider/test.go probe) already sends max_tokens to a host that isn't OpenAI's, so it needs nothing. The tool-schema \0 gate, the same narrow gate, is #4852's, open. Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1 -run 'TokenField|MaxTokens|MaxCompletionTokens|DeepSeek' ./internal/gateway/ ok. Broken by hand: deepseek_schema.go back at main, test kept: TestDeepSeekRelayChatGetsMaxTokens FAIL "upstream got {...max_completion_tokens:393216...}". Not tried: a real request through AI Flash API. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
c6d2bd3316 |
library: ZCode reads the shared skills folder too (#4987)
ZCode reads ~/.agents/skills beside its own ~/.zcode/skills, but it wasn't among the readers of the shared folder: a skill kept there behaved as if ZCode didn't have it — its chip unlocked, a tick writing a second link into its own folder. It reads it as the others do. Generated-by: GLM-5.3-Flash (ZCode) Reviewed and ported: docs/subsystems/library.md now lists ZCode among the readers of ~/.agents/skills, as Ikki6666's own branch (a23828e81) had it; the reporter checked the published ZCode builds for a version boundary and found none (#4987). Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1 ./internal/library/ ok 76.5s; -run 'ZCode|Shared|Always' ok. Broken by hand: "zcode" taken out of readsShared, test kept: TestSharedSkillReachesZCode FAIL "zcode has a second link to it in its own folder" and "zcode's own folder got it on the sync too". Not tried: a real ZCode install reading the skill. Co-authored-by: ggbdpq <ggbdpq@gmail.com> Co-authored-by: Ikki <824310075@qq.com> |
||
|
|
acde144a7a |
providers: a vendor of embedding and rerank models alone is detected on /embeddings and /rerank (heatonz)
heatonz on Discord (#help, 11-05): a custom provider whose models are only
embedding and rerank models couldn't be added. Detect APIs ("检测协议")
picked the first listed model, an embedding model, and asked it to chat on
every API, so nothing answered.
- tiny: an embedding or rerank model (catalog.ServesOf) on Chat is asked
where the gateway's retrieve sends it: the OpenAI base's /embeddings
({"model","input"}) or /rerank ({"model","query","documents"}). tested
adds no extra body there, as the gateway sends none.
- detectModel asks each API a model that chats when the list has one, so
a chat vendor's detection is unchanged. A retrieval model is a last
resort on Chat only. Responses, Anthropic and Gemini say why they weren't
asked (DetectModels too).
- testModel: a saved provider with nothing to chat with tests on a
retrieval model its list keeps apart (LiveServing). testOne asks such a
model on Chat and never moves it to another API.
- provider.ListAll is List with Serves models kept. /api/provider/list and
the provider's JSON carry a `retrieval` count. The add form's Fetch models
and the saved editor say "Only embedding and rerank models are listed.
They need no pick: ask them on /v1/embeddings and /v1/rerank." in place
of "the list is empty". One new string, in zh, zh-TW, ja and de.
- app.js stays under TestCoreScriptBudget with no raise: +42 bytes, paid
for by two add-form comments cut.
- The gateway already routes /v1/embeddings and /v1/rerank to such a
provider (#765, resolveRetrievalModel by prefix or KindGroup), so nothing
changed there.
Run (mote, at this tree on origin/main
|
||
|
|
60fe6645a9 |
claude: a caller's folder Claude Code would ask about is known before the run, and the session kept (sleepy_shibe)
sleepy_shibe on Discord (magpie 0.1.2996, Claude Code 2.1.318, own account, interactive mode): message counts 36, 65, 85, 108, 128 for one conversation. Confirmed at origin/main |
||
|
|
74d1cda421 |
gateway: a rate limit with a bracketed reset time rests the model until then, and says rate limited
taoxiaoxin on Discord (v0.1.2992, WorkBuddy China, plugin 0.2.24):
deepseek-v4.1-flash got 429
{"error":{"code":null,"message":"WorkBuddy: 您的使用量已超出频率限制,将在
2026-11-06 17:13:04 (UTC+8) 重置,您也可以切换其他模型继续使用。",
"param":null,"type":"rate_limit_error"}}
with credits left, and Routing showed the account as 额度用尽.
Cause: WorkBuddy now writes the offset in brackets, "(UTC+8)".
resetsWhen read "UTC+8" only bare, so the reset time went unread, the
refusal fell to plannedWords (用量) as failQuota with no time, and the
whole account rested a quarter of an hour as quota used up. With the time
read, the existing path (resetsWhen + otherModels) rests only that model
on that account until 17:13.
- resetsWhen takes an optional ASCII or fullwidth bracket round the
offset (zh and en forms); a body cut inside or after the bracket,
before 重置, still reads no time.
- Rest.Rate (and provider.KeyRest.Rate): a refusal read as out of quota
until a named time whose words say rate/frequency limit. Routing is
unchanged (it rests as the quota it is until then); the Providers row,
Routing's stage row, its Accounts line and the account tallies (live
and the day's, history.go) say "rate limited" (限流, 限流, レート制限,
Rate-Limit; strings already translated) with "back at {time}".
- workbuddy-ai gets the same: one path, tested for both ids. The plugin
(opencode-workbuddy-auth) already reads the bracketed time; no plugin
version or mover min.
Run (mote, at this tree):
- go test ./internal/gateway -run 'TestDayTallies|TestResetsWritten|
TestWrittenReset|TestBracketedReset|TestMonthlyWritten|
TestRateLimitBelieves': ok
- go test ./internal/gui ./internal/provider: provider ok; gui red only
in TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27, untouched)
- go vet (darwin) gateway, gui, provider; GOOS=linux and GOOS=windows
go vet gateway, provider: ok; gofmt -l clean
- node --test account-rate-rest (new; chromium + webkit, en zh zh-TW ja
de, 1100 and 420px): 10/10
- GUI routing-*, account-*, i18n*, key-rest*, rate-limited-* (194
files, 3127 tests): 3086 pass, 41 red. Rerun at concurrency 2 here
and at origin/main
|
||
|
|
8fbf8e0af6 |
gateway: DeepSeek's own API gets an agent's images once, by file id, not on every turn (#5407)
DeepSeek's API is stateless, so every turn re-sent every inline image in
the history. Now, on api.deepseek.com only (never a relay or another
base), for a model with "flash" in its name (deepseek-flash sees images;
deepseek-v4-pro reads them as "[Unsupported Image]"), each base64 data:
image goes up once through POST /files (purpose=user_data, expires_after
a day) with the candidate's own key, and later turns name it by file id:
- Chat: {"type":"file","file_id":…} (flat, as DeepSeek's vision guide);
- Responses: input_image with file_id in place of image_url;
- Anthropic: source {"type":"file","file_id":…} plus anthropic-beta
files-api-2025-04-14.
Shapes checked against api-docs.deepseek.com files_api, vision,
responses_api and anthropic_api. The Anthropic guide names the "file"
source type and the beta; the field name file_id is Anthropic's Files
API's, which DeepSeek says it follows. Not confirmed with a real call.
Ids are kept per key hash + image sha256 in deepseek-files.json beside
providers.json (temp+rename, unparseable file moved to .bad), reuploaded
with under an hour left. One upload per image and key however many
requests want it; a request waits at most 8s for its uploads, and what
isn't up goes inline this turn. A failed upload leaves the image inline
and rests that key's uploads for 10 minutes. A 4xx naming a file-api id
or a missing/expired file forgets the ids, uploads again and asks once
more; refused again, the request goes inline. detail:low stays inline.
`magpie provider set <id> image-files=off` turns it off (kept on GUI
save). Doc: docs/subsystems/gateway-routing.md.
Run (mote, at this tree on
|
||
|
|
7625481b9e |
library: a Codex MCP entry never keeps the other transport's keys
kwanyu (Discord #help, 11-06): with Codex connected to magpie, the ChatGPT/Codex app wouldn't start: "config.toml:209:1: env_vars is not supported for streamable_http". Codex refuses a command's keys (args, env, env_vars, cwd) beside a url, and a url's (bearer_token_env_var, http_headers, env_http_headers, http_headers_helper, oauth, oauth_resource, auth) beside a command (codex-rs/config/src/ mcp_types.rs, TryFrom RawMcpServerConfig). merged kept every old key magpie doesn't own. env_vars is magpie's only while the server references a variable in its env, so a server changed from a command to a URL (in the Library, or one imported from the user's own stdio entry) kept its env_vars and cwd under the new url. The converse kept bearer_token_env_var and env_http_headers under a command. The sync's in-step check decodes neither key, so an entry already broken was never written again. Now codexRefused names the other transport's keys. merged drops them, and behind reports an entry holding one, so the next sync (and a project's .codex/config.toml) rewrites it. The user's keys of the entry's own transport stay (enabled_tools, tool_timeout_sec, scopes, a stdio entry's own env_vars). bearer_token, which Codex refuses for both transports, is left as the user wrote it. Run (mote): go test ./internal/library -count=1 ok (77.8s); GOOS=linux and GOOS=windows go vet ./internal/library ok; gofmt -l clean. Broken by hand: the four new tests against the old mcp.go are all red (env_vars/cwd kept under a URL; bearer_token_env_var, env_http_headers and oauth_resource under a command; a broken entry left in step; a project entry read as in step). Real Codex (codex-cli 0.165.0, sandbox CODEX_HOME, codex mcp list): a url + env_vars entry fails with the reporter's exact error. The three config.toml files the new tests write load and list their servers. Not tried: the reporter's own config.toml (we only have the error line); the ChatGPT desktop app itself; Grok's config (written by the same TOML writer, its own transport rules not checked); a full suite before push (runs after). |
||
|
|
498b6419ff |
claude: a turn Anthropic refuses in the interactive mode as a third-party app's is asked again as claude -p, and the agent's prompt is remembered
Raven (Discord #general): Cindy with Pi as its engine, routed through
group/auto to a Claude subscription, failed every turn with "Anthropic
refused an interactive-mode turn on claude-opus-5-5 as a third-party
app's", and the message told them to turn the interactive mode off in
Settings, which makes every request of every agent run as -p (about twice
the plan count).
Now, with the interactive mode on:
- a refusal carrying "Third-party apps now draw from your extra usage",
met before a byte of the reply reached the client (stream head, or a
whole reply with no parts), is asked again once as claude -p
(redoAsPrint); the client sees only the -p answer;
- the agent's system prompt (sha256 of its first 2KB, billing header
dropped, so Pi's trailing <cwd> doesn't change it) is remembered for
12h, and its next turns go straight to -p (wantTUI, req.tuiRefused,
clientCache.print) while every other agent stays interactive;
- a refusal after the reply had begun (keepalive sent, or text said) is
not redone, so nothing is spent twice; the prompt is still remembered
and the message now says magpie runs its next turns as -p: ask again;
- a -p run that is refused too fails as before ("run as claude -p"),
once, no loop;
- the setting is untouched; with it off (claudePrintMode) everything is
-p as before. The run is the real claude binary, nothing else changed
in what is sent.
This reverses the #4503 call (
|
||
|
|
1100ed6494 |
gateway: an overlong item id goes left out on every kind that may go without one, and under its kind's own prefix on the rest (echo_ts, web_search_call)
echo_ts (Discord, Codex on GitHub Copilot, after |
||
|
|
1d704f8190 |
codex: OpenAI's threads follow a provider of the user's at the top, where Codex resumes them
harris on Discord (the Codex app, after switching from CC Switch): "This chat uses openai, but your current provider is custom. Switch to openai to continue." CC Switch left its "custom" as config.toml's model_provider, which magpie keeps since #4347, and Codex 0.166 resumes a thread only on the provider it is on now. Every thread started on OpenAI before was refused, and switching to OpenAI would refuse custom's threads instead, so the user was stuck. Nothing moved them: bringOver moves only onto magpie, bringBeside only from such a provider onto OpenAI. lendOwn (each Sync) moves OpenAI's threads onto that provider, as bringBeside does the other way: in place at OpenAI's length, by the row for a paginated thread, the last 30 days rewritten with a copy kept otherwise. The ids go in stash codex.lent; giveLent returns exactly those to OpenAI once Codex is on it again (CC Switch's official card), keeps the record while Codex is on that provider or on magpie, and drops it on any other. Nothing moves while a profile names openai, after the user disconnected Codex, or from a distro's Codex. TestCodexThreadsComeBackOffMagpie/by_hand expected an OpenAI thread to stay on OpenAI with custom set by hand at the top, the stuck state itself; it now expects it on custom. docs/subsystems/agent-wiring.md says so. Run (mote, go 1.26.8): go test -count=1 ./internal/agent/ ok (250s); GOOS=windows, GOOS=linux and native go vet ./internal/agent/ ok; gofmt -l clean. Broken by hand: Sync without lendOwn, TestCodexOwnProviderTakesOpenAIThreads red (thread left on "openai", rollout not on custom); without the disconnected and profile guards, TestCodexOwnProviderLeavesOpenAIThreads red for both cases. Not tried: a real Codex app resuming a moved thread on a real relay; harris's config.toml wasn't seen, so the "custom" here is CC Switch's relay table as it writes it. A thread moved from the ChatGPT backend to a relay carries its encrypted reasoning, which a relay on another account may not accept; the thread then fails on the relay as a switch to it by hand would. |
||
|
|
845e324b13 |
liveagent: each model on its own API, and the request format the user picks stays (xiaoxiaofei)
xiaoxiaofei on Discord: "magpie 默认导入的是 message 格式的,要可以自定义请求格式".
magpie wrote one LiveAgent provider, "magpie", type claude_code with
api anthropic-messages, for every model. K-brain asks all of a
provider's models on the provider's one API (routing/client.go builds
the client per provider; PiModel.api is only validated), and LiveAgent's
settings lock an Anthropic provider's API: only an OpenAI provider
(type codex) has a request format to pick (ProviderModalView.tsx,
resolveProviderApi; K-brain settings_provider.go accepts
openai-completions and openai-responses). So the format couldn't be
changed, and a GPT served on Responses was translated from Messages on
every turn.
Now, as dsh's routes do (dshKinds), each model goes on the provider of
the API it is served on natively (catalog.Model.APIs):
- magpie: type codex, Chat Completions, baseUrl the gateway's /v1, for
every model with no Responses or Messages API of its own (groups, Chat
providers' models);
- magpie-responses: type codex, Responses, baseUrl /v1;
- magpie-anthropic: type claude_code, Messages, baseUrl the root (K-brain
appends /v1; for OpenAI it appends only /chat/completions or
/responses, hence /v1 there).
A codex provider is written with api and requestFormat, as LiveAgent's
settings write one; when the user switches it in LiveAgent, a sync keeps
their format (one LiveAgent doesn't offer goes back to magpie's). A
provider left with no model is taken out. A config.json from before (all
on one claude_code "magpie") is moved on the next sync: each model brings
its record (the user's display name) and whether it was turned off, and
a default/compact/task pick of it follows it to its new provider.
Disconnect takes all three out. Docs: reference.md, agent-wiring.md.
Run (mote, through mote-run):
- go test -tags nogui ./internal/agent -run '^TestLiveAgent|Key': all pass,
new TestLiveAgentRequestFormat and TestLiveAgentFormatMove included.
- go test -tags nogui -timeout 45m ./internal/agent: ok (320s).
- GOOS=linux and GOOS=windows go vet ./internal/agent: clean; gofmt -l clean.
- K-brain 507f560 (the version LiveAgent af89ea7 pins), with Go 1.27.0
on mote: config.LoadFile on the config.json magpie writes in
TestLiveAgentRequestFormat loads it, and routing.ClientForProvider
builds *ai.OpenAI at http://127.0.0.1:3425/v1 for magpie,
*ai.Responses at /v1 for magpie-responses and *ai.Anthropic at the
root for magpie-anthropic (a throwaway test, not committed).
Broken by hand (a copy), each turned a test red:
- the user's format not kept -> TestLiveAgentRequestFormat;
- no carried record from another provider of magpie's -> FormatMove;
- picks not following their model -> FormatMove;
- Responses models left on magpie -> both;
- an emptied provider not taken out -> FormatMove;
- turned-off not carried to the new provider -> FormatMove.
Full suite at
|
||
|
|
814a625a24 |
usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.
Now a refresh of every allowance by hand asks usage/quotas?asked=1&all=1
(AskEveryClaudeUsage). It marks its ask generation in claudeEveryAsked,
and for claudeEveryFor (2 minutes) each saved account not read since is
read as its card's refresh would, under the same due check, the
30-second per-account floor and the same running holds. Opening the
Usage page or the Allowances tab (?asked=1 alone), the timed refresh and
every background read are unchanged, so nothing polls more. Callers:
the panel's top refresh (refreshPage "allowances"), the Usage page's
refresh and sidebar reload (refreshUsage -> loadQuotas("all")),
Routing's Read allowances, and the TUI's r. loadQuotas no longer lets a
lesser load on its way (an opening's asked read) swallow a Refresh.
Siblings: saved Codex accounts are already read anew on every asked
whole read (loginReading over HTTP after AskUsage clears the cache), so
Codex is unaffected. PlanQuotas and KeyBalances keep their 1-minute cache
on an asked read; left as is. The core scripts' budget is not raised:
the ~140 bytes are paid for by two loadQuotas/quotasOpened comments cut.
Run (mote, at 807341cdc on origin/main 5666cb049; rebased onto
|
||
|
|
5055349922 |
plugin: a host ended ends what its plugin started, at any depth (#5402)
A plugin host was ended with cmd.Process.Kill(), the host alone. A plugin that starts a browser or a daemon (magpie-magicrew-auth's headless Edge behind a WAF) left it running with no parent: 620 msedge.exe (6.8GB) and 382 temp profiles (57GB) in an hour on one Windows machine. Bun's own job ends its direct children with it on Windows, but lets their children out, so Edge's gpu/renderer processes lived on. On macOS and Linux nothing ended them at all. The host now starts as a proc.Tree (new Output.StartTree): a session of its own on Unix, a job (kill on close) on Windows. host.kill kills the tree; stop (after stopWait, so EndHosts, Restart, a moved proxy, an update) and the line-too-long path both use it. A host that ends by itself is swept by the tree's Wait: the Unix group is killed, the Windows job closed. Nothing outside the host's own session or job is signalled, so magpie's own process group is never reached. Ported from baijiu666's fix/plugin-host-tree (a8172a1), which called proc.End then Process.Kill. Reviewed against it: - macOS/Linux: proc.End is SIGTERM to the host pid alone, followed at once by SIGKILL; host.js has no SIGTERM handler and the host was in magpie's own process group with no session of its own, so nothing it started was ended. Red on mote and WSL, same as main. - Windows: endTree walks living parents, so it covers the killed host but not a host that ends on its own (crash, process.exit) or one that leaves when its input closes; those were red on Windows too. - Its test was Windows-only and checked a direct child, which Bun's job already ends: the new test checks a grandchild, through a real host. Run (TestHostEndedEndsWhatItsPluginStarted: a real Bun host whose plugin starts a child that starts another; subtests stop / killed / own end): - origin/main |
||
|
|
5666cb0490 |
search MCP: web_search takes a count, 6 by default, 1 to 20 (treeman)
The web search MCP server's web_search always gave 6 results: searchHits was both what a search API (a plugin's included) was asked for and where its pages were cut. It now takes an optional count, described in its input schema (integer, minimum 1, maximum 20, default 6). A number or a number in a string is taken, floored; below 1 is held to 1, above 20 to 20 (Brave and Tavily take no more than 20); null or a non-number is the default 6. The tool's description is unchanged, and the web_search magpie offers models on vendor requests keeps its schema (no count). The count rides the search's context (withSearchCount/searchCount), so every backend reads it: plugin search APIs by key and signed-in (the count handed to the hook and the pages cut), Tavily max_results, Brave count, Exa numResults, Firecrawl limit, DeepSeek count, Volcengine Count, You.com count (all three routes), Yuanbao Search's Cnt (the fewest of 10/20/... that covers it), SearXNG (cut only), Kimi Code's limit, GLM's search MCP and Codex's backend search (cut only, neither takes a count), WorkBuddy (its client's 5 unless more than 6 is asked). A searcher model's search is prose and has no count. Run (mote): go test -run 'Search|Codex|Kimi|GLM|WorkBuddy|Plugin' ./internal/gateway ok; -race of the new tests and TestSearchMCP* ok; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the package ok; gofmt -l empty. Broken by hand: searchCount ignoring the count went red in both new tests (plugin asked for 6, said 6, every vendor asked 6); withSearchCount without the clamp went red for 50, 0 and -3. Not tried: a real search API or plugin with count > 6; the full suite runs after the push. |
||
|
|
c24915f04e |
library: LiveAgent in the MCP and Skills pickers (zero2sin)
LiveAgent was missing from the Library's MCP and Skill agent pickers
(zero2sin on Discord #feedback). It is now a target, written in its own
engine's formats, read from K-brain 507f560 (the one LiveAgent af89ea7
pins), not guessed:
- MCP: <data dir>/config.json.live-mcp.json (cmd/kn/backend.go,
internal/mcp/live.go LiveSettings): {"servers":[{"id","enabled",
"transport":"stdio"|"http","command","args","env" | "url","headers",
...}],"selected":[...]}. Streamable HTTP only, so SSE is refused.
${NAME} in env and headers resolves as K-brain's secret refs
(internal/config/secret.go). The user's servers and their
description/enabled/cwd/timeoutMs/policy/auth/... are kept; untouched
servers are written back byte for byte (json.RawMessage). A non-empty
selected gets magpie's server added (or it would have no tools) and
taken out on remove, never the last one. With no file yet, K-brain
reads config.json's "mcp" object (settingsFromConfigs), so the first
write carries those servers over the way K-brain's own first save
does. A new file is 0600 like K-brain's. A file K-brain itself could
not parse is not written over.
- Skills: <data dir>/skills, as copies (Target.Copy): K-brain refuses a
link in a skill's path (safePath) and ScanDetailed walks past one. A
skill there loads only when picked in skills-settings.json
global.selected (Manager.Effective), so syncLiveAgentPicks picks each
copy magpie makes once (Applied.Picked), never again after the user
unpicks it, and unpicks it when the copy goes. Names K-brain refuses
(validManagedName) are never put in selected, since its next save
would fail on them. Its built-in skills-creator/skills-installer are
not offered for import.
- Not added: instructions (K-brain's brain.md is its own memory file).
A server written while LiveAgent runs is seen at its next start (the
app holds the list in memory and saves it whole).
Run (mote-run, at base
|
||
|
|
125fd93ecd |
gateway: an overlong message or call id goes left out, and any other is bound under its kind's prefix, which Copilot checks (echo_ts, #5266, #4972)
echo_ts (Discord #feedback, v0.1.3058): after Codex's native compaction, a tool call on GitHub Copilot failed with an empty 400 "invalid_request_body". Copilot had handed the call a 452-character opaque id (Base64, + and / in it, no fc_ prefix). plainItemIDs, on every relay that checks ids (validatesItemIDs, Copilot among them), sent any id over 64 as boundItemID's sha256. That kept an id's own prefix only when it had one, so an opaque id went as a bare 64-hex digest. Copilot refuses that. By hand, the reporter got 200 with the original id and 200 with the id left out (call_id kept). isnine found the same thing for a message on #4525/#5266: left out 200, bare digest 400, msg_+hash 200. The bare digest dates from |