8a4e32febef69bb797cdf3003ec1395e725d5d63
5945
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8a4e32febe |
tests: the overflow memory's compacted and answered cases stay one conversation (#3453)
TestOverflowRefusedOnceIsAskedLast's "compacted" request changed the conversation's only user message. A ruled group keeps a conversation by its first user message (firstWords in the stick key), so that request was another conversation, and passed with behindOverflow's size check taken out. Nothing asked that what a member answered is forgotten. The conversation now has turns after its first user message, and the compacted request keeps that message and drops the rest: the same key, a smaller body. a answers it, and the conversation grown back to the size a once refused begins with a again. Run on mote, -tags nogui ./internal/gateway/: - -run TestOverflowRefusedOnceIsAskedLast: ok. - size check taken out (size >= r.bytes always true): FAIL at overflow_learn_test.go:71 "compacted: ... (a 0, b 1)". - forgetOverflow call taken out: FAIL at :81 "after a answered: ... (a 0, b 1)". - -race -count=20 of this test, TestOverflowMemoryReadWhileNoted and TestRelayInputCapGoesToTheNextMember: ok. |
||
|
|
3af592f587 |
gateway: the overflow memory is read under its lock, so two requests of one conversation don't crash the gateway (#3453)
Review follow-up to ggbdpq's 075aaef62. behindOverflow took the conversation's inner map under overflowLearned's lock, let go, and then read it, while noteOverflow and forgetOverflow write that same map under the lock. Two requests of one conversation at once (a turn beside its title ask, a client's retry) read and wrote one Go map together, which is a fatal "concurrent map read and map write", the whole gateway gone. The loop now runs under the lock. TestOverflowMemoryReadWhileNoted notes and forgets on one goroutine while another orders members by the memory. Before this commit, on mote: go test -tags nogui -race -count=1 -run TestOverflowMemoryReadWhileNoted ./internal/gateway/ -> "--- FAIL: TestOverflowMemoryReadWhileNoted ... race detected during execution of test". With it, -race -count=20 of that test, TestOverflowRefusedOnceIsAskedLast and TestRelayInputCapGoesToTheNextMember: ok. Also: behindOverflow's comment said resting members keep their order; the code moves a refused member behind every other one, resting or not, so the sentence is dropped. gateway-routing.md now describes the memory beside withRoom's overflow paragraph. |
||
|
|
e0a5091b7d |
gateway: a member that refused this conversation as too long is asked last, not first
What changed: an overflow (400, "prompt is too long") is the request's
length, not the account's, so it rests nobody — and left no trace: the
next request of the same conversation tried the member again, failed the
same way, and fell back again, for every request (#3453: a rule sent
every turn to a Claude subscription bridge that answered "Prompt is too
long" and DeepSeek answered; two consecutive requests of one turn each
paid the refused try first). Now the conversation remembers, per
provider's model, how large the request was when it was refused, and the
member is put behind the others — behind, not out: it is still asked
when every other member has failed, a rule that names it is still
heard (ruleOver has run), and what it answers makes magpie forget the
refusal. A request smaller than what was refused — the agent has
compacted the conversation — finds the member where the rule put it.
Another conversation is unaffected, and a byte cap (413) is not
remembered: it is not the conversation too long for the model.
TestRelayInputCapGoesToTheNextMember's second phase shares its server
with the first, whose overflow left this conversation's memory of a's
refusal behind; as that phase says how a plain bad request is classed,
its memory starts empty.
Run: go test -tags nogui -count=1 -run
'TestOverflowRefusedOnceIsAskedLast' ./internal/gateway/ (red on
|
||
|
|
9a4eaab82a |
gateway: a Chat body relayed to Gemini's OpenAI-compatible API goes without Ollama's options (#3097)
What changed: a client that takes the gateway for an Ollama server (its
/api/show is answered in Ollama's shape) sends Ollama's per-request
options beside its Chat fields. The google preset serves a model on
Gemini's OpenAI-compatible endpoint, so such a request is relayed as it
came, and that endpoint reads proto JSON: an unknown name turns the
whole request away with 400 "Invalid JSON payload received. Unknown
name \"options\": Cannot find field", every call, whatever the effort.
A body relayed to a Gemini OpenAI-compatible upstream (geminiCompat)
now goes without the top-level options, whose runner settings have no
place on a Chat API, as the Ollama route's own body builder already
leaves them out (ollamaChatBody). Another vendor's Chat upstream still
gets the body as the client sent it, and translated requests are
unchanged: they are built from the request's own fields, which never
carried options. geminiCompat is worked out once where the thought
signatures ask for it too.
Run: TestGeminiCompatRelayLeavesOutOllamaOptions fails on the old code
with "Ollama's options reached Gemini's OpenAI-compatible API" and
passes with the change; a request to another vendor's Chat upstream
still carries options there. go test ./internal/gateway/ ok (346.6s);
go test ./... -timeout 45m: 66 packages ok, internal/agent TestMothX
and internal/gui TestProxyCheckSaysAProxyPassedBy red, both red with
the change stashed on
|
||
|
|
026d4423d0 |
gateway: a Command Code stream that ends with no finish_reason is a cut (#2471)
What changed: a Chat stream of Command Code's whose reply ends with no finish_reason anywhere - esp32gallery's day had 665 requests, 624 ended with one, and the 20 that didn't were turns its slow starts lost to a killed worker, each a ledger 200 with no stop and no error while the client read "Stream ended without finish_reason" - was taken for a turn that ended as it should, silence in the ledger and a bare half-reply for the agent. Its API joins Gemini's OpenAI-compatible one in saysItsEnd: every whole reply of its says its end, so a stream that stops short of a finish_reason is said as the cut it is, in the stream, the same way a relayed Gemini one is (#1644) - and one still held, with nothing of the reply said yet, fails there for the group's next candidate. Another vendor's Chat stream may still end whole with neither a finish_reason nor [DONE]: nothing changes there. Run: Four new tests, the first two red on cef8c1a4a before the change (the cut passing as a whole reply, the next member never asked): TestCommandCodeRelayEndedShort, a half-reply cut ends with "the reply ended before it was complete", no finish_reason filled in; TestCommandCodeTaillessFailsOver, a held lead-only stream fails 502 for the next member; TestAnotherChatStreamWithoutAFinishReasonStaysAsItCame, another vendor's tailless stream goes as it came; and TestCommandCodeRelayWholeStaysWhole, a finished reply is never given a second end. TestGeminiCompatRelayEndedShort and TestGeminiCompatTranslatedEndedShort green throughout. Not tried: a real Command Code upstream (the frames are the reporter's ledger shapes, the host the one balance.go reads). Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
eb7e72cc7f |
gateway: a response.completed with no output and no tokens fails over (#2471)
What changed: a Responses upstream that ends its 200 stream with a
response.completed carrying no output and counting no token - WorkBuddy
AI's account answered Codex's request with created, in_progress,
completed and `output: []` three times running (MurmuredVelpro) - had
the completed event taken for a reply's end: the held stream went to the
agent as a completed turn, the try stood as a 200 success, and the
group's healthy members were never asked. streamEvent now reads a
completed with an empty output and a zero usage as the no reply it is -
the same shape a translated reply that said nothing and counted nothing
has failed as since #2086 (repliesCounted) - and fails the held try for
the group's next candidate, in the candidate walk as an empty reply's
does: nobody rests, as the reply's shape failed, not the account. A
completed that counted a token stays a reply, as Claude's own empty
end_turn does; and an event this reaches is one nothing was said before,
since the hold lets the first content through and reads no event beside
it, so nothing of the try has reached the agent when it fires.
The fields said are what is read: a completed that names neither field
goes as it came, as the streamEvent table pinned it
(TestStreamEventRefusals, which caught the first draft reading an
omitted output as an empty one), and a completed that counted a token
stays a reply.
Run: TestEmptyCompletedFailsOver (new) red on
|
||
|
|
dac759e54c |
site: a contributors page, everyone magpie's history credits with the releases that came of it (packinggoodsllc_07668 on Discord)
usemagpie.ai/docs/contributors, /docs/zh/contributors and
/docs/ja/contributors list each person the release notes' thanks line
would (the previous commit's rules), with the versions their reports,
ideas or code went into, newest first: three shown, the rest under
"N more", each linking its release. A name with a known GitHub login
links it; the platform a report came from (Discord, X, …) sits under it.
How it is built: wrangler.jsonc's build runs `node credits-cli.mjs wall`
at each deploy. It reads every tag's commits from git, the issue authors
from GitHub (reusing the last build's answers), and writes
public/contributors.json and the table in each language,
public/contributors/{en,zh,ja}.html (gitignored). worker.js puts that
table into the page's #wall with HTMLRewriter; without it the page keeps
a line pointing at the release notes. A build that can't read git leaves
the last list. The page says how names are found (only as already public
in the history, no emails, no maintainer, agents or bots) and how to be
left off: Discord, an issue, or a PR to site/contributors-exclude.txt.
Every docs page's footer and the home page's (foot.contrib in zh, ja, de)
link it. Styles reuse docs.css's table and tokens.
Run (mote, node 22): node --test site/*.test.mjs 77/77. The wall on a
clone of origin/main
|
||
|
|
08c761d456 |
release notes: each release thanks the people its commits credit (packinggoodsllc_07668 on Discord)
A release's notes ended with the install block and named nobody, though
the commits behind them credit their reporters. site/credits-cli.mjs
thanks <from>..<to> prints an English line and a Chinese one ("Thanks to
A, B and C, whose reports and code went into this release" / "感谢 A、B
和 C:…"), linking the contributors page, or nothing when no one is
credited. yetone/magpie-releases' publish job puts each at the end of its
language's part (that repo's own commit).
Who is credited (site/credits.mjs, no imports so the worker can use it):
- a subject's brackets: "(NAME on Discord|X|…)", "(A and B on Discord)",
"(willz, Discord)", "(spotted by @login in #N)", a quote after ":" cut;
- the GitHub authors of the issues and PRs it names, #N, plugins#N,
plugins #N (GraphQL, GH_TOKEN, 100 a query); one GitHub can't give is
left out, never guessed, and a bot is no one;
- commit authors and Co-authored-by people, not the maintainer, agents
(Claude, Cursor Agent, Instinct Agent, glm-5.3-flash, a @localhost
address) or a merge. Emails only tell an agent apart; none is written.
A bare word ("(mrwl666)", "(axelburks)", "(#3305, LoKi)") is a person
only when it is a handle with digits or the same name is credited plainly
elsewhere: over the whole history that drops "Image #59", "#860 flake",
"memory, Osal", "Neon, Notion", "magpie-releases#18", "(P3)", "𝕏 user".
site/contributors-exclude.txt leaves out whoever asks.
Run (mote, node 22): node --test site/*.test.mjs 74/74 (credits.test.mjs
12, real subjects from git log as fixtures). The thanks CLI on a blobless
clone of origin/main with a real token: v0.1.2579..2580 → Chixi_Fang;
v0.1.2560..2569 → faketrader, skygunner, vincent (#3656's co-authors),
StringKe (#3491), qikamatata, axelburks, infinitex233 (#4532),
samson910022 (#4738), each checked against the commits; v0.1.2578..2579
→ nothing. The release step's own script run there with VERSION=0.1.2580:
the English line after Install, the Chinese after 安装 (DeepSeek stubbed),
no line on a ref without the script, a warning and no line when the CLI
exits 3.
Broken by hand: the agent/model co-author check removed → test 8 red;
Markdown escaping removed → test 10 red; the gate on unsure names in
credit() removed → tests 2, 3, 6 red.
Not tried: a real release run in magpie-releases (the next tag is).
|
||
|
|
c991733dca |
docs: the Claude bridge's tool_choice none, asides and cut-copy branches (bbfatx on X)
claude-subscription-bridge.md now describes the four commits before this one: - a tool_choice none turn is offered every tool, and what it may call is kept apart (subscriptionRun.allowed, mcpCall's refusal); - an aside of a run that was told tools neither retires the conversation's run nor is taken as rewritten (asideOf); - a branch is a cut copy of its run's session (cutSession), resumed in its run's mode (savedSession.tui), in place of --fork-session --resume-session-at, with the cache numbers measured on mote; the "-p because it is a branch" reason is only for a -p run's branch; - an interactive run behind a prompt suggestion is cut at the line before it (branchAt, lastLine/backLine/behindLine), not told whole. Verification lists the new tests. Run at this tree (mote, the whole stack 252006e87..this): - go test -tags nogui -count=1 -timeout 45m ./internal/gateway ./internal/claudetui: ok (gateway 1045.8s, claudetui 9.6s) - go vet -tags nogui, GOOS=linux go vet -tags nogui and GOOS=windows go vet of both packages: clean; gofmt -l internal/: clean Every symbol and test named was checked against the tree with grep. Not run: the full go test ./... ; queued behind other sessions' suites on mote, it was lost before it started. Not changed: gateway-sessions.md's --fork-session line, which is about Claude Code's own forks of a user's sessions, not the bridge. |
||
|
|
c079b9ad7e |
claude: an interactive run's side question is branched before, not told whole (bbfatx on X)
Claude Code asks for a prompt suggestion as the conversation plus one more user message (#1638). A claude -p run takes that aside and goes on; on the next real turn the bridge rewinds it to the line before the aside (behindKey/behindTurn and --resume-session-at). An interactive run ignores --resume-session-at, so the bridge aborted it and told the next turn whole to a new run: every turn after a suggestion wrote the whole conversation into the cache again. That is bbfatx's second suggestion (save a checkpoint at a history prefix and fork from the deepest one) in the one place where it rewrites the cache today. Now the run remembers the last session line it wrote before each turn (lastLine, backLine, behindLine). When the next real turn finds an interactive run behind an aside, the bridge cuts a copy of the run's session at that line before the abort removes the file (branchAt, the cut copy from the previous commit), and the new run resumes the copy in interactive mode and is told only the new message. Run (mote, at this tree): - go test -tags nogui -count=1 -timeout 30m -run "Claude|Bridge|ToolChoice|Subscription|Retire|Rewrit|Fork|Branch|Shelf|Shelve" ./internal/gateway: ok (70.7s) - go test -tags nogui -count=1 ./internal/claudetui: ok - gofmt -l internal/: clean Broken by hand (TestClaudeInteractiveSideQuestionBranchesBeforeIt): - the old code (HEAD 37ff7356f): red, the turn after the suggestion is "had 0 turn 1" (told whole to a fresh run). - backLine left "": red, "had 0". - cut at the run's last line (after the suggestion) instead of the line before it: red, "had 6". Not tried: a real interactive Claude Code prompt suggestion end to end; the test uses the fake claude with the helper stand-in. The cut copy itself was measured with real Claude Code 2.1.316 in the previous commit. Not taken from the suggestion: a general store of checkpoints by history prefix. The bridge already keeps one run per conversation and resumes it at the line it is behind; the only case that lost the prefix was the interactive aside, so only that case gets a cut. Prompt and system text sent upstream are unchanged. |
||
|
|
8215164296 |
claude: a branch is a cut copy of its run's session, in its run's mode (bbfatx on X)
A sub-agent's first request that answers calls another request already answered branches off the lead's run's session (branch). That branch was `claude -p --resume S --fork-session --resume-session-at U`, and claudePrint forced every branch to -p, because Claude Code's interactive mode ignores --resume-session-at (Claude Code 2.1.316 on mote: it resumes the whole session). Runs are the interactive mode by default now, so the lead's cache has the interactive prompt, and a -p branch of it read only tools and system from the cache and wrote the conversation again (measured on mote, sandbox HOME, 30 MCP tools: an interactive fork of a -p session read only tools and system; the other way round was not measured). With "Interactive only" no branch was made at all, and the fork was told the whole conversation. Now the branch's run copies the session's lines up to U into a new session file next to it, with sessionId set to the copy's id (cutSession), and resumes it with --resume <copy> in the mode its source run had (savedSession.tui). claudePrint keeps "branch" only for a branch of a -p run. Under "Interactive only" a -p run's session isn't branched. The run owns the copy, as it owns an unshelved session. The copy waits up to 2s for U's line to be fully written; if it never is, the turn is told whole, as before. claudetui's translator now passes each assistant row's uuid through, as -p does, so an interactive run's lines can be cut. Measured on mote with real Claude Code 2.1.316: a cut copy resumed interactively read 7648 and wrote 14; with -p it read 24009 and wrote 13. Run (mote-run, this tree): - go test -tags nogui -count=1 -timeout 30m -run 'Claude|Bridge|ToolChoice|Subscription|Retire|Rewrit|Fork|Branch|Shelf|Shelve' ./internal/gateway: ok 63s - go test -tags nogui -count=1 ./internal/claudetui: ok - go vet -tags nogui ./internal/gateway ./internal/claudetui; gofmt -l: clean Broken by hand (each red, then put back): - old claude_subscription.go and transcript.go (cutSession stubbed): TestClaudeForkBranchesOffTheLeadsSession interactive (branch ran -p), interactive only (told it whole), print (old flags), TestClaudeCutSessionCopiesAsFarAsTheLine and TestTranslatorTellsTheRowsUUID red - claudePrint's branch reason for every branch again: interactive and interactive only red - the copy taking the whole file: all three subtests and the cut test red - branch() refusing every run under Interactive only: interactive only red Not tried: a real fork sub-agent through the gateway. The cache numbers come from copying by hand with real Claude Code; the tests use a stand-in. Windows and WSL keep no session on disk, so they never branch, as before. Not taken from the suggestion: the fork's own runtime and TypeScript wrapper. The cut is done here at the one place a branch starts. |
||
|
|
85ab325d48 |
claude: a title asked between turns leaves the conversation's run waiting (bbfatx on X)
bbfatx on X: the Claude subscription bridge spends more of the quota than it should. While checking which of the suggestions cause real cache writes, this one turned up. A client asks a title or a summary between a conversation's turns, the conversation so far and a question more, with tool_choice none or with no tools. Such an aside cost the conversation its run, in one of two ways: - tool_choice none: the aside went to a run of its own, and retire, which lets go of the runs a new run carries the conversation on from, let go of the run the conversation waited in. - no tools: looseTurn's key has no tools, so the aside was taken as the conversation rewritten (#912), and the conversation's run went on with it, to wait at the aside afterwards. Either way the conversation's next turn found no run. A new Claude Code was told the whole conversation in one message, and all of it was written to the cache again. Now an aside of a run that was told tools neither retires it (retire takes the request; asideOf) nor takes it as rewritten. The aside is answered by a run of its own, as before, and the next turn goes on in the conversation's run. A client with no tools at all is unchanged: asideOf holds only for a run that was told tools. Run (mote, go1.26.8): - go test -tags nogui ./internal/gateway -run TestClaudeAsideLeavesTheConversationsRun -count=1: ok. - go test -tags nogui ./internal/gateway -run 'Claude|Bridge|ToolChoice|Subscription|Retire|Rewrit' -count=1: ok (75s). Broken by hand: - HEAD's claude_subscription.go: red. With none, the next turn went to a new run told it whole. With no tools, the title went on in the conversation's run. - The rewritten check only: red (no tools). - The retire check only: red (both). Not tried: a real client's title request on a real account. The aside still costs one new Claude Code told the conversation whole. The next commit branches it from the run's session instead. |
||
|
|
e02df9e226 |
claude: a tool_choice none turn is offered the client's tools, and may call none (bbfatx on X)
bbfatx on X: the Claude subscription bridge spends more of the quota than it should. Suggestion 1 was to keep a turn's tool definitions apart from whether it may call them. bridgeTools dropped every tool for tool_choice none. Anthropic caches a prompt as tools, then system, then messages, so such a turn (a title or summary asked with the tools as ever) was a prefix the cache had never seen. All of it was written again, Claude Code's own tools and system prompt included. Now a none turn's MCP helper offers every tool the client sent. A call the turn makes anyway is answered at once with an error result (mcpCall), and toolStart treats it as Claude Code's own call, as it does magpie's web search. The client never sees it, and the reply goes on in words. A named tool_choice still offers only that tool. The allowed set (subscriptionRun.allowed) is set for each turn: at start, on resume, and with tool results (a client may choose none once it has its results). The system prompt and the turn's text are unchanged. Measured with the real Claude Code 2.1.316 on mote, in a sandbox HOME and CLAUDE_CONFIG_DIR, against a stand-in Anthropic that counts cache reads and writes the way Anthropic's cache does (30 MCP tools): - the same turn with no tools: 0 read, 7595 written; - told whole in a new session with its tools: 15780 read (tools and system), only the history written. Run (mote, go1.26.8): - go test -tags nogui ./internal/gateway -run TestClaudeToolChoiceNoneKeepsTheTools: ok. - go test -tags nogui ./internal/gateway -run 'Claude|Bridge|ToolChoice|Subscription' -count=1: ok (54s). Broken by hand: - HEAD's claude_subscription.go: red, the helper was offered [], the call was not refused, and the client was shown a tool_use. - Only the refusal turned off (mcpCall and toolStart): red, the call was shown to the client. Not tried: a real client's tool_choice none request through the gateway to a real account. The measurement drove Claude Code directly. Not taken from the suggestion: nothing of the fork's code is ported. The fork drops a none turn's tool calls in its own runtime. Here the call is refused where magpie already answers its web search. The only new text upstream is that refusal, a short tool error result naming neither magpie nor a vendor, and only when the model calls a tool anyway. |
||
|
|
1adff37796 |
claude: a refusal Claude Code falls back from goes on to the fallback model's answer (Chixi_Fang on X)
Claude Code 2.1.316 doesn't end a turn at a refusal. It asks the same
model again, then its fallback model (claude-opus-4-8 for Opus 5.5),
whose answer ends the turn with result success. The bridge ended the
reply at the first stop_reason refusal, so the client got "Partial "
plus a refusal, and the gateway's hw.refused moved to another account
or handed the refusal back. That is the "model error" the reporter saw.
readOutput now holds a refusal from Claude Code's own model and goes on
with the next message as one reply. Not held: a client tool call, or a
schema reply. The refusal's stop_details are held too. The refusal is
told only if it stands: at a result with no API status (Claude Code's
model_refusal_no_fallback, -p or TUI) or at the end of output. Then
hw.refused and b01766d13 see it as before. A result with a status after
a refusal is that error, not a refusal. The continuing message's model
goes on the KUsage as Model and Served. The try records the fallback
model, and a reply told whole names it. A stream's message_start can't
change it. Prompts and system text sent upstream are unchanged.
Real behaviour: Claude Code 2.1.316 on mote, in a sandbox HOME and
CLAUDE_CONFIG_DIR, against a fake Anthropic upstream that refuses
claude-opus-5-5 (or every model). The -p and TUI stream-json lines were
captured and trimmed into the fixtures in
claude_refusal_fallback_test.go.
Run (mote-run, worktree at base
|
||
|
|
5416fdb76b |
agent: Claude Code on magpie keeps its MCP tools deferred (ENABLE_TOOL_SEARCH)
cybercaius on Discord (#help): the MCP router's 245 tools took 124K
tokens of a 341K context ("Magpie ×245" in Usage › Context). Claude Code
before 2.1.304 keeps tool search off behind an ANTHROPIC_BASE_URL that
isn't Anthropic's, so every router tool's definition went on every
request. 2.1.304 (10-19) turned it on for gateways itself, but a
conversation begun without it stays held off.
While Claude Code is routed through magpie, magpie now writes
env.ENABLE_TOOL_SEARCH="true" into ~/.claude/settings.json: Claude
Code's own documented switch, no prompt or identity change. The gateway
carries deferred tools to every upstream already (#2660,
withoutDeferredTools). It follows the auto-mode review's ownership:
magpie's value is stashed (claude.tool_search), a value the user set,
an empty one too, is theirs, and magpie's goes in desktopOnly/unroute.
T3 Code's magpie instance gets the same "true" in its environment
unless the user gave it a value there.
Not changed, filed as #4755: agents with no tool search of their own
(OpenCode, Gemini CLI, ...) still get the router's whole list; a lazy
router mode for them needs an owner decision. Not changed: Codex, which
already sends tool_search on magpie's catalog (0.165.0 measured: 14
tools, no MCP ones), and newmax/claudescience, which run Claude Code
through the SDK and set no gateway env of this kind.
Run:
- Real Claude Code 2.1.290 on mote, sandbox HOME, sandbox magpie serve
on 127.0.0.1:3563 built from this tree, a fake Anthropic upstream, a
245-tool stdio MCP server in the Library behind the router, wired
with `magpie claude up/fake-1`: first /v1/messages had 12 tools,
27,443 bytes of tools JSON (+~9KB of deferred names in the messages).
The same with magpie's ENABLE_TOOL_SEARCH taken out (the old
wiring): 266 tools, 245 of them MCP, 242,346 bytes.
- Without magpie, against a capture server: 2.1.200 to 2.1.303 send
every MCP tool (239-257KB); 2.1.304 to 2.1.316 defer them (~28KB);
ENABLE_TOOL_SEARCH=true in settings.json env or the process env makes
2.1.200, 2.1.260 and 2.1.290 defer them too.
- TestClaudeToolSearchOn, TestT3CodeToolSearchOn (new); #4755 filed.
- go test -tags nogui ./internal/agent on mote; GOOS=linux and
GOOS=windows go vet ./internal/agent; gofmt -l.
Broken by hand: writeSearch stashing nothing and writing nothing, and
T3's entry left out: both new tests red. The user-value check skipped:
TestClaudeToolSearchOn red on the user's "false".
Not tried: a real model loading a deferred router tool through
ToolSearch and calling it via magpie (gateway tests cover deferred
tools); Claude Code on Windows/Linux; T3 Code's real app.
|
||
|
|
726544eed7 |
browser: with two browsers connected, an agent lists them and picks one
With Magpie Browser in two browsers (Chrome and Edge, or two profiles),
every call went to the last to connect and nothing said there was another
(packinggoodsllc_07668 on Discord: which one is controlled?).
- Each connection gets an id (b1, b2, in connect order) and a name from its
User-Agent (Edge, Opera, Vivaldi, Yandex say so; Brave, Arc and other
Chromium browsers read as Chrome).
- browser_tabs action browsers lists them, * on the one calls go to; action
use with browser (an id, or a name only one has) moves this session's
calls there. Other sessions stay where they were; a browser that
disconnects drops every session's pick of it.
- With two or more connected, browser_tabs list says whose tabs it lists.
The default is still the last to connect.
Run (mote-run): go test ./internal/gateway -run Browser ok (new
TestBrowserMCPPicksAmongBrowsers, TestBrowserName); go vet, GOOS=linux and
windows go vet ./internal/gateway ok.
Broken by hand: forSession ignoring the pick, the new test red ("s1 after
picking chrome: ... b2's tabs (Edge 141)").
Not tried: two real browsers at once; the GUI still shows only the last
connected browser.
|
||
|
|
3cb8b17312 |
browser: two agents at once each work in a tab and tab group of their own
Magpie Browser kept a tab per session, but a session with no tab took the
tab the user was looking at, so two agents started together worked in one
tab, and every agent's tabs went in one "Magpie" group
(packinggoodsllc_07668 on Discord).
- A session whose first call finds the shown tab held by another session
gets a new background tab of its own.
- Each session's tabs go in a group of its own: "Magpie", then "Magpie 2",
"Magpie 3" beside other live sessions (session → group kept in
storage.session with the tabs).
- browser_tabs list marks another session's tab ~ and names each tab's group.
- A link that opens a tab moves the session that clicked it (t.by), not the
first session found holding the old tab.
- Instructions and the popup's hint say so; extension 0.1.1.
Run (mote-run, MAGPIE_BROWSER_CHROME = Playwright's Chrome for Testing
1234): TestBrowserToolsInARealBrowser and the new
TestBrowserSessionsApartInARealBrowser (two sessions, real tabs and groups)
ok; go test ./internal/browserext; ./internal/gateway -run
'Browser|MCP|Hub'; GOOS=linux and windows go vet of gateway, library,
browsermcp, browserext ok.
Broken by hand: the new test against the old background.js is red ("both
sessions work in t803211511").
Not tried: real Chrome/Edge with a user profile, a person watching the
groups; t.by with two sessions (the click test has one).
|
||
|
|
0b783b1ddc |
browsermcp: TestVisionBridgePassesLines takes the messages in any order
The bridge passes each stdio message from its own goroutine, so initialize, the notification and the call reach the fake gateway in any order; the test read the call's image at index 2 and went red on mote when the call landed first (images ["" ".../shots/a.png" ""]). It now checks every path and that the one image named is the call's, made absolute. Run (mote-run), with a 50ms hold injected before every message but the call: the old test red 3 of 3, the new one green 3 of 3; without it, go test ./internal/browsermcp ok. |
||
|
|
de74cb53f7 |
mcp router: each caller gets its own Magpie Browser session
The router keeps one backend per Library server for every agent, so all agents behind it shared one `magpie mcp browser`, one browser session and so one tab (packinggoodsllc_07668 on Discord: two agents through a remote router fought over one tab). - serveMCP gives a client that initializes an Mcp-Session-Id (nothing is kept or checked by it). - hubSession names each tools/call's caller: _meta magpie/session from a router in front, else hub-<agent>-<Mcp-Session-Id>. - The router passes it in _meta magpie/session to `magpie mcp browser` and to another magpie's router only (keepsSession); the bridge sends it as that call's X-Magpie-Browser-Session (callerSession). A call naming none goes as the bridge's own session, as before. Run (mote-run): go test ./internal/browsermcp; ./internal/gateway -run 'MCP|Hub'; ./internal/library -run 'TestHubTellsMagpieBrowser|TestKeepsSession|TestHubGivesMagpieImage'. ok. Broken by hand, each red: no meta from the library (library test), no Mcp-Session-Id from serveMCP and ignoring _meta in hubSession (gateway test). Not tried: a real remote router chain between two machines. |
||
|
|
5dfbca6274 |
cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can be read and set from the terminal. - internal/settingsapi holds the save the handler made: Merge (the carry of keys a page leaves out, moved verbatim from api.go, plus upstream's RouterNote line), the vision/imageGen/searcher checks, settings.Save's own checks, catalog.Touched. POST /api/settings and `magpie settings` both call settingsapi.Apply, so a value is checked and saved one way. It sits outside internal/gui so the nogui build has it. - `magpie settings` (list, the default, with value, default and choices; get; set; reset to settings.Defaults()), --json on list and get. Body sends the whole file with one key changed, so a key the save keeps when absent (noBird, refusalRetries, ...) is set even to off. A flag where a key or value goes, an unknown key (with near matches named) or a refused value writes nothing and exits 1; --help prints usage. - Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent changed on its own; what the save takes must equal Keys), TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed (each /api route has a command or a reason in notYet, which later stages shrink; 36 have one now). - Item 3 of the stage (per-provider CLI-only fields in the window) is left for stage 2. - The open app's in-process follow-ups (fonts, Dock, tray menu, alerts, language, update re-check) run only from the window's save: #4752. Run (mote, at the pushed head |
||
|
|
1c3591b5d1 |
guard: the local masking model reads text a third faster on amd64 (mrwl666)
mrwl666 (Discord #help, v0.1.2554, Docker on a 2-core EPYC) saw one
core at 100% for 2-3 s on every request with masking and AstrLink Guard
on, and took it for every message of a ~66k-token conversation being
scanned again. It isn't. Probed on the Linux VM (GOMAXPROCS=2, taskset
-c 0,1) with a 50-60 turn Chat session of ~4 KB tool results, ~240-270 KB
a body:
- rules masking (MaskJSON without the model): 5-11 ms a turn;
- the history is cached by hash (LRU + found-<rev>.bin), and a turn
hands the model only what it added. Bounded caps that at 4 KB;
- the request waits masking's 2 s defaultWait for the model on that
text, and guard.Cores() is 1 on a 2-core box, so one core runs the
int8 BERT at about 1 KB a second. That is the spike.
This change makes the model's CPU cheaper; it does not take the 2 s
wait away. AVX2 kernels for the int8 dot products (dot4, attention
scores), exp in softmax and the GELU epilogue, picked at start when
the CPU has AVX2, plus plain compares in place of the builtin float
min/max (a third of the non-matmul time, for their NaN/±0 rules).
Every float op is the same per lane and in the same order as the Go
code (release builds are GOAMD64=v1, no FMA), the int8 sums are exact,
mix32 and the softmax sum keep their order, so the model finds the
same spans with the same scores to the bit.
Numbers, Linux VM (AMD Ryzen AI MAX+ 395), one core of guard:
guard.Find on 4,247 bytes: 4.05 s before, 2.75 s after (same 20 spans)
turn 50-57 with the model: MaskJSON wall 2.0 s both (the wait), CPU
after the wait 0.1-3.0 s before, 0.0-2.0 s after
mote (M5 Pro, arm64, rules path, unchanged by this):
BenchmarkMaskLongSession chat 10.3-11.7 ms, responses 10.8-13.0 ms,
messages 12.1-13.9 ms per turn of a ~260 KB body
Tests:
- TestKernelsSameBits: the AVX2 exp/GELU/scores give Float32bits equal
to the Go code, edge values included. Broken by hand: swapping two
adds in the asm exp made it red (0x175156d6 vs 0x175156d5).
- TestMaxAndRangeAsBuiltins: maxOf/rangeOf agree with the builtins on
±0 and NaN. Red with maxOf's NaN check taken out.
- TestModelSameWithoutAVX2 (needs MAGPIE_GUARD_DIR): the real model
finds the same spans on ~6 KB of mixed text with AVX2 and with SSE2.
- TestSessionTurnReadsOnlyWhatItAdds (internal/pii): turn 61 of a
275 KB session, after turn 60, has the model read only turn 61's text
(5.2 KB for 4.6 KB added). It passes on the old code too: it guards
the claim above, not this speedup. Red (10.5 KB, earlier turns read
again) with the cache lookup in known() turned off by hand.
- BenchmarkMaskLongSession (internal/redact): Chat, Responses and
Messages sessions with large tool results, turn 61 after turn 60.
Run at this tree (
|
||
|
|
647323409e |
gui tests: TestColdTurnsTaken asks once the warm-up holds its turn (#4510)
The test closed `asked` and asked at once, while the warm-up's goroutine might not have taken its turn yet. The page then took the turn first, a right order, and the test called it "answered while the warm-up's step read". Its t.Fatal left the step blocked holding the turn, so with -count above 1 every later run waited to the timeout. The step now closes `holding` once it has its turn, and the page asks after that. sessions.go is unchanged. Run (mote): go test -tags nogui ./internal/gui -run 'TestColdTurnsTaken$' -count=200 -cpu 1,2,8 -race ok (35.7s). Broken by hand: coldTurn not taking a turn turns it red at once. |
||
|
|
4a4a82cd49 |
gateway: TestSearchAPIAsksAreLogged's query has no number a port can hold
The Linux box's full suite failed it: "the query's \"7781\" is in
usage.jsonl", where the only 7781 was the fake server's random port,
host 127.0.0.1:37817. Every row logs the host, so any query word made of
digits can match a port now and then. The query is letters only now; the
check that no query word reaches usage.jsonl is unchanged.
Run on mote at this tree (origin/main
|
||
|
|
344a59f9db |
gui: an unchanged Sessions poll answers Same without making the rows
The Sessions tab asks for every session each 15 s. When nothing had changed, the handler still copied the kept listing, made a row of each session, merged the gateway's sessions, read Codex's effort and the vias, encoded every row and hashed them, only to answer X-Magpie-Same. Over ~17k real sessions (69 GB of Claude Code and Codex history) that was ~140 ms of CPU and ~24 MB of garbage per poll. Now the handler keeps, per ?limit, what the last list it sent was made from: the sessions listing (sessions.ListUnless's number, which changes whenever the listing is made again, and at least once a minute), the usage log's version (usage.LogVersion), the user's usage aliases, and the agents' names and icons with the folders. An ask whose X-Magpie-Had is that list's tag, while all of these stand, gets X-Magpie-Same before any row is made or the listing copied. Anything else a row shows (a Codex thread's effort, a gateway title) follows within the minute the kept listing stands. writeJSONRows returns the tag it sent. Measured on the real history (a sandbox HOME with APFS clones of ~/.claude/projects and ~/.codex/sessions, 17,140 files), 30 polls of /api/sessions + stats + overview, the same script for both builds: before ( |
||
|
|
403323af7f |
claude: a switch waits for another magpie's runs in the account's directory (#4532)
StringKe's audit, item 2. claudeDirRun is an in-process RWMutex, so
`magpie accounts switch` from the CLI never waited for the app's /usage,
warm-up or keep-alive run in the saved account's directory: it handed
Claude Code the refresh token that run could still spend, and removed
the directory under it. And the gateway's hand-over let go only of idle
runs; a run in a turn when the switch came was kept for its next turn,
waiting up to idleLongest in the removed directory with the same token.
- inSavedClaudeDir also holds a lock file of its own beside the
account's directory (markClaudeRun, <dir>.run-<pid>-<n>.lock,
filelock), removed as it ends.
- switchSavedLogin waits on every such file (waitClaudeRuns) up to
claudeRunWait (90s), then fails with errClaudeRunning and leaves the
sign-in as it was. A file whose run ended without removing it is free
and taken out.
- handedOver marks the account's runs in a turn (subscriptionRun.handed);
keepIdle ends such a run instead of keeping it.
Shelved (parked) sessions hold no process or token; a later turn starts
a new run under the account the gateway picks then, so nothing changes
there.
Run (mote, nogui):
- new tests TestClaudeSwitchWaitsForAnotherMagpiesRun,
TestClaudeSwitchRunHeldAndLeft, TestSavedClaudeRunHoldsItsLock,
TestClaudeHandOverEndsTheAccountsBusyRuns, plus TestClaudeSwitch*,
TestSavedClaude*, TestClaudeHandOver*: ok.
- Broken by hand (wait call, run mark and the handed check taken out,
helpers kept): all four new tests red ("switched while another magpie
ran Claude Code…", "got <nil>", "a left lock file kept", "run locks []",
"a run of the handed-over account was kept for its next turn").
- go vet darwin/linux/windows for provider and gateway: ok.
- Windows (win-run): the three provider tests and
TestSavedClaudeUsageKeepsRotatedSignIn: ok.
Not tried: two real magpie processes with a real Claude Code (the other
process is a second open of the lock file, which flock and LockFileEx
treat as another holder; filelock's own test covers a real second
process). Not covered, filed as #4750: a run queued behind the switch
makes the handed-over account's directory again, and a run in a turn
can still refresh during that turn.
|
||
|
|
b646a91277 |
gui tests: the Settings save guard sets BusyLoad (#4739)
TestSettingsSaveKeepsWhatItDoesNotSend has been red since
|
||
|
|
01ccbd40a0 |
library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same tools through their MCP router (/mcp/magpie/hub). An agent connected to both saw two identical web fetches and couldn't pick the one in Los Angeles to reach Google. Each router now says where it is: - initialize's instructions end "This router: <name>. Each of its tools' descriptions starts with [<name>]; ...", and serverInfo.title is "Magpie MCP hub · <name>"; - each tool's description in tools/list starts "[<name>] " (once: a description that starts so already, another magpie's router behind this one, isn't given it twice). <name> is the user's words (settings.RouterNote, one line, 80 characters at most) to every caller. With none it is this computer's name, to callers on other computers only: an agent on this computer has one router at hand, and its prompts stay as they were. RouterNote is this computer's own (KeepOwn): library.json is synced, settings.json isn't, so a sync never brings the other machine's name. It is set in the Library's MCP tab, in a Router name row under the router's address (shown while the router is on): a plain field with the computer's name as placeholder, saved on Enter or leaving it, Escape puts the saved words back, an input method's Enter is its own. POST /api/settings keeps it. Translated in zh, zh-TW, ja, de. docs/subsystems/mcp-router.md has the rule. Run (mote, at |
||
|
|
5a0c79ed9d |
i18n: ja for removing the agent's only account names {agent} twice, as zh does (#4580)
a7b47d57e's ja for "{agent} is signed in to {user}, the only account in
magpie it can be signed in to…" said {agent} three times ("magpie で
{agent} がサインインできる唯一のアカウント"), so gui-ja's "ja has every
zh string, with its placeholders and tags" was red on main. The third
is dropped: "これは magpie でサインインできる唯一のアカウントで", the
subject already being {agent} in the sentence before.
Run on mote at this head: node --test gui-ja.test.cjs and
i18n-keys.test.cjs, 7 pass, 0 fail (gui-ja was red 1 of 13 at
c903c3a41's base with the same file). Not tried: the sentence in the
running app.
Closes #4580
|
||
|
|
c903c3a411 |
usage: Use on Codex's window lands over 7 and 30 days, a model's own Compact at named apart (hoobnn on Discord)
hoobnn on Discord (11-01): "观测-用量-上下文里,在7天或者30天的选项里,点击
应用codex的上下文,没生效。" Over 7 or 30 days the range held calls on a
model whose provider has a Compact at of its own (430K); today's didn't.
Tuned for you's "Now" was the largest compaction point over every model
in the range, so it came from that model. Use put the advice in Long
conversations, which did move Codex's other models (Codex's list had
them at the advice), but the card still read 430K and then turned held
("compacts at its own 430K, which comes first"), so nothing seemed to
happen. And with Long conversations at magpie's default, a range of
only such models offered a Use that could move nothing.
codexWindow (internal/gui/tune.go) now reads "Now" from the models Long
conversations moves, and lists each model with its own Compact at as
Apart (largest first). Only a range whose every model has its own is
held (Own), whatever Long conversations says. The card names each
model kept apart under the row: "{model} compacts at its own {value},
which this doesn't move", in en, zh, zh-TW, ja and de.
provider.CompactSetIn is CompactSet with the caller's settings and
group finder, as CompactFor takes them.
Siblings: Claude Code's knob is per model (no max over models), so it
has no such mix. 1, 7 and 30 days go through the same codexWindow;
the GUI test covers 7 and 30 and the Go test the 1-day sample.
Run on mote at
|
||
|
|
822f526a63 |
claude: /usage's "Sonnet only" week is the Sonnet week (#4532)
Claude Code 2.1.316 names it "Current week (Sonnet only)", and claudeScopeModel made that the model word "sonnet-only", which no model id holds: the Sonnet week used up stopped no Sonnet request in routing, and it was a row apart from the "7 days · Sonnet" its seven_day_sonnet header keeps (StringKe's audit, item 4, second half). A trailing " only" is now dropped from the scope, so it reads "7 days · Sonnet", counts sonnet, and the header replaces it in place; the GUI's existing translation of the name applies too. Not changed (item 4, first half): a model's own week still doesn't move Claude Code's sign-in; usedPast counts windows that hold every model. Moving the sign-in for one model's limit is a design question left on #4532. Run (mote, -tags nogui): - TestClaudeUsageSonnetOnly: red on the old claude_usage_cli.go (Model sonnet-only, name "Sonnet only"), green now. - go test ./internal/provider -run 'Claude|Allowance|Routing' ok. - go vet darwin/linux/windows; gofmt clean. Not tried: a real Sonnet-limited account. |
||
|
|
7b6b7492a9 |
claude: an account on overages is read with its windows and switched off (#4532)
Claude Code's /usage line "You are currently using your overages to power your Claude Code usage…" was in claudeUsageDenied, so the whole reading became an error: the card lost its windows, and NextLogin, which stays on an account it can't read, left Claude Code billing overages while other accounts had room (StringKe's audit, item 3). Now the line is no error. The windows under it are read as usual, and a Text row "Extra usage" with Used 100 is added (claudeOveragesWindow), so usedPast/roomLeft count the account spent and the switch moves off it. The row ends when the last used-up window renews (the time Claude Code says it switches back), else at the next reading. Routing skips Text rows, so the gateway's own account choice is unchanged. The GUI says the row "In use" in the reader's language (quotaText; a plugin's text row keeps its display as it came). The overages case is out of TestClaudeUsageFailureDoesNotHideAccountErrors: it was the bug. Run (mote): - TestClaudeUsageOverages, TestClaudeSwitchOffOverages: red on the old claude_usage_cli.go (an error; switched to ""), red with the row's Used set to 0 by hand, green now. - go test -tags nogui ./internal/provider -run 'Claude|Usage|NextLogin|Next|Switch' ok. - GUI: claude-overages (new, 5 languages, chromium + webkit) red 8 of 10 on the old app.js (en passes there), green now; with quota-text-row, quota-name-translated, i18n-keys, usage-no-reading: 40 pass. - go vet darwin/linux/windows; gofmt clean. Not tried: a real account on overages; the text is Claude Code 2.1.316's string table, and the windows under it are what StringKe describes. |
||
|
|
9097687a31 |
gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account (#1515) was blurred like the account, so faketrader's several Antigravity accounts couldn't be told apart; and an Antigravity account whose value is "Google" blurred "Google" of its plan "Google AI Pro" on Usage and on the Providers row. The name the user gave an account is shown text, not an identity. The account is. - provider: a card's Alias says whether it is the user's own name (SubscriptionQuota.Named, set by withAccountNames from AccountNameOf), since Alias is also a plugin's name for an account (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the Usage page and tray panel may have no /api/providers to tell them apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared. - app.js names(): the user's own names (accountNames) and named aliases are no longer accounts to hide; accountUsers, an unnamed alias and a seat still are (noteAccounts keeps an alias without named). - app.js mask(): labels are scoped by element, never by value (LESSONS: scope an exemption by where the value sits). In .own-name, .plan, .acct-plan (the Providers row's plan pill, new class), .model-value and .subscription-head > b only an address is hidden; a plan's and a model's tooltip too (TIPS). The own name's tooltip ("name · account") is masked in full. - .own-name is set only where the text is the user's own: the editor's rename span when it has one (else it shows the raw account and stays hidden), Usage's quota-alias and the panel's pq-user when q.named. From skygunner's patch (95c0511 on |
||
|
|
39bade71d1 |
gateway: a plain <invoke> written into a reply's text is the call it is, on a relayed Messages reply too
packinggoodsllc_07668 on Discord (#general): Claude Code v2.1.316, magpie's routing group "Hard to strong, easy to cheap", asked to open Google in magpie's browser. The reply showed <invoke name="ToolSearch"><parameter name="query">select:…</parameter></invoke> *Result: Tool loaded.* <invoke name="mcp__magpie__magpie-browser__browser_navigate">…</invoke> *Result: Navigated to https://www.google.com — page title: "Google"* 已用 magpie 的浏览器打开了谷歌 ... as text. Nothing ran: the model wrote its calls and made up their results. Asked, the reporter said the group holds only Claude models (v0.1.2545). Cause: Claude wrote its own call form as text, and none of magpie's readers of written calls knew that form on the routes Claude takes. - The plain <invoke name=…><parameter name=…> shape (Claude's own calls, MiniMax's in <minimax:tool_call>, Claude's in <function_calls>) wasn't a mark: only <tool_call> and DeepSeek's DSML invoke were. - A reply relayed as it came on the Messages API (a group member on a provider that speaks Messages itself: MiniMax, Kimi, GLM, DeepSeek, Claude relays) was never read for written calls at all; the subsystem doc said so. Claude Code's request to such a member takes that route. - A Claude subscription member runs Claude Code itself (the bridge), whose textCalls held back only "[tool call …]" lines. Not the cause: history isn't flattened (tool_use/tool_result translate to native calls on every API), and this was the conversation's first turn. Fix: - textcalls.go: the invoke regexes take DSML's pipes, a namespace, or nothing; <invoke name=, <function_calls> and <minimax:tool_call> are marks; their leftover tags go. Text after a call read out, other than tags, ends the calls and goes with all after it: it is the model going on as if the call had run. This changes the old rule for every shape: prose after a Hermes call ("Done.") went on as text and now goes (TestTextWrittenCallCutEarlyNotCalled updated). - textcalls_anthropic.go: anthropicTextCalls in passthrough, for a streamed Messages reply (holds the text block's start and stop with the held text, adds tool_use blocks after it or in its place, stop_reason tool_use) and a whole one. - claude_text_calls.go: the bridge's textCalls also holds a line opening <invoke name= or <function_calls>, so the run is asked once to make the calls (textCallsAsk no longer names the "[tool call …]" form only). - Responses and Gemini relays still aren't read: #4743. Tests (textcalls_invoke_test.go), on the reporter's literal text: parse, a relayed Chat stream, a Messages passthrough through a routing group (streamed, with lead text, a lookalike left alone, and whole), and a Chat upstream translated for a Messages client. TestClaudeTextInvokeCallsAreMadeForReal: the bridge, bare and wrapped. Run: - On origin/main |
||
|
|
5d63b3f995 |
accounts: a Claude import never writes an older sign-in over a newer one (#4532)
Importing a claude-swap export of the account Claude Code was signed in to wrote the file's sign-in over Claude Code's own (addLogin, using). cswap exports what it saved when it last switched; Claude Code has refreshed since, each refresh spending the refresh token before it, so the file's was spent and Claude Code was signed out. A saved account was replaced the same way. Only an identical refresh token was caught. Now a Claude sign-in for an account magpie already has (Claude Code's own, or a saved one that can still be used) with another refresh token is taken only when the file's expiresAt is later than what magpie has, the account's own config directory counted (claudeNewerKept). Otherwise it is "exists" with why, nothing written. cswapEntry and loginEntry read claudeAiOauth.expiresAt. The CLI prints the reason. Run (mote, -tags nogui): - TestImportCswapKeepsNewerSignIn: older-than-live, undated, newer-than- live, older-than-saved. Red with the check turned off by hand (three subtests: updated over live / saved), green with it. - go test ./internal/provider -run 'TestImport|Login' ok. - go vet ./internal/provider ./internal/cli on darwin, linux, windows; gofmt clean. Not tried: a real cswap export against a real Claude Code sign-in. A sign-in that was itself imported and never run is saved with expiresAt 1 (so Claude Code refreshes it first), so any dated file still replaces it. |
||
|
|
d614f21721 |
gateway: a HEIC photo goes to the vendor as JPEG, or PNG with alpha (qikamatata on X)
Pi and Pi Desktop send an iPhone photo dragged in as image/heic, and
DeepSeek flash on WorkBuddy (a plugin's fetch) turned it away; most
vendors take JPEG, PNG, GIF and WebP only.
What: heicAsJPEG (heic.go) runs at the top of Server.serve, after
offAsNone, so every route below sees the converted image: a provider's
own, a plugin's fetch, the describer, every translation. count_tokens
does the same. It walks images through walkImages, the one image walker,
so it covers Chat image_url (string or object), Responses input_image,
Anthropic image blocks and Gemini inlineData, tool results included. It
goes by the bytes (ftyp + an HEVC still's brand), so a HEIC labelled
image/jpeg or image/png is converted too, and a JPEG labelled heic is
left alone. Other fields of the block (detail, cache_control) are kept.
Transparent images go as PNG, opaque ones as JPEG q90.
Cost: a body with no "image/hei" and no base64 ftyp mark ("eXB" + 5
chars, at the same place in any base64 that starts at the file) is not
walked. Caps: 48 MB of base64, 50 MP, the long side written at 4096 px,
one decode at a time, 30 s wait (a late result is cached for the next
turn), a 64 MB / 32 entry cache by sha256, since agents resend a
conversation's images every turn. Any failure, panic included, leaves
the image as it came. Measured on mote (M5 Pro): 12 MP 0.44 s, 24 MP
0.86 s, 48 MP 1.6 s / ~1 GB held, freed at once with FreeOSMemory.
Why gen2brain/h265 v0.2.4: pure Go (release builds are CGO_ENABLED=0),
MIT, no dependencies, SIMD on amd64 and arm64, maintained (latest
2026-10-29). Not chosen: gen2brain/heic (wazero WASM or a libheif dylib
through purego), jdeng/goheif (cgo libde265), OS converters (Windows
needs the paid HEVC extension, Linux tools are often missing).
Tests (heic_test.go, fixtures made on mote with sips, 1.6 KB each):
12 shapes converted with their kept fields, pixels kept, 7 non-HEIC
cases byte-identical, a cut file / a panicking decoder / a timeout go
as they came, and a plugin's fetch (fake plugin, new FAKE_SEES image
model) gets JPEG on /v1/chat/completions and /v1/messages.
Run at this tree (
|
||
|
|
0b7d5f3a20 |
claude: a switch waits for Claude Code's own refresh locks (#4532)
A switch read the sign-in it was replacing while Claude Code could be refreshing it. Claude Code 2.1.316 refreshes under two mkdir locks, <config dir>/.oauth_refresh.lock then <realpath(config dir)>.lock (~/.claude.lock), both stale after 60s, and saves the rotated pair with a compare-and-swap on the refresh token. So the outgoing account's token was not written over the incoming one, but magpie kept the outgoing account with the refresh token that refresh spent, and it was signed out of magpie on its next use. switchSavedLogin and addLogin (Claude) now take both locks the way Claude Code takes them (claude_lock.go: mkdir, touch while held, take over one untouched past the stale time, let go in reverse order) before reading the live sign-in, and hold them until the new one is written. putClaudeLogin's ~/.claude.json rewrite takes <real path>.lock (stale 10s), after the refresh locks, the order Claude Code saves in. A lock held past 20s fails the switch with nothing written. Read from Claude Code 2.1.316's bundled source: lgr/Cki/cl (refresh locks, owner record, retries), Vno (CAS write), gi (config save lock). Run (mote, -tags nogui): - TestClaudeSwitchWaitsForClaudeCodesRefresh (refresh/legacy/config) and TestClaudeSwitchStaleAndHeldLocks: red on the old code (switched while each lock was held; no error when held), green now. Also green on Windows (win-run). - Broken by hand: no stale takeover -> stale subtest red (20s, locked). - go test ./internal/provider -run 'TestClaudeSwitch|TestClaudeAccount|Login' - go vet ./internal/provider for darwin, linux, windows; gofmt clean. Not tried: a real Claude Code refreshing while a real switch runs (its refresh fires only near expiry). magpie writes no .oauth_refresh.lock.owner, so Claude Code takes over a lock magpie left only by its 60s stale time. The Library's MCP writes to ~/.claude.json don't take the config lock yet: #4747. |
||
|
|
66c0ddc19a |
gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)
axelburks on Discord: a vendor that queues reports loads past 100%, and
the only way to a threshold such as 150 was settings.json. Settings ›
Network and sharing › Busy models last now ends in Custom…, one more
choice in the same in-app switch (no <select>). It opens a small field
in the row whose sub says what the number means: a load in percent as
the plugin reports it, 100 is all the vendor serves at once, past 100
requests queue (200 is twice that), 1 to 9999. Enter or Apply saves it
through settings/busy-load, Escape or Cancel closes it untouched. A
value that is not a whole number from 1 to 9999 is said in red in the
sub and nothing is posted; the field keeps it to correct. The number
saved shows as its own choice ("Over 150%"), and Custom… opens with it
filled in. The site docs (en, zh, ja) and gateway-routing.md say
Custom… instead of settings.json. Code in plugins/gateway/settings.js
and i18n.js only, so the core budget is untouched.
Run on mote at this tree:
- node --test model-load, i18n-keys, bare-ids, gateway-port: all pass.
model-load's new test runs in Chromium and WebKit, at 420 and 900, in
en, zh, zh-TW, ja and de: Custom… focuses the field, says what the
number means, refuses abc, 0, 10000, 1.5 and -3 with nothing posted,
Escape closes, 150 posts {at:150} and shows Over 150% picked, 2000 by
Enter replaces it, the row and settings don't run sideways, and no
press moves the page more than the row changed height.
- go test ./internal/gui -run Budget: ok. gofmt -l: clean.
Broken by hand: validation turned off (if (false)) went red in every
language; the Custom… entry taken out went red in the old and new
tests; the field without flex:none was squeezed to ~20px and the width
check went red.
Not tried: the real app window (only Playwright's engines), and the
full GUI and Go suites, which run after the push (one suite on mote at
a time).
|
||
|
|
c688211d13 |
gateway: a ChatGPT (Codex) account gets loaded tools where they were loaded, keeping its cache (#4738)
infinitex233 (#4738, Discord): Claude Code -> magpie -> a Codex account, and every ToolSearch load dropped cache_read to 0. loadsInPlace sent the additional_tools item (#2660) only to OpenAI's own API, so for an account the loaded tool went into the top-level tools and the cached prefix broke at the tools. Tried on the real ChatGPT backend first (owner's account, sandbox HOME on mote with a copied auth.json whose refresh_token was replaced, so the live token was never rotated; ~/.codex untouched). A probe client sent Claude Code's shape: ToolSearch with two deferred mcp tools, then the tool_reference result, then the calls, 4 requests per run. - additional_tools item (on, and this commit's default): request 2..4 read 7680-8320 tokens from cache on gpt-5.6-terra, gpt-6-luna and gpt-6-sol; the model called read_a and read_b from the item; no "turned away additional_tools" in the log. - tools top-level (off): request 2 and 3 read 0 from cache (8044 and 8163 tokens in), as the reporter saw. So the backend takes it, and this makes it the default for a ChatGPT account (p.Account.Agent == "codex"). Copilot and other sign-ins stay off: not tried. - loadsInPlace: AdditionalToolsOff wins, then AdditionalTools, then an account is in only if it's Codex's, then OpenAI's API as before. - `magpie provider set <id> additional-tools=on|off|default`: off is new (AdditionalToolsOff, kept through an account's Save by accountSettings and through the GUI editor's save like AdditionalTools). The old "off"/"no" meant default; now they turn it off where the default is on. - The 400/422 fallback that names the item still applies, so a backend that stops taking it costs one retry and then sends tools top-level. - No prompt, instructions or identity line changed. Run (mote, at base |
||
|
|
8042d1bf3b |
provider: a signed-in account's settings go through one list, so Save keeps what withPicks reads (#4738)
infinitex233 (#4738, Discord): `magpie provider set codex additional-tools=on` said "saved" and changed nothing. Save rebuilt a signed-in account's entry from one field list and withPicks read it back from another; AdditionalTools was on neither. The two lists had drifted in both directions, so the same class hit other settings on every subscription account (Codex, Copilot, ...): - written, never read back: QuotaRest, QuotaResetAt, RestCap. The gateway never saw them on an account, and the next Save of anything cleared them, since Save starts from Find. - read back, never written: ExtraBody and ReplyHeaders. A Codex account's extraBody (magpie-releases#18), written by hand, was wiped by the next editor Save. - on neither: AdditionalTools, LimitRestOff, Patience. Fix: accountSettings is the one list. withPicks is it, and Save's account branch builds {ID, Key, Hidden, Quiet, Tucked} and runs it, so a field added to one is in both. Run: - New TestAccountSettingsKept (codex and copilot accounts): sets AdditionalTools, ExtraBody, ReplyHeaders, QuotaRest, RestCap, LimitRestOff and Patience, Save, Find, then clears them. Red on the old provider.go (every field lost on both accounts), green now. TestAccountPriceRateKept still green. - Real CLI path in a sandbox HOME on mote: `magpie provider set codex additional-tools=on` wrote "additionalTools": true to providers.json and the running gateway used it (see the next commit for the backend). - Suite record for this and the next commit together is in the next commit's body. |
||
|
|
9feb1024c7 |
zen: free models are asked as OpenCode 2.2.5 asks them (#3491)
laomao04_65777 on Discord: Zen's free models answered 429 "Free usage limit reached. Free models work in OpenCode" to the built-in OpenCode Zen provider, while real OpenCode 2 on the same machine was served. magpie sent OpenCode 1.x's shape. It now sends what OpenCode 2.2.5 sent in a captured request (internal/provider/testdata/opencode-2.2.5-chat.json, from a recording proxy), as the zen-free plugin does since plugins d62193c and 8501988: - User-Agent opencode/latest/<v>/cli. <v> is the version OpenCode's updater (opencode.ai/update/api/latest/cli/npm) names, never below 2.2.5 and never anything but a plain x.y.z. It is read in the background at most every 6h, with a 3s timeout and no redirects. - x-opencode-project is OpenCode's project id for the folder the agent says it works in: sha1 of git-remote:host/path (origin, else the first remote; worktree .git files followed), else of directory:<root or folder>. It is no longer "global". - b3 and traceparent: one trace a conversation, a new span a request. - The session id goes in x-opencode-session, x-opencode-session-id, x-session-affinity and x-session-id. Accept is */*, and x-opencode-request is gone. - On a free request the agent's own headers (Claude Code's x-stainless-*, Codex's originator) are dropped. Only Content-Type and Anthropic-Version and Anthropic-Beta are kept. - The core tools are edit, glob, grep, read and shell with 2.2.5's schemas, strict false on Chat. Claude Code's Read, Edit, Glob and Grep are offered under those names. Its Bash is no longer bash: shell is a stub. - OpenCode's <env> block, word for word, for the agent's folder, is added to the system prompt unless it has one already (OpenCode's own). - Paths are the v2 catalog's: /inference/openai/v1 for Chat and Responses, and /inference/anthropic/v1 for Messages. The models list is unchanged. Every route takes this: chat, responses and messages through forwardOnce, the Test button's probe (tiny/zenFreeProbe), and the models list (listHeadersAt: UA and x-opencode-client). Sibling: paid Zen and OpenCode Go share OpenCodeClient, so they get 2.2.5's headers. Their /zen/v1 and /zen/go/v1 paths are left as they are: #4740. Run on mote (mote-run) at this tree: - gofmt -l . is clean. - GOOS=darwin and windows go vet ./... pass. GOOS=linux go vet passes for internal/provider and internal/gateway. The whole-tree Linux vet stops in Wails' cgo when run from macOS, and in WSL for want of gtk4, before it reaches this change. - go test ./internal/provider ./internal/gateway -count=1 -timeout 45m: ok provider (154s) and ok gateway (715s) on base |
||
|
|
4c815ac2a5 |
search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)
axelburks asked for more than one searcher, so that when one fails another provider searches. A searcher named in Settings gave way to no other provider before, only to the Search APIs. Automatic already fell back to up to three. - settings: SearcherThen, the searchers after the one named. Entries are trimmed. Blanks, "off", the named one and repeats are dropped. - gateway: when the named searcher fails (the context still live), modelSearch asks each of SearcherThen in order and skips one that can't search now or is the same model. The first that searches answers, and the call is marked searchingInstead, so the Routing row says why the named one didn't search. If all of them fail, their errors go back together, saying "the searchers picked ..., in their order", and webSearch goes on to the Search APIs as before. SearchFailure.Instead names the one that searched in its place. - gui api: searchFailed.instead. A save takes only searchers that Searchers() offers. A save without searcherThen keeps the list, since the page's prefsKeep doesn't send it, and [] clears it. - Settings › Web search (plugins/search/settings.js, outside app.js's budget): an "If it fails" row under a named searcher, with numbered chips and Add. A chip's picker changes the chip or removes it. The row is hidden for Automatic and Off. The failure line names who searched instead, or says the ones after it failed too. The help text says the same in en, zh, zh-TW, ja and de. - docs: gateway-routing's failing searcher, and gui-shell. Tests: - TestPickedSearchersInTheirOrder (gateway): one test where the named searcher answers without searching and one where it fails. A gone entry and one that can't search are skipped, and the third searches once. With no working entry, the error says so and Instead is empty. - TestSearcherThenSaved (settings) and TestSearcherThenFromSettings (gui): what is saved, kept and cleared; refusing an entry that can't search. settings_keep_test sets SearcherThen. - searcher-then.test.cjs: chromium and webkit, en, zh, zh-TW, ja, de, at 560 and 1000 wide. Checks the row's place and words, what Add offers, the posted lists, that the chips fit with no horizontal scroll, that no click moves the page, and both failure lines. Broken by hand: running no fallback turned TestPickedSearchersInTheirOrder red (both subtests: "ds2 searched []"). Not keeping the list on save turned TestSearcherThenFromSettings and the keep test red. Run on mote (mote-run): - At the pre-rebase tree (base |
||
|
|
0b4aa96fd0 |
gateway: a relay whose models are typed in by hand is offered as a searcher (axelburks on Discord)
axelburks added a custom provider on OpenAI's Responses API and ticked "Searches the web by itself", but Settings › Web search's searcher picker didn't offer it. Searchers() and namedSearcher took a provider's models from Available() alone. A relay with no /models list has its models typed in by hand (Exposed) and none available, so it was left out of the picker, while the same row named it among the relays to pick there. searcherModels gives what the provider lists, then the hand-typed ones it doesn't. A relay that lists its models was offered before this already. Tests: - TestSearcherRelayWithoutModelList (gateway): a Responses relay with no /models and a typed model is a searcher and is resolved by name. - TestSearcherPickerOffersResponsesRelay (gui): the relay saved the way the editor saves it is in SearchChoices with its model. Both were red on the old code. Run (mote-run), at this commit alone: go vet of gateway and gui, and go test -run 'Searcher' of gateway and gui: ok. The full checks ran with the next commit; its body has them. Not tried: the reporter's own relay (we don't know whether it lists its models; the reply asks). |
||
|
|
ed0ad52821 |
gui tests: a picker's item is pressed once the list is drawn for good (#4274)
A model picker draws its list again when its first read of
/api/model-speeds answers (readSpeeds, once a minute and after every
load). searcher-pick's click found the Automatic item after a reload,
the list was drawn again under it, and Playwright gave a null box for
the detached item: "Cannot read properties of null (reading 'x')" at
line 319. reader.cjs's pickItem finds the item again each frame until
its box is the same twice, and presses it there; searcher-pick's click
uses it.
Run on mote (mote-run), chromium, searcher-pick "the provider that
searches..." en and zh:
- origin/main
|
||
|
|
e62a1bc515 |
routing: a trail is drawn in its own agent's colour, and agents on screen don't share one (Pkh)
Pkh (Discord, 0.1.2509, Linux) saw trails in another agent's colour, and different agents drawn alike, on the Routing page. Causes, read in routing/client.js: - Wrong colour: render() coloured a lit row by row.rid, the latest staged request that weighed the seat, not by the request actually on it. With Codex answering and ZCode's request staged later, Codex's trail was drawn in ZCode's colour, and the fold, group and flows layers copied it. - Stale colour: --agent was set when a row lit and never cleared, so a reused row or fold wire kept the last agent's colour. The panel's ps-out wires did the same. - Collisions: hueOf gave 15 makers their own colour and hashed the rest into 8 spares. 49 of 59 agent ids fell into those 8. QwenPaw, ZCode, Qwen Code and AstrBot were all #65a30d. Change: - A row's colour is the agent it answers now (trying), else the agent whose request is on its wire (flying), else the request it answered. It is cleared when the row is off. Folds and groups copy it through tint(), which clears too. A ps-out wire clears when its trip ends. - One PALETTE of 12 quiet colours, same lightness and chroma around the wheel, none near --red. HUES is a maker's place in it. hueOf gives each agent the first colour from its place that no other agent has had, and keeps it while the page is open. hues() keeps the agents shown together apart once more than 12 have come. Tests (red on the old client.js): - routing-reused-row-hue: Codex then ZCode on reused rows. Lit and flows colours are each agent's own, and off wires carry no colour. - routing-agents-apart: four agents on screen at least 20 degrees apart in OKLCH hue, and the same colours after a fifth request. - Both run in Chromium and WebKit, in every language, at 1100 and 420/390 widths. - routing-agent-hue-not-red now reads PALETTE. Broken by hand: - Without the removeProperty, routing-reused-row-hue is red. - With by = r.agent, it is red. Run (all on mote, macOS 27): - The whole GUI suite, Chromium and WebKit, at concurrency 6, at base |
||
|
|
f506638690 |
sessions: the Sessions poll makes its rows as the gateway's sessions merge
/api/sessions copied every one of ~17k sessions into MergeExternal's
merged list, and MergeExternal made a set of every native session's
keys again to leave natives out of the gateway's, though
GatewaySessions had already left them out by the same keys. The rows
were then copied from that list.
EachMerged hands each session to the caller in MergeExternal's order
(newest first, a native before an external of the same moment) from
the list as List gives it and the gateway's sessions sorted alone, so
the handler copies each session once, into its row. MergeExternal
keeps its own copy and dedupe for its other callers; both share
externalSessions.
TestEachMergedListsWhatMergeExternalDid: same rows, field for field, as
MergeExternal for a sorted list, an unsorted one (sorted in a copy, the
caller's left as it was) and none; with and without externals; ties;
stops at false. TestEachMergedCopiesNoList: 5000 natives merge in under
a twentieth of the list's bytes. Broken by hand, each red:
EachMerged over MergeExternal's list: 5,437,624 bytes for a
2,480,000-byte list
EachMerged making the native key set again: 394,352 bytes
Measured on mote's build against the real ~17k sessions (sandbox HOME,
APFS clones), 30 polls, against v0.1.2554's build:
heap diff alloc_space 726 MB -> 701 MB (MergeExternal's 107 MB
gone; externalSessions 51 MB left, the
gateway's own sessions)
CPU over 30 polls 4.44s -> 4.24s
/api/sessions median 73ms -> 71ms
Run on mote: go vet ./internal/sessions ./internal/gui ok;
go test ./internal/sessions ok; ./internal/gui red only in
TestSettingsSaveKeepsWhatItDoesNotSend (#4739) and
TestMainWindowCorners (#3949), both red on origin/main
|
||
|
|
994cd4fb68 |
gui: Rex switches to the tab magpie opens, through the app's session.select (#4565, StringKe)
StringKe tried v0.1.2446 on the real Rex app (Rex Beta 0.1.0 (1696)):
the tab opens, but the app keeps showing the tab the user was on. The
new tab shows only in the sidebar, and `open -b` only brings the window
forward. The app's own session.select action, sent to the app client,
does switch to it.
After `rex run` (reused magpie session) or `rex new` (now with --json,
for session_id and initial_windows[0].window_id), openInRex brings Rex
forward and then calls rexSelect. rexSelect reads `rex client list
--json`, takes the client of info.kind "app" whose session_ids hold the
session, else the last app connected, and skips one whose
connection_state is "lost". Then it runs `rex -C <client_id> do
session.select session_id=<id> window_id=<window>`. App actions need
Remote Control on in Rex's settings. With no app, a failed list, a
refused do or no answer within 3s (rexSelectWait), the open still
succeeds, the same way a failed rename is ignored. docs/reference.md's
Rex paragraph says this.
Command shapes come from the real rex CLI, snapshot 0.0.1793420730-
g6d0d9a, on mote with a sandbox HOME and XDG_RUNTIME_DIR: `rex --help`
(-C is a global flag, label or ID), `rex do --help`, `rex client ls
--help`, `rex api describe client.list` (client_id, info.kind
app|cli|agent|other, connection_state connected|lost, session_ids),
`rex new --json` output. With no app connected, `do` without -C exits 3
("no app client is connected"), and -C <unknown> exits 3. A client that
doesn't answer keeps `do` waiting 10s ("did not answer within 10s").
That is why the select runs after open -b and has its own 3s bound.
Tests: TestOpenInRexSelectsTheTab runs a fake rex program (a sh script,
so arguments go through a real exec), with a new session and with
magpie's session reused. It checks that the app attached to the session
is picked over another, that a lost app is never asked, and that no
app, a failing client list, a refused do (exit 1) or a do that never
answers (exec sleep 30, killed at the bound) leave the open a success
within its time. The in-process fakeRex answers client list (no app)
and new --json. TestOpenInRexReal runs these paths against the real rex
server, with no app client.
Ran, through mote-run, on this tree before the rebase onto
|
||
|
|
1e6a27d4f8 |
gui: an icon's image URL typed and saved is fetched, kept and shown again (hoobnn)
hoobnn on Discord #general: a custom provider's icon given by an image URL was neither fetched nor applied, and on editing it again the URL was gone. Cause: the Image URL… box ( |
||
|
|
a5a9cdf7be |
gateway: a refused big conversation isn't told again to the Claude subscription's other accounts (Aisiverto on X)
Aisiverto on X: a refused turn of a ~900K-token conversation made magpie switch accounts and send it again, "one user action becomes several expensive requests". In the usage, pairs ~100ms apart: one read the whole conversation from the cache, the other read ~26K and wrote ~877K. The cause: a refusal goes to the next candidate under RefusalRetries (unset: every one left), and matesFirst puts the same model's other accounts first (#248, where a verified account may answer). For a Claude subscription each other account is a new Claude Code told the whole conversation, all of it written to that account's cache again, for a refusal about the content that it most likely gives too. Now, before a Claude subscription account's try, a conversation of retellMost (100K) tokens or more by estimate (tooBigToRetell) leaves the subscription's other accounts out if that account refuses (otherThanClaudeAccounts). Other members are still asked; with none left the refusal is the agent's, and it isn't handed over mid-stream to nobody (handsOver is given last). A smaller conversation goes to the next account as before. The size is measured only when another Claude subscription account is left. gateway-routing.md says so beside RefusalRetries. Run: - TestClaudeSubscriptionBigRefusalNotToldAgain (new; streamed and not): red on the old code (runs "own,tok-spare"), green with the fix, the agent getting the refusal. TestClaudeSubscriptionRefusalMovesToNextAccount (small conversation, spare still asked), TestRefusalRetries* and TestPolicyRefusal* green. - Broken by hand: tooBigToRetell always false, red. - On mote: gofmt -l clean; go vet, GOOS=linux go vet -tags nogui and GOOS=windows go vet of internal/gateway ok; go test -tags nogui -timeout 45m ./internal/gateway: ok (702s). The whole suite ran at the parent commit (its body); this commit touches internal/gateway only. Not tried: - The handsOver change: the test's refusal comes with no reasoning before it, so nothing is handed over, and taking the change out stays green. Not covered by a test. - A large conversation where another member of the group is a Claude subscription of a different provider id: it is left out too, as every Claude subscription account is. - A real Claude refusal on a real account. |
||
|
|
2af4d8c62d |
claude bridge: tool results another request answered first branch off the run's session (Aisiverto on X)
Aisiverto on X: a Claude Pro account's five hours went from 96% left to
1% in about five messages of a ~900K-token conversation. The usage had
pairs of requests about 100ms apart: one read ~900K from the cache, the
other read ~26K and wrote ~877K.
The cause: Claude Code's fork sub-agents start from their lead's
conversation, each of the lead's calls answered "Fork started", and they
come with the lead's own next turn. One of them goes on in the run that
made the calls. Each other one (and a resend, or one after the run has
delivered) got a new Claude Code told the whole conversation in one
message, a prefix Anthropic's cache had never seen. So it was written
to the cache again, about a fifth of the plan's five hours each time.
Now the run keeps where in its session each call of the client's tools
was written: the uuid on Claude Code's stream-json assistant line
(noteLines). As it parks, it also keeps the conversation those calls
answered. A request no run takes, whose last reply's calls a live run of
the same owner made from the same conversation, goes on in a -p branch:
--resume <session> --fork-session --resume-session-at <uuid>. That is the
conversation as Claude Code sent it to Anthropic, so it reads the
cache, and it is told only the results and the directive after them. The
lead's session file stays the lead's. There is no branch with client
cache marks, in interactive-only mode, or from a rewound, closed or
sessionless run. Then, and if the resume fails, the old path is taken.
The -p reason is "branch", worded in claudemode.js and i18n.js (zh, zh-TW,
ja, de). The subsystem doc's section says so.
Run:
- Claude Code 2.1.316 (real binary, on mote), against a fake Anthropic API and a
fake MCP tool. --resume S --fork-session works while another
process holds S. --resume-session-at <assistant uuid> cuts the copy
there even after the lead went on, and the prefix up to the tool_use
matches the lead's. Calls it answered nothing for get a
synthetic error result.
- TestClaudeForkBranchesOffTheLeadsSession (new): red on the old code
("told it whole"), green with the fix.
- Broken by hand, each red: park() not stamping the conversation the
calls answered; serveSubscription not asking branch().
- On mote, before the rebase onto origin/main
|
||
|
|
7503beee72 |
plugin, settings: a model's load goes past 100% for a vendor that queues (axelburks on Discord)
axelburks, on v0.1.2547: their vendor queues, so a model's load can be
past 100%, even 200%. magpie clamped every load to 100, and Busy models
last allowed 1-99 only.
- host.js reportLoad and plugin.noteLoads keep a load from 0 up. The
floor is still 0, null still clears it, and a sanity cap of 10000
(LOAD_MOST, plugin.LoadMost) keeps an absurd value from reaching the
UI or the trace.
- settings.BusyLoad takes 1 to 9999 (BusyLoadMost-1). The segment
choices stay Off/50/70/80/90, and a value set in settings.json (150)
shows as its own choice, as before.
- The editor's badge reads "180%". It is a badge, not a bar, so nothing
assumed 100 wide; the test checks it stays on one line.
- Docs: site plugins page (en, zh, ja) Values and Routing bullets, and
provider-plugins.md and gateway-routing.md.
Run on mote via mote-run, on origin/main 8d8df0639+ rebased:
- go test ./internal/plugin ./internal/gateway ./internal/settings -run
'ModelLoad|TestBusy' -v: all pass. TestPluginReportsModelLoad has
over:250 kept and huge:1e9 at 10000. TestBusyModelGoesBehind has 180
behind 120 at a threshold of 150, and 10000 refused.
- Broken by hand in a copy, with the old 100 clamps and the 99 limit:
TestPluginReportsModelLoad red ("ModelLoad(over) = 100; want 250"),
TestBusyModelGoesBehind red (150 refused).
- node --test model-load (with Queued 180% in every language, Chromium
and WebKit, 420 and 900, plus Over 150% picked at 420) and i18n-keys:
46/46 pass. go test ./internal/gui -run Budget: ok.
- gofmt -l: empty. GOOS=linux go vet -tags nogui and GOOS=windows go
vet on plugin, settings and gateway: ok.
Not run before the push (owner: push and tag first): go test ./... and
the whole GUI suite. They are queued on mote behind another session's
suite.
|