ac4af582301a4e8a29245dbba767eba31334ddf9
2027
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d432920f02 |
search: DeepSeek's Search API as a search API vendor (TJHHHH on Discord)
DeepSeek's own Search API (api-docs.deepseek.com/guides/search) can now be added as a search API, with a DeepSeek API key: - provider.SearchVendors: deepseek, at https://api.deepseek.com, keys at platform.deepseek.com/api_keys, offered after You.com. - askSearchAPI: POST /v1/tools/search, Bearer key (the default), body {query, count: searchHits}. The query is cut to the 128 characters the docs allow (a longer one is a 400); need_content stays false. - readSearchAPI reads its summary (the docs' text "for a model", ~600-800 chars) as the page's text, since content is empty without need_content; its snippet stands in when there is no summary, and its date (RFC 3339 or null) is the page's age. Other vendors' fields are read as before; summary and snippet are only fallbacks after content. - 402 (no balance) and 429 (5 QPS per account) already rest a key as out of credit and rate limited (searchRestFor); the test pins it for deepseek. - Siblings: CLI usage (main.go, search_cli.go's api list and empty-state hint), README.md, README.zh-CN.md, gateway-routing.md's path list. The GUI takes its vendors from SearchVendors (no vendor list in app.js or i18n), so no GUI file changes. Not tried against the real DeepSeek API (no key in this run); the fake is built from the docs' response shape, with null site_name/date and empty summary/content. Note DeepSeek bills direct API calls ($0.75 per 1,000 non-empty searches). Run (worktree on origin/main |
||
|
|
89521b03d6 |
cli, gateway: magpie cpu records the running magpie's CPU profile for 30s, for a report of high CPU (@LeiCheng42 on X)
@LeiCheng42 on X reports magpie using the most CPU while Codex runs. As with magpie heap ( |
||
|
|
2042123f43 |
provider: a provider switched off for a while stays in the groups magpie found, so agents on auto-<model> aren't rewritten to the one left (#2671)
timonwong (#2671, with the branch this is): a found group, auto-<model>,
was built from the providers that are on only, so switching off one of
its two providers took the group away. Every agent on group/auto-<model>
was reseated to the other provider's model (agent.Reseat → sameModel),
rules and groups naming it went 404, and switching the provider back on
brought the group back but not the agents' settings.
timonwong's change, ported as is (05927b833, 063fe15a2):
- models.go: entriesOf(of, off), and heldOffEntries(), the models of the
providers that are Ready and Off (a keyless one, a plugin not signed in,
finds no group), held per request like the other entries.
- group.go: foundGroups/foundFrom merge those back in the Providers order
before autoGroups, in groupsIn, DeleteGroup and RenameGroup. membersIn
already skips a switched-off member, and the Routing page already says
it as switched off (memberJSON.providerOff).
- A removed provider still leaves the group; NoAutoGroups and
ModelSameAs are honoured; a hidden found group stays hidden.
Side effect: a found group whose only usable member is left shows while
a provider is off, which is the point.
Reviewed line by line; nothing writes a user-set value, and Reseat now
has nothing to move for these agents, so there is nothing to restore when
the provider is on again.
Added here: TestReseatKeepsAFoundGroupWithAProviderOff (internal/agent:
Claude Code and Hermes on group/auto-gpt-5 are not moved when cop is
switched off, a model only cop served still is, the group resolves, and
switching cop on moves nobody) and TestFoundGroupMemberOfASwitchedOffProvider
(internal/gui: auto-x is on the Routing page with b/x said as switched
off). The docs row names the tests.
Red on bf931f82c's provider code (models.go and group.go from main): both
new tests, timonwong's TestFoundGroupWithAProviderOff (404 as in the
issue) and the updated TestProviderOff. Broken by hand (heldOffEntries
returning nil): the agent and gui tests and TestFoundGroupStaysWithAProviderOff
and TestFoundGroupRemovedWithAProviderOff go red.
Run at this change on
|
||
|
|
992f288e20 |
gateway: a Chat-only relay that refuses tools with reasoning and none too moves a group on (#2670, JJ-Lin)
JJ-Lin's analysis in #2670 found both causes and gave the mock upstream the tests use. A relay with a Chat URL alone answers tools with reasoning_effort with "use /v1/responses or set reasoning_effort to 'none'", and then refuses none ("Supported values are: 'low', ..."). - forwardTranslated: when none was #176's own and is refused naming the levels, offRefused is still remembered (it is true of the model), but the request isn't asked again at the lowest level (refused the same by the upstream's own word). The tools refusal is the answer. The #176 retry is gated on turnedAway(none) plus a per-request guard, so it can't loop. Before: the first request went [xhigh none low] and every later one [high], with the 400 going to the agent. - passthrough (a chat client's relayed request), the sibling: the same. It used to ask none on every request and hand back the confusing "'none' is not supported" error. - shapeRefused/retryable: a 400/422 that wrongEndpoint reads reaches the group only once the member has tried every API it has a URL for. The next member is now asked once, and this one doesn't rest (failShape). Before, the group stopped on it. - The agent's error still names the Responses URL the provider lacks (wrongAPINote via asksResponses). Reading supported_endpoint_types from /v1/models was left out: wrongAPINote already says what to set, and trying Responses on the Chat base unasked isn't clean. - docs/subsystems/gateway-routing.md says both. Plain chat without tools, and gpt-6-astra (where none is taken) are unchanged; TestToolsEffortNoneTaken pins both ([effort none] -> 200 three times in a row; no-tools [xhigh] -> 200). Tests (internal/gateway/tools_effort_none_test.go, JJ-Lin's mock): - TestToolsEffortNoneRefused: one Server, Codex xhigh/high/high asks [xhigh none], [high], [high]. Each answer is the tools refusal with the Responses-URL note. A chat client gets [high none], [high]. - TestGroupPassesOverToolsRefusedOnChat: group relay -> other. Three requests in a row are all 200 from other, tries[0] is failShape, no rest. Broken by hand: - fallback.go reverted: the group test is red (400 to the agent). - translated restore off: "request 1 asked [xhigh none low]". - passthrough check off: the chat client gets "'none' is not supported". - turnedAway gate off: "request 2 asked [high low]". Without the per-request guard too, it loops forever (seen, killed). Run on origin/main |
||
|
|
e183604f06 |
claude: a tool named with a dot comes back under the name the client declared (#2649)
tsy0716's client offers a tool named "spawn.agent". Through a Claude
subscription the reply's tool_use called "spawn_agent", a tool the client
never offered: Claude Code keeps only [A-Za-z0-9_-] of an MCP tool's name,
and magpie handed the call back under the name Claude Code used.
The MCP helper now offers each tool under bridgeToolName: a name Claude
Code keeps as it is (and at most 51, 64 with mcp__magpie__) is unchanged;
any other, or one ending as a changed name ends (_ and 12 hex digits), is
cut to 38 of [A-Za-z0-9_-] and given 12 hex digits of its SHA-256. So
"a.b" and "a_b" stay apart, and the name is the same in every run: a
resumed session, the history told to a new run (renderParts) and the
tool-choice line (toolChoiceAsk) name it as the run was offered it.
subscriptionRun.names maps it back to the declared name in toolStart (Claude
Code's streamed and whole messages, so every API the bridge serves) and in
mcpCall (what an agent like Cursor is told through onCall). A name Claude
Code already kept goes upstream exactly as before.
What was run:
- New TestClaudeToolNamesComeBackAsDeclared: tools "spawn.agent",
"fs/read", "has space", an 83-character name, "a.b" and "a_b", through
/v1/messages, chat/completions and responses, client stream on and off,
Claude Code's reply streamed and whole (12 cases); a fake Claude Code
that changes names as Claude Code does and calls every tool it was
offered. Checks the client gets exactly the declared names, and Claude
Code was offered six valid, unique names of at most 51; and the history
and tool-choice text use the offered name.
- Broken by hand: with the encoding taken out the test fails; with only
the decoding in toolStart taken out, every case fails ("the calls name
[a_b a_b_2e7336dc8eba fs_read_96379919f693 ...], want the declared").
- go test -run 'Claude|Bridge|MCP|Mcp|Tool' ./internal/gateway/
./internal/claudebridge/: ok.
- gofmt -l clean; go vet -tags nogui ./... on darwin, linux, windows: ok.
- Full suite at this head (8b1fad8f5 before the message change), as
recorded in the #2651 commit: ok but three timing reds outside this
change (#2719, #1889, and one fixed on main by
|
||
|
|
f550d3699c |
claude: a SOCKS proxy reaches Claude Code through magpie's HTTP bridge (#2651)
demystify0137's Claude account sits behind a socks5:// proxy. Every turn was answered 502 after minutes of retries, Claude Code failing each try as UnsupportedProxyProtocol: it is a Bun binary, and Bun takes only http:// and https:// proxies. magpie handed it the socks5:// URL as HTTPS_PROXY. Every Claude Code magpie runs for the subscription now gets its env from one helper, netproxy.EnvForBunWith, which sets the proxy as before and puts the loopback HTTP bridge (netproxy.Bridge, #1409) in place of a SOCKS URL: a turn (startRun), the model test (askClaude), /usage (claudeUsage), sign-in (startClaudeSignIn) and the sign-in check (claudeSignedIn). Where the bridge can't be used (it doesn't start, or Claude Code runs in WSL under NAT, which doesn't reach this computer's loopback) the request fails at once with that reason, instead of Claude Code retrying for minutes. Other CLIs magpie runs with a proxy (grok, devin, cursor-agent) aren't Bun (checked their binaries), and the settings.json env writer already leaves SOCKS out. What was run: - Real Claude Code 2.1.302 in a sandbox HOME with a fake API key, through a fake SOCKS5 proxy (temporary test, removed): raw socks5:// gave "API Error: Unable to connect to API (UnsupportedProxyProtocol)" with 0 SOCKS connections; bridged it reached Anthropic, 401 "Invalid API key", 7 SOCKS connections. - New tests TestEnvForBunWithBridgesTheProvidersSOCKS, TestClaudeCodeGivenTheBridgeForASOCKSProxy (turn, askClaude, claudeUsage), TestClaudeSignInBridgesASOCKSProxy. With proxied() put back to EnvWith both gateway and provider tests went red ("Claude Code was given the SOCKS proxy: https=socks5://127.0.0.1:1...", "login-proxy: Claude Code ran with HTTPS_PROXY=\"socks5://127.0.0.1:1\""). - gofmt -l clean; go vet -tags nogui ./... on darwin, GOOS=linux and GOOS=windows at 8b1fad8f5: ok. - Full suite at 8b1fad8f5 (this and #2649 on origin/main |
||
|
|
717b69f78a |
routing: a conversation held to its native compaction's account says so, not "the only account on" (#2639)
A turn carrying a native compaction goes only to the account that
sealed it, so the route's order has one account, and Routing's first
line read "{who} is the only account on for {model}". On #2639 that
read as the other account not serving the model. The route now names
the sealer (Route.Compaction, compactionWho), and Routing says the
conversation stays on it because only it can read the compaction, and
that a new conversation uses the others. Translated in zh, zh-TW, ja
and de.
Run on origin/main
|
||
|
|
04e8aa8f10 |
library: typing with an input method no longer moves the page (#2636)
In Library -> Instructions, typing Chinese through an input method made the
page jump up or down while a word was composed. The cause: the textarea's
autosize set height:auto to measure scrollHeight, so the page went short for
a moment and the browser clamped the view's scrollTop. Putting the height
back doesn't undo a clamp. app.js's scroll guard took the clamp for a scroll
the reader didn't make, and its scrollIntoView({block:"nearest"}) pulled a
textarea taller than the view to one of its edges. Every composition step is
an input, so this happened on every keystroke.
autosize (the only one in the GUI, used by a set's text, an agent's own
text, a skill's description and subagent boxes) now holds the textarea's
parent at its height while measuring, so the page never goes short.
What was run:
- New internal/gui/tests/library-ime-scroll.test.cjs covers en/zh, 980/560px,
a Default set's text and Cline's own text. Chromium composes through CDP
Input.imeSetComposition/insertText. WebKit gets synthetic
composition events and inputs.
- With the fix: 9/9 in both engines, before and after rebasing onto
|
||
|
|
17557132cb |
gui: in a narrow window the title bar's tools show their icons, then the title gives way; nothing lies over it (#2625, linusxiong)
Beside the sidebar, Library's, Plugins' and Settings' heads sit in the
title bar after the breadcrumb, between --tools-l (the crumb's right +
16) and the window's buttons, laid out flex-end. When the tools needed
more than that room they ran on to the left, over the crumb: at about
650pt with the sidebar, Library -> MCP servers had 「发现」 over
「MCP 服务器」's last character. The crumb never gave way to them.
app.js tools() now shares the room out, laying out and reading each
step in its one frame, the next only if the tools still run over:
1. the crumb whole (its natural width from its parts, the last one's
scrollWidth) and the tools with their words;
2. body.tools-tight: Library's Discover / Library folder / Backups and
Plugins' "Mirrors in China" show their icon (or switch) alone. Each
keeps its name as aria-label (a hidden span leaves the accessible
name) and its tooltip as before (the folder's path, the backups'
note and path, Discover's and the mirrors' sentences);
3. --crumb-max: the crumb drops its leading parts ("Work /"), a part
and its slash at a time, and last cuts the page's name at its end.
In the side-nav head the Library buttons and the mirror switch are
flex: none and Plugins' search keeps 120px, so what doesn't fit shows
as running over rather than shrinking out of sight. The views'
MutationObserver also asks tools() again, as a tab's own tools change
(Discover only on MCP servers and Skills) without the crumb resizing.
title-bar-tools.test.cjs (new): every Library tab, Plugins' three and
Settings, sidebar picked, window mode, at 560 (the window's least),
650, 760, 900, 1024 and 1280px, in zh, zh-TW, ja, de and en, Chromium
and WebKit. No tool lies over the shown title or another tool or out
of the bar, no label is cut, an icon-only tool has aria-label and
title, only leading crumb parts go and the page's name shows, whole
from 650px. Against the old assets (MAGPIE_GUI_ASSETS) it fails in all
five languages at 560px Library Instructions ("a tool lies over the
title"); with the change Chromium 5/5 and WebKit 5/5. Looked at
screenshots of zh Library MCP servers and Plugins Discover at 560, 650
and 760px.
docs/subsystems/gui-shell.md says how the title bar gives way.
Run with both #2623's and #2625's changes, on
|
||
|
|
7ea8aeaba7 |
gateway: DSML written with a run of pipes (<||DSML||invoke) is made the call too, not left as text (#2623, OKURBITO)
DeepSeek wrote its tool call as <||DSML||invoke name="get_weather">…
(two full-width pipes each side) and the reply reached the Responses
client as that markup: textCallAt only knew the one-pipe marks, so
nothing was held and parseTextCalls, whose regexes already read a run
of pipes, never ran. dsmlMark now finds a DSML tag's mark as the parse
regexes (dsmlTag) read one, with no list of spellings: <, spaces, / and
spaces for a close, a pipe, a run of pipes and spaces, DSML, and
another run that may be empty. A pipe is ASCII | or full-width |, in
any number and any mix of widths. textCallAt uses it to find a call
and to hold a mark still being written (down to a full-width pipe's
first bytes); cutMark uses it to trim a tag cut short at the end, once
the tag has begun its pipes, so a value ending "a < " keeps its "<".
Every route goes through these: textCallSee (translations),
textCallTidy (relayed Chat streams) and wholeTextCalls (whole Chat
replies). OKURBITO pointed out on the issue that a spelling table
leaves |||, ||, || and the like as text; this reads the class.
Tests (textcalls_pipes_test.go). Which cases were seen and which were
made up, as OKURBITO set out on the issue: one reply was written by a
model on its own in real use (deepseek-flash offered web_search:
<||DSML|| calls> … <||DSML|| invoke name="web_search"> …), kept
byte for byte as observedPipes; the issue's get_weather reply came from
asking the model to echo the markup; every other spelling (three pipes,
ASCII, widths that disagree, spaces after <, no pipes after DSML) is
constructed and has not been seen.
- TestTextWrittenDSMLDoublePipe: the observed reply, relayed Chat
streamed and whole, is a web_search call with its query and no DSML
left; the issue's reply through /v1/responses, streamed and whole, and
a whole Chat reply, is a get_weather call with {"city":"Beijing"} and
no message item.
- TestTextWrittenDSMLAnyPipes: | | || || || || ||| ||| "| |", each reply
sent one character per chunk: the call, wrapped with text before, a
space before invoke (the live <||DSML|| invoke), no parameters, cut
short, tags only with the last cut short, a tool not offered, a mark's
start at the end, pipes without DSML; each ends as the one-pipe reply.
- TestTextWrittenDSMLDoublePipeEveryCut: the reply split at every byte
boundary JSON allows is the same call; textCallAt holds each prefix of
the mark, a full-width pipe's first bytes too.
- TestTextWrittenDSMLMarkAsParsed: widths that disagree within a tag
and between its open and close, spaces after < and around /, no pipes
after DSML are each the call; a cut-short <parameter> value ending in
"a < " keeps it; "x < y and a <" stays text.
Fails without the change: with b7d9616d0's textcalls.go all four
FAIL, the observed reply among them ("text \"<||DSML||invoke …\" calls
map[] finish \"stop\"", "a message item beside the call"; MarkAsParsed's
widths that disagree, spaces after <, no pipes after DSML); the one-pipe
rows pass there. With an earlier draft of dsmlMark (a run of pipes,
none after <, one required after DSML) MarkAsParsed FAILs its
spaces-after-< and no-pipes-after-DSML rows; with cutMark's
has-begun-its-pipes guard taken out it FAILs the cut-short value ("a "
for "a < ").
Not tried against a real DeepSeek upstream: the fixtures are the
bytes OKURBITO posted. In the observed event the request offered only
a hosted web_search ({"type":"web_search"}), not a function; a call to
a tool the request didn't offer by name still goes on as text, as
before, and the test offers web_search as a function.
Run with both #2623's and #2625's changes, on
|
||
|
|
8233eadaec |
provider, gateway: a plugin's model served at priority has fast mode, whichever plugin (Lovest on Discord)
Since #2514 a plugin can say which tiers its vendor serves a model at
(serviceTiers). CanFast still returned true only for Cursor's plugin, so
no other plugin's models could be a group's fast member or an agent's
fast pick. The Routing and Agents pickers (gui/groups.go, agent/route.go
FastFor) and SetFastPick/SaveGroup all read CanFast, so they refused too.
Changes:
- CanFast: a plugin's model has fast mode when the plugin says it is
served at "priority", on its Chat or Responses API (pluginTierOn), where
the gateway sends service_tier. This holds for any plugin. Cursor's
fast flag and -fast sibling logic are kept below it, unchanged.
- UltraOn/CanUltra: such a model can also be picked Ultrafast when the
plugin says "ultrafast". Before, plugins were excluded outright.
- forwardTranslated: a plugin's request whose agent spoke Claude's API
carries fast mode as speed "fast", with no tier. It is now given tier
"priority" ("ultrafast" for an Ultrafast pick) when the model is served
at that tier. Before, Claude Code's fast pick on a tiered plugin went
out with no service_tier.
- The "no fast mode" error names plugins.
- docs/subsystems/provider-plugins.md says all of this.
Test: TestPluginTiersGiveFastMode (gateway, fake plugin with FAKE_TIERS):
- CanFast and CanUltra: fake-1 (priority+ultrafast) true/true,
fake-resp (ultrafast only) false/false, fake-claude (none) false/false.
- fake-claude is refused as a fast member and as a fast pick.
- A fast group member reaches the plugin's fetch as priority from Chat,
Responses and Anthropic.
- Claude Code's fast pick sends priority, its Ultrafast pick sends
ultrafast, and another agent's request sends none.
Broken by hand, each then restored green:
- CanFast's tier check off (the old behaviour): red on CanFast(fake-1),
CanUltra(fake-1) and the fast member being refused.
- forwardTranslated's Fast-to-tier off: red on the anthropic member, the
fast pick (nil, want priority) and the Ultrafast pick.
- UltraOn's plugin branch off: red on CanUltra(fake-1) and "no account
offers Ultrafast".
Existing TestPluginServiceTierReachesFetch, TestPluginModelServiceTiers*
and TestCursorPlugin* pass.
No GUI asset changed (the pickers only read canFast/UltraOK from Go), so
the GUI suite was not run.
Run:
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows -tags nogui.
- go test -tags nogui -timeout 90m ./... at 9f9bfc160+this: EXIT=0, 66
packages ok, none failed (agent 3928s, gateway 2739s, provider 785s).
The timeout is 90m because the load average was ~150-270, and 45m cut
agent and gateway short on this box earlier today.
- Rebased then onto
|
||
|
|
bf931f82c3 |
gateway: a Codex conversation compacted natively is held to its account only when native compaction is on, and told why when it can't go there (#2642, #2582)
ScarfQian (#2642, still on v0.1.1279): after a native compaction by one Codex account, routing to another answered 400 "only that key or account can read the compaction it sealed ... switched off, removed, or no longer serves". Three causes, one fix each: - #2582 (Dony2050, ump45nose's patch): one of Codex's own models asked on the backend path through magpie's accounts (codexAccounts) kept the compaction_trigger whatever the codex provider's native compaction setting, so every compaction was sealed by and recorded to one account. It is now decided as a magpie model's is: codexInputAs with nativeCompactionFor("codex/<model>"); off (the default) gives codexCompact's magpie1: summary, which any account reads, and records no writer. Unlike ump45nose's branch, /responses/compact and Codex's own single sign-in relay are left as they were: the legacy endpoint's body has no trigger for codexCompact to answer, and a lone sign-in has no other account to move to. - ggbdpq's fix (0ab41eba0, e1646488d, ported as is): a writer whose own model list has since dropped the model sat in planned.left, out of the candidates, so checkpointReaders never found it and refused although it was on. It is now taken back from planned.unlisted (plan, planLevel and the nested weighted plan), its row moved from left to order. sealedReaders, run before it for a sealed subagent task, narrows unlisted too (sibling). - A request carrying a recorded seal while only Codex's own sign-in is on was relayed as it came (codexAccounts false), so with the writer switched off the one account left was sent it. codexSealedFor routes it through serve, where checkpointReaders holds it to the writer. - checkpointError now says the reason magpie's settings give (checkpointGone: provider removed, account signed out, sign-in lapsed, paused while others are on, switched off, kept from the model in Names & levels, key off or gone, model disabled, or the model/group asked for not routing to it), the fix for that reason, and whether native compaction is on for the writer's provider now. The old catch-all sentence is gone. The seal is still treated as readable only by the account that wrote it, as #1099 and #2271 found; chestnutLeeeee's report that another account read one in a direct canary was not tried here (no real accounts). Tests (fake ChatGPT backend, sandbox HOME, nothing on the network): TestCodexOwnModelCompactionHonoursTheToggle (off: summary, no trigger upstream, no writer; on: native seal kept, writer recorded), TestNativeCompactionWriterGoneSaysWhy (spare switched off, own paused, Names & levels, signed out), ggbdpq's TestNativeCompactionWriterWhoseListLacksTheModel and ...ThroughAGroupWhoseListLacksTheModel. All four are red on |
||
|
|
5b12407e8e |
gateway: a custom tool a Responses upstream turns away is translated, not given back as a 400 (#2656)
DeepSeek's Responses API answers Codex's exec, a custom tool, with 400 "Unsupported custom tool: 'exec'. Only 'apply_patch' is supported." The relay (attempt -> passthrough) sent the tools as they came, so the translation that offers a custom tool as a function and gives its call back as a custom_tool_call never ran, and the 400 matched no word list, so a group's next member wasn't asked either. - passthrough: a 400/422 matching customToolRefusal, on a Responses body that offers a custom tool (tools, a namespace's, an input item's tools), marks the model (customToolRefused) and returns not done. - attempt: then, and on a marked model's later requests with a custom tool, the request is translated on the client's own API (ownAPI), so exec keeps its name and comes back as custom_tool_call. A Codex compaction (keepsCompaction) isn't translated and gets the refusal. - shapeRefused also takes customToolRefusal, so where the refusal does reach a group, the next member is asked and nobody rests. Not scoped to DeepSeek: any Responses relay (key, plugin) that says its custom tools are unsupported is handled the same; an upstream that never refused them still gets them as sent (tested). Tests: custom_tool_test.go, fixture from the reporter's literal error text and request. TestCustomToolTranslatedWhereRefused (stream and not), TestCustomToolRefusalInGroup (reporter's ordered group, next member asked 0 times), TestCustomToolRefusalWordings. Broken by hand: passthrough branch off -> both request tests 400 with the reporter's exact message; attempt pre-skip off -> next turn asked 4 times, not 3; shapeRefused addition off -> Wordings red. Run: - gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags nogui ./... clean, at the pushed head. - Full go test -tags nogui -timeout 45m ./... on |
||
|
|
85eef5d87a |
gui: quota refreshes stay centered and finish each turn without jumping (#2397)
chiperman's patch (df288db, #2397), landed here since external PRs are collaborators only. The card redraw replaced its refresh button on a background reading and again when the click finished, restarting its rotation and hover reveal and moving the Updated text; a fast reply also stopped the spin partway through a turn. Each account's control and its animation are kept through redraws, the reply is shown at once and the current 800ms turn finishes (at least one), Reduce Motion skips it, and the glyph sits on the text baseline in an inline grid instead of a pixel offset. Changed in landing: main had since given the tray panel's Allowances the same quotaRefresh (#panelQuota, #840). A kept button is reused only when its redraw took it out of the page, so a refresh started on the Usage page is never moved out of the panel (or back); the other place's copy of a turning control gets busy+spun and turns by itself until done() clears it. The panel's hover rule (.pq-card:hover) reveals it as the Usage card's does. quota-refresh-order's vm harness gets a document stub for that. app.js's budget goes from 1,250,000 to 1,269,000: with four comments shortened it is 1,250,904 here, the core's own code since the tray panel draws the same control, plus 1.5% as the budget's comment asks. Every core script together is still under coreScriptBudget, which is unchanged. Run, sandbox HOME, pinned GOMODCACHE/GOCACHE, load ~110-360 from other sessions' suites: - Full suite on |
||
|
|
252bc61ce9 |
agent: a caller key of the gateway's own in Claude Code's and Codex's config survives a model pick (#2545)
What changed: - writeTiers (claude.go) wrote env.ANTHROPIC_AUTH_TOKEN = wiredKey() on every model and tier pick, and putProvider beside the thread-provider tables (codex.go) wrote experimental_bearer_token = at.gwKey() the same way: a caller key of the gateway's own the user put in their place was written over, and it was never stashed, so no Disconnect brought it back. Both keep such a token now, as a sync keeps one (mergeKept, keyHolds of #2510): only a value the gateway would refuse is wired over. The sign-in field's own Set is unchanged, as that switch is the user's own. - The sharing key magpie itself made is never one of those: access.Default says a secret is the default key ConfigureLAN keeps, sharing on or off, and the two write points ask it before keeping what they hold. With sharing off the key stays enabled in the store, Authenticate still took it, and keyHolds held it for the user's — Rekey could no longer bring gateway.Token back (TestRekeyGivesWSLAgentTheSharingKey, deterministic red on the first cut of this patch, found in review). Claude has no WSL twin: the sharing key reaches it by an address beyond loopback (MAGPIE_ADDR), and a pick kept it the same way there, so TestClaudeSharingOffWiresGatewayTokenBack holds a sharing on, then off, to gateway.Token. - docs/subsystems/agent-wiring.md's sentence about a hand-set key said Check reports it; Check has taken one since #2510, and a pick keeps it now too, the sharing key excepted. Patch by ggbdpq (c809f7ad), the second cut after review: the first (835d3bf8) turned TestRekeyGivesWSLAgentTheSharingKey red, as the sharing key stays enabled with sharing off and was kept as the user's. Applied unchanged on |
||
|
|
cb05dc2d1b |
sessions: CodeBuddy Code's own sessions are listed on the Sessions page, resumed with codebuddy --resume and deletable (#2657, caozeal)
CodeBuddy Code keeps its sessions as WorkBuddy does, ~/.codebuddy/projects/<cwd>/<id>.jsonl. magpie read them for the calls ledger (#1779) but never listed them: allFiles() and Dirs() left them out, parserFor sent them to the Claude parser, and Deletable didn't name the agent. caozeal's branch (85cc186a2) adds them to allFiles, Dirs, parserFor (workbuddyLine) and Deletable, with the meta cwd fallback WorkBuddy has, and the ledger reads through the same list. On top of it: the resume command is `codebuddy --resume <id>` (its CLI's `-r, --resume [sessionId]`, read from @tencent-ai/codebuddy-code 2.168.2's dist/codebuddy.js; codebuddy is one of the package's three bins). The Sessions page's and Usage > Sessions' agent label come from the agent registry (CodeBuddy Code, codebuddy-color) and needed no change; a test now holds them. Fixtures are the real `codebuddy -p` runs already in internal/sessions/testdata/codebuddy (#1779). Tests: - TestCodeBuddy (caozeal's, extended): two sessions with their cwd, title and model tokens; the resume command on each OS's form; Deletable. - TestCodeBuddySessionsListedUnderTheirName (new, internal/gui): /api/sessions, /api/sessions/manage and /api/sessions/stats name them CodeBuddy Code with its icon, resume command and trash. - Broken by hand, each red: allFiles reverted and parserFor reverted ("want 2 CodeBuddy Code sessions, got 0" in both tests), resume reverted (resume ""), Deletable reverted ("not deletable", "offers no trash"). Run at |
||
|
|
7660399a12 |
gui: a provider's Claude model chip says the number Claude Desktop's menu shows beside it (#2578)
jerrychoi (#2578) has two providers serving the same Claude models, and Claude Desktop's menu tells them apart only by a 10-digit number. The provider editor now shows that number on the model's chip. From ggbdpq's patch (dcb00beb5), changed after reading desktop.go and Desktop 2.7032's app.asar: - Desktop renames a row to its own catalog's name ("Opus 5.5") only when the id resolves into that catalog, which is the magpie-<n>.anthropic.<model> form claudeLooking gives a Claude model with reasoning levels. Every other row is named by our display_name (which already says the provider) or by its own id, and its number never shows in the menu. The patch put a number on nearly every chip; DesktopNumber now returns one only for the .anthropic. form ("" for mythos-magpie-<n>, anthropic/magpie-<n>, own ids and groups). - The number shows only while Claude Desktop is installed, and only for a model Desktop is shown (CatalogFor("claude-desktop"), not the whole catalog, so a model hidden from Desktop gets none). - The numbers are worked out once per Providers page build, not once per provider. - The GUI test runs en and zh at 900px and en at 420px in both engines and checks the badge sits inside its chip. - docs/subsystems/agent-wiring.md says why the number is there. The badge reuses the muted .badge.ctx pill beside the context size. Its tooltip is in zh, zh-TW, ja and de (ggbdpq's strings). Broken by hand, each watched red then restored: - ggbdpq's DesktopNumber: TestDesktopNumber red for glm (mythos), glm (anthropic/magpie) and a group led by Claude; the GUI Go test red for m2. - the installed check removed: red "without Claude Desktop, claude-opus-5-5 says desktop ...". - provider.Catalog() in place of CatalogFor: red for the hidden haiku. - j.Desktop dropped: red for claude-opus-5-5. - app.js without the badge: model-desktop-number.test.cjs 0 passed. Run (macOS arm64, sandbox HOME, pinned GOMODCACHE/GOCACHE): - model-desktop-number.test.cjs 6/6 in chromium and webkit (en, zh at 900px, en at 420px); screenshots checked: zh at 900px shows "Opus 5.5 [number]" as a muted pill, Sonnet none. - Go, this tree, as 1160f2e7d before the bodies were reworded (with the #2576 commit, on origin/main |
||
|
|
b566745b8a |
gateway: the model list says each model's reasoning levels as plain names too, for Catwalk clients (#2576)
Clients of the Catwalk schema (Crush and kin) read reasoning_levels, a
flat array of names, to know which reasoning efforts a model takes, and
drop reasoning_effort from requests to a model that names none. magpie's
/v1/models said the levels only as objects (supported_reasoning_levels,
[{"effort":"low"},...]), which such a client reads as none (cyancity).
modelObject now also says reasoning_levels: the same e.Efforts in the same
order, [] when there are none, never null. The objects stay as they were.
Every row built by modelObject carries it: the provider/model rows,
routing groups, bare ids, /v1/models/{id}, deciders, and Claude Desktop's
and Claude Science's lists. Muse's list has its own shape and the
image/video rows say no levels, so neither changes. No gateway default
for thinking, no thinking/enable_thinking aliases and no
default_reasoning_effort, as decided on the issue. Docs: reference.md,
integrating.md and the site's integrate page (en, zh) name the field.
ggbdpq's patch (base
|
||
|
|
e085d6e926 |
cli, gateway: magpie heap writes the running magpie's Go heap profile, with its memory numbers
A user on X (FatimaHill74421) reports the macOS app at 3.95 GB physical
footprint after ~12h (v0.1.1273, after 8a1b5916f's #2278 fix), and a macOS
`sample` shows Go's frames as ???. `magpie heap [<file>]` asks the magpie
that serves the gateway for GET /v1/magpie/heap: runtime/pprof's heap
profile after a GC (gzipped protobuf, go tool pprof reads it), with
HeapAlloc, live heap, HeapInuse, HeapSys, StackSys, Sys, NumGC and the
goroutine count in X-Magpie-Heap-Stats. It writes <file>, else
magpie-heap-<date>-<time>.pb.gz here (0600, never over a file), and prints
the path, the pid and the numbers. --help writes nothing; an unknown flag,
"-" or a second file is refused before anything is asked.
The route answers only a loopback, unproxied caller with no browser marks
calling localhost or a loopback IP. heapRefused checks this in the handler
itself, so a gateway key never lets in another machine, a listed page,
Origin null, a localhost page or a rebound Host, and it holds where Handler
is served without lanGuard.
Run at
|
||
|
|
df341e7671 |
gateway: a member that answers a stream request with a whole reply is asked once, not again and again (#2455)
An upstream that answers stream:true with a whole JSON reply (a relay that doesn't speak SSE) fails as a 502 "did not stream". magpie read that 502 as a failure a moment may mend: the same-one retries (passing) asked it twice more, then a group's patience (busy, #1418) kept asking it until the budget was spent. The failure is the same however often it is asked. With production pauses that is about 7 requests and 60s at the default Patience, about 14 at 240s; the test's 1ms pauses let the 12 replan rounds run out first, 15 requests (ggbdpq's correction on the issue). busy() and passing() now leave a body that says didNotStream alone, and the four places that word the error (translate, streamTranslated, askTranslated, holdWriter.settle) share that constant. A group still moves on to the next member, whose API may stream; retryable() is unchanged. Patch by ggbdpq (f9e09ca7), applied on main with the docs sentence placed by hand (the hunk no longer applied). Run: - TestStreamlessMemberIsAskedOnce with both exclusions taken out: FAIL, whole and stream ("asked 15 times"); with only busy()'s: FAIL ("asked 13 times"); with only passing()'s: FAIL ("asked 3 times"). Restored: ok (asked once, the agent gets the 502 naming "did not stream"). - TestStreamlessMemberHandsOnToTheNextMember (b, which streams, answers after a): ok. - TestQuietNotAReplyLastFails, TestPatience*, TestStreamOverflow*, TestCodexOverflowInGroupNotAskedAgain, TestAgentGoneInTheRetryPause, TestRelayInputCap, TestOverflowGoesToAMemberWithRoom: ok. - Full suite, go test -tags nogui -timeout 45m ./... (set -o pipefail, sandbox HOME, load ~350) at 0224e826f (these four commits on |
||
|
|
ae98cda651 |
gateway: an inner group's own Patience waits out its busy members through an outer group (#2410)
serve read Patience only from the group the request named (g.Waits()). planLevel stamped a nested group's FirstToken (#2246) on its candidates but not its Patience, so an inner group's budget was never read through an outer one: an inner 4 min under an outer default gave up at 1 min, and an inner Off was still asked again for 60s. Each candidate carries the innermost Patience that is set on its way down (innerPatience, as innerFirstToken). waitsOf reads it as Group.Waits does, falling back to the asked group's when unset; PatienceOff keeps the member out of replan. replan counts each member's budget from waitFrom and asks again only those with budget left past the pause; the hold on the last failure lasts while any member's may (maxWaits), and the trace's Patience is the member's own. With no nested Patience set, every member's budget is g.Waits(), as before. Patch by ump45nose (61b1c17c); ggbdpq checked it against main on the issue. Review changes: the docs sentence was placed by hand (the docs hunk no longer applied), and the tests' budgets moved from inner 8s / outer 3s to 10s / 4s, so every round's pause ends 2s or more from a budget line (it was 1s from the 3s line), as a timing test leaves room on both sides. Run: - With fallback.go, gateway.go, patience.go and patience_test.go put back to main: TestNestedGroupPatienceThroughOuter FAIL ("a.n=2, want 3 — the inner group's 10s budget was not read"), TestNestedGroupPatienceInnerOff FAIL ("code=529 a.n=13 (want 529, 1 — no replan)"). With replan reading only the fallback budget: ThroughOuter FAIL the same. Restored: ok. - TestNestedGroupPatienceFallsBackToOuter, TestGroupWaitsOut*, TestPatienceIsUsedUp: ok. - Full suite, go test -tags nogui -timeout 45m ./... (set -o pipefail, sandbox HOME, load ~350) at 0224e826f (these four commits on |
||
|
|
08400f4ebd |
gateway: a byte cap after the stream has begun says request_too_large, so Pi compacts (#2533)
A vendor's 413 that came after the stream's headers had gone out (a keepalive sent while the vendor was quiet) reached Pi as a stream error of type api_error saying "413 Request Entity Too Large". Pi compacts only when the error's text says request_too_large (overflow.ts), so the turn stopped. A 413 before the headers was already typed request_too_large (writeErrorSaid, |
||
|
|
ebf3f48f7f |
usage: a reported call takes first_text_ms and flow_ms, so a reasoning reply tells its speed and a burst is held (#2637)
POST /v1/magpie/usage/requests turned away first_text_ms and flow_ms as
"not a field a reported record takes", so a reported reasoning reply was
timed from its first reasoning token and a burst-at-the-end reply was
never held. The ingest now takes both, validated like ttft_ms (whole
milliseconds, 0..ingestMaxMillis, null = unset), and checks:
- first_text_ms <= ms, and first_text_ms >= ttft_ms when both are set
(the first text is content too);
- flow_ms <= ms*10/8+1, since the gateway's flow is the tenth-to-nine-
tenths span scaled by 10/8 and can exceed ms.
The fields reach usage.jsonl through the Record, so DecodeOf, Row.Decode
(ThinkPace, HeldShare) and the Reported totals read them as they do the
gateway's own rows. docs/reference.md and gateway-sessions.md say so.
Tests: TestUsageIngestTellsSpeed posts the reporter's literal repro
(grok-4.7, out 307, reasoning 129, ms 5035, ttft 4632, first_text 4700:
178 tokens over 335ms), a burst held by flow_ms, an even reply told, and
a ThinkPace hold, and checks the totals. TestUsageIngestTimesChecked
covers each bound, its edge, null and absent fields.
Broken by hand: old code fails both tests (field refused); dropping
FirstText tells repro-1 0; dropping Flow tells the burst 601/4035;
removing the ttft check accepts first_text 299 < ttft 300; bounding flow
by ms rejects the valid 1501.
Run at
|
||
|
|
333c167575 |
routing: a rule can set the reasoning its model is asked for (#2633)
dengtongcai asked for a routing rule that picks both the model and the reasoning it is asked for (a quick question goes to a cheap model at low). A rule now has an output field, useEffort (low|medium|high|xhigh|max). When the rule matches, its member is asked for that effort. A member's own fixed effort still wins. Otherwise the rule beats the model's suffix, the turn's pick and the agent's pick. The existing effort condition is unchanged. - The value is fitted to the model's levels (max -> high on a model that tops out at high). A model with no Efforts is sent what the agent asked, untouched. Unset changes nothing. Failover members are not affected. - The trace records it: Rule.UseEffort and the try's RuleEffort (the second Try construction in the candidate loop was missing it). - Saving a group rejects an unknown value or one on a pause (cleanRules). The CLI takes use-effort=; the TUI and CLI lists show " at <effort>". - GUI: a chip after the rule's model, picked from the app menu (pickFrom, no native select), set/changed from the rule's menu. A pause clears it. Strings in zh, zh-TW, ja, de. - A Gemini-protocol client is left unchanged, as with every effort magpie sets. - Docs: docs/subsystems/gateway-routing.md; site docs intent and start (en, zh, ja). What was run, at d4c03a2c5 (rebased on |
||
|
|
df3734b959 |
proc: the login shell's variables count only when exported, and Codex's proxy detail names the variable it read (#2627)
ReneXiong: Codex showed the "proxied" drift, "through the proxy at
http://127.0.0.1:7890, set in HTTP_PROXY", while Codex went direct. The
value was fish's universal http_proxy from an old Clash setup, never
exported (`set -S` says "unexported"), so no program fish starts has it.
shellEnv asks fish beside the login shell (zsh), and shellProbe printed
"$http_proxy" in the shell itself, which expands unexported variables too;
mergeShellEnv then filled zsh's empty value with fish's.
Fix at the shared reader: every shell is now asked to run
/bin/sh -c 'printf ... "$PATH" "$CODEX_HOME" ...', the form nushell already
used (still with its ^). A child sees only exported variables, so each
value is what an agent started from that shell gets. This covers every
reader of the probe: Codex's proxy (codexEnv), Claude Code's provider
switches (claudeShellEnv), and agentenv.Vars such as CODEX_HOME and
CLAUDE_CONFIG_DIR that magpie takes into its own environment; an
unexported zsh or bash variable no longer counts either, which matches what
an agent run from that terminal sees. Proxy variables are still merged from
fish when the login shell has none: a fish user who exports one runs Codex
with it from fish, so taking proxies from the login shell only (the
report's other suggestion) would miss that case.
codexProxyFor named HTTP_PROXY (or HTTPS_PROXY, ALL_PROXY) for a value in
the lowercase variable. It now names the one it read, in both the reqwest
and respect_system_proxy paths, and the detail's NO_PROXY advice matches a
lowercase name too (and not "the system's proxy settings").
Other proxy readers checked: the daemon's carried env, wslrun's proxyVars,
netproxy and the plugin host read magpie's own environment, not a shell;
the WSL probe scripts ask for no proxy variable.
Tests: TestLoginEnvUnexportedNotCounted, a login shell with the reporter's
literal values unexported beside an exported NO_PROXY; TestShellEnvRealFish
now writes the reporter's literal fish_variables lines and checks that
http_proxy, https_proxy and all_proxy read empty;
TestCodexProxyNamesItsVariable. Broken by hand, each went red: the old
in-shell printf (unexported values read back, in the fake shell and in real
fish 3.7.1), and env() naming keys[0].
Run: go test ./internal/proc and the codex proxy tests on darwin;
TestShellEnvRealFish, TestShellEnvFishLogin and
TestLoginEnvUnexportedNotCounted on real fish 3.7.1 in an alpine container
(linux/arm64), green with the fix and red without it; gofmt -l clean; go vet
-tags nogui ./... for darwin, linux and windows; the full go test -tags
nogui -timeout 45m ./... under pipefail, both fixes together on
origin/main
|
||
|
|
ed0335f75c |
gateway: an assistant turn cut off before it said anything is left out of what a Chat upstream is sent (#2599)
timonwong (#2599): after the user stops a reply while the model is still thinking, the agent keeps a turn with no text and no calls and sends it again on every later turn. Translated (buildChat) or relayed, it reached the Chat upstream as {"role":"assistant","content":""} (reasoning_content alone, on DeepSeek), and DeepSeek and Kimi turned every request of the conversation away: "Invalid assistant message: content or tool_calls must be set". One rule, withoutSilentAssistants (chat.go), runs on both Chat routes: buildChat before pairToolMessages (Claude Code, Codex and Gemini clients, and the plugins fed by buildChat), and silentAssistantsOut in passthrough next to developerAsSystem (a Chat client's own body). An assistant message with no content or only blank text parts, and no tool_calls or function_call, is left out; the user messages it stood between join into one (texts with a blank line, else their parts in order), so no two user messages stand in a row. A prefill (prefix, partial, a Resume), a legacy function_call, a refusal and an audio reply stay. A relayed body without such a turn goes byte for byte. TestChatThinkingOnlyAssistantKeptOutside- Exchange pinned the old pass-through; it now expects the joined message. Built on ggbdpq's patch (cb438ebb on their fork) and its fake upstream, written again because the review found it missed shapes the issue names: - after a tool result it kept the empty turn ("a strict template wants the reply behind its tool message"), so the interruption mid tool loop still sent content "" and still got the 400. tool then user is what any agent sends when the user writes after a tool result; it is now left out. - the relay dropped an assistant with a legacy function_call or a refusal and empty content, and a client's own prefix/partial prefill; kept blank text-part arrays (still refused); joined only string users; re-marshalled with HTML escaping. - its Resume check compared a joinSplitCalls turn index with len(r.Messages)-1. Verified (sandbox HOME, pinned caches, go1.26.8 darwin/arm64, base origin/main |
||
|
|
ec64543952 |
claude: a switch gives a Claude subscription's run the agent's instructions as its system prompt, in place of Claude Code's
Every request through a Claude subscription is answered by the real
Claude Code, which sends its own system prompt, with the agent's
instructions in the run's first user message. Settings › Replies › Short
Claude system prompt (claudeLeanPrompt, off by default) starts the run
with --system-prompt-file holding the agent's instructions instead
(without a client Claude Code's billing line, plus the tool-choice
line), and the first message holds the conversation alone. The file is
under the distro's mount in WSL. A request with client cache marks
(#1717) is never lean. The mode is part of the run's identity, so a run
started in one mode never takes the other's turns. The row says the
risk: requests look less like Claude Code's own.
Measured with a real Claude subscription, Sonnet 5.5, Claude Code
2.1.301, off then on:
- chat client, ~600-token prompt, 2 tools, 3 turns: 10,048 -> 6,580
input tokens (-35%)
- claude -p as the client, Read and Bash, 4 requests: 85,453/85,471 ->
81,948/81,977 (-4%)
A fixed ~0.9-1.2K tokens a request.
Run at this head (rebased on
|
||
|
|
72d6103e28 |
gateway: a Chat tool in MCP's or another API's shape goes upstream as a Chat function tool (#2622)
jinyue806 (#2622): ZCode sends its tools on /v1/chat/completions in MCP's shape, {"name","description","inputSchema"}, with no type and no function object. magpie relayed them as they came, and SenseNova turned every request with tools away ("field Tools[0].Type invalid, should be set"; a flat {"type":"function","name":…} got "function cannot be empty"). A missing type is invalid Chat Completions for every upstream, not SenseNova only, and the translated routes were broken too: parseChat read no name from such a tool, so Messages and Responses upstreams were offered a tool named "". shapeChatTools puts a tool with its name at the top (no type, or type "function" without a function object) into {"type":"function","function": {name, description, parameters, strict}}, parameters taken from parameters, inputSchema or input_schema; other fields stay beside it. It runs right after liftMessageTools at the same two choke points: handle, for every Chat body before routing (relay, schema fixers, redaction, plugins), and parseChat, for a body that never came through handle. A tool that has its function, a hosted tool (any other type) and one with no name are left alone, and a request with nothing to shape is relayed byte for byte. Verified: - TestChatToolInAnotherShapeIsShaped sends the reporter's curl body with each of the four tool shapes from the report through the Chat relay, Messages and Responses. With shapeChatTools made a no-op by hand all 12 subtests FAIL: relayed as {"name":"f","inputSchema":{…}} as it came, and translated as {"name":"",…}. TestShapeChatToolsLeavesChatShape (byte for byte on Chat-shaped/hosted/nameless tools; strict and cache_control kept) FAILs on the same break. Both pass restored. - gofmt -l: clean. go vet -tags nogui ./... for darwin, linux, windows: ok. - Full suite at |
||
|
|
a69cd07075 |
gateway: a Chat tool call kept with an empty id goes with one made from its place (#2611, RunMintOn)
RunMintOn's session held an assistant turn whose tool call had "id":""
and a tool result with "tool_call_id":"". magpie relayed it unchanged on
Chat->Chat, and WorkBuddy AI turned the whole request away (400, 11133).
Chat->Messages sent tool_use id "" and Chat->Responses gave the call a
random id while its result kept "".
- chatCallIDs (chat_call_ids.go) runs in attempt for every Chat request,
before the relay, the translation and a plugin's fetch alike (a moved
WorkBuddy AI goes through the plugin, so the edit must come first). An
empty, null or missing call id gets "call_" + a hash of the call's
message index, position, name and arguments: the same on every resend,
so the prompt-cache prefix holds. A result with an empty tool_call_id
takes the turn's unanswered calls in order. A body that already has its
ids comes back byte-identical.
- chatTidy gives a stream's first fragment of each (choice, index) call an
id when the upstream sent none, and drops an empty id on later ones;
chatWhole fills a whole reply's empty ids.
- docs/subsystems/gateway-routing.md says so.
Tests (chat_call_ids_test.go), fixtures from the issue's literal bytes,
against a fake that refuses as WorkBuddy AI does:
- TestEmptyCallIDRelayedWithOne, TestEmptyCallIDReachesPluginWithOne
(movedFake workbuddy-ai), TestEmptyCallIDTranslatedWithOne (messages,
responses), TestChatCallIDsLeavesWhatHasIDs, TestStreamedCallGivenAnID,
TestWholeReplyCallGivenAnID.
- Broken by hand, each watched red: edit removed (relay and plugin get
the 400; translations send an empty or unpaired id); a random id in
place of the placed one ("the made id changed between requests");
stream mend off (first fragments' ids ""); whole mend off ("id":"").
Run at this change on origin/main
|
||
|
|
9228bd443f |
library: skills are grouped by source when the skills CLI keeps its lock under $XDG_STATE_HOME (@_yukirock on X)
skills 1.7 writes its global lock to $XDG_STATE_HOME/skills/.skill-lock.json
when that variable is set, and only to ~/.agents/.skill-lock.json otherwise.
The Library read only the ~/.agents one, so with XDG_STATE_HOME set every
`npx skills add` skill had no repository and the "By source" view could not
group them. Both locks are now read, the XDG one winning per skill, since a
lock written before the variable was set still names older skills.
XDG_STATE_HOME joins agentenv.Vars, so the desktop app takes it from the
login shell like the other folder variables (TestFolderVarsAreListed).
Not handled: a project install's ./skills-lock.json.
Run (worktree at origin/main
|
||
|
|
1978eabe58 |
agent: Codex's background compaction is turned on from Settings › Long conversations (#2490, #2493)
Codex 0.163 can compact a long conversation in the background while a
turn goes on ([features.async_compaction]). A new row under Long
conversations turns it on, with the share of the window it starts at
(empty: Codex's own 65%). magpie writes it into each Codex config it
routes (codex_async.go):
- [features.async_compaction] enabled = true and
model_async_compact_threshold_percent. Codex reads the threshold only
in that table; one at the top level is ignored (tried).
- capabilities = { remote_compaction = "v2" } on [model_providers.magpie].
Codex starts a background compaction only on a provider with v2, which
it gives OpenAI and Azure alone. Tried with Codex 0.163 against a
sandbox gateway and a fake upstream reporting 70% use: without the
capability, no compaction in a whole turn; with it, compaction_trigger
requests ran beside the turn's steps and the next step's input held
the summary. The capability is written for a feature the user turned
on by hand too (#2493 asked whether magpie supports it: it didn't).
putProvider carries the table's capabilities over when a model switch
writes it again.
- What magpie wrote is in the stash (codex.async). A value the user set,
or changed since, is never written over and stays when the switch is
turned off; a bare async_compaction = true, an inline or a dotted
table is the user's as written. A config that doesn't parse is not
written to.
Not tried: Codex signed in with ChatGPT (openai_base_url to magpie on
the built-in provider, v2 by default), only the custom provider path.
Tests: TestCodexAsyncCompactionWritten, ...KeepsTheUsers and
...KeepsUsersCapability (internal/agent), each red with the matching
part removed by hand (no writing; no capability carry-over; no
ownership check on enabled). codex-async-compact.test.cjs: Chromium and
WebKit, en/zh/zh-TW/ja/de, red with the 1-100 check removed;
compact-at, i18n-keys, settings-general, settings-search pass.
TestSettingsSaveKeepsWhatItDoesNotSend holds the two new fields.
gofmt clean; go vet -tags nogui on darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main
|
||
|
|
a2c4aab1ba |
gateway: DSH's session header and compaction mark are recorded, also through a remote magpie (#2505)
h4rk8s asked that the Requests list tell DSH's context compactions apart
and attribute usage per DSH session, also when the call goes through
Remote Magpie, from the headers DSH sends and never from the prompt.
- x-deepseek-harness-session-id joins sessionHeaders, after the others:
sessionOf / nativeSessionOf / conversationID take it, so usage, the
Routing page and affinity see DSH's session, and passOnCaller already
sends a native session header on to a remote magpie.
- x-deepseek-harness-compact set (any value but "", 0, false, no, off)
makes callKind "compact", which PurposeOf groups as Compaction. Only
display reads that kind; routing is unchanged.
- withCaller keeps the mark on the caller and passOnCaller sends it on to
a remote magpie, so the other magpie records the call as a compaction
too. Neither header reaches a vendor (the request to it is built fresh).
- docs/subsystems/gateway-sessions.md says so.
Run:
- TestDshMarksSessionAndCompaction: direct and through a remote magpie
(two gateways over httptest), marked and unmarked with a summarizing
system prompt. Red on the old gateway.go/codex_backend.go/
remote_magpie.go (session "", kind "", remote sent neither header),
green now; asserts the vendor saw no x-deepseek-harness-* header.
- TestRemoteMagpieKeepsTheSession still green.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main
|
||
|
|
7d7dba31ae |
provider: removing or turning off a moved subscription's plugin moves nothing back
The built-ins are being retired (the owner, 10-16: 陆续把内置Provider下线掉),
so the last way back to one is gone. MoveBack, moveBack and releasePlugin
are removed, with the Left flag they set.
- SetPluginOff only turns the plugin off. A moved subscription stays
moved, off with it.
- RemovePlugin records the moved ids as the new state "removed". The
record keeps its accounts, which plugin.Remove leaves in the plugin's
auth store. Nothing moves or installs it by itself: MoveRetiring
skips it and keepMovedCurrent reads only "plugin".
- HandOver turns a removed record whose plugin is installed and current
back into "plugin", record and all. So does Adopt (the editor's Move).
- MoveRetiring moves an old "back" record again, whatever Left said.
- Plugins page, rm/off confirms: "{names} stops working until the plugin
is installed again. Its accounts are kept." / "... while the plugin
is off." The status after removing no longer says it is back on the
built-in.
- Strings: five old strings dropped ("Moving back…" among them), three
new ones in zh, zh-TW, ja and de.
- `magpie plugins rm`/`off` say the same in their output.
- Docs: provider-plugins.md (the states table, the Move-back paragraph)
and AGENTS.md.
Tests:
- TestNoWayBack is new. It covers a "back" record moved again, the
plugin turned off (still moved, accounts kept), removed (removed, not
reinstalled by keepMovedCurrent or MoveRetiring), installed again
(HandOver), and removed again then Adopt.
- TestReleasePlugin and TestMoveBackKeepsLapse asserted the way back
and are deleted.
- TestMove, TestHandOver, TestMoveTidiesItsPlugin and
TestAdoptBeforeSigningIn no longer call MoveBack. TestKeepMovedCurrent
uses the removed state.
- plugin-release.test.cjs checks the new asks and that the status names
no built-in.
Run:
- Broken by hand:
- With HEAD's migrate.go, TestNoWayBack is red at "turning the plugin
off moved it back".
- With HandOver's removed branch disabled, it is red at "installed
again: map[], moved false".
- go test -tags nogui ./internal/provider -run
'TestMove|TestNoWayBack|TestHandOver|TestKeepMovedCurrent|TestAdopt|TestInstallPlugin|TestWorkBuddyCheckin|Plugin|Migrat':
ok.
- GUI (NODE_PATH playwright, --test-concurrency=1): plugin-release,
plugin-move and i18n-keys, chromium and webkit: 17/17.
- gofmt -l clean; GOOS=linux and windows go vet of provider, gui and cli.
- Full suite: go test -tags nogui ./... -count=1 -timeout 90m at this commit rebased on
|
||
|
|
f9ceac1628 |
provider: a move onto the plugin takes every account, and no model holds it back
The built-ins are retired (the owner, 10-16: 一定要下线完毕), so a move
can't be held back by something only the built-in could fix. Before, a
move failed when every account was lapsed, when one account's check
failed (the vendor unreachable through the plugin), when the vendor
refused every account, or when a model in use wasn't in the plugin's
list. Each of those left the user on a built-in that is going away.
Now Move installs the plugin and imports every account:
- one the vendor refuses goes along marked lapsed, as before;
- one already lapsed, or whose check fails otherwise, goes along untried
and unmarked, for the plugin's own reads to judge, and is logged;
- no model is checked against the plugin's list.
Only an install failure, the plugin not serving the id, or a sign-in the
plugin won't import fails the move, which puts everything back and is
tried again after moveRetry. The movers' served (Devin, Cursor) and
builtin (ZCode) hooks, modelsInUse, modelNames, lapsedAll and devinBase
had no other use and are gone, with the tests of the hooks. The page still
translates an older magpie's lapsed, unserved and account whys, which
migrations.json can hold.
Tests:
- TestMoveEveryAccountLapsed and TestMoveTriesEachAccount are new, and
TestMoveToPlugin's first case is now a refused account that moves.
importAuth is a seam: the fake mover's "r-noimport" sign-in fails part
way, so TestMoveToPlugin, TestMoveTidiesItsPlugin and TestMoveCutShort
still test putting back.
- TestMoveCutShort's cut-short record now carries the sent sign-in's
hash, as a real move writes it. Without it putBack took the built-in's
sign-in as renewed. The old test passed only because the check renewed
the token a second time.
- Broken by hand: with a failed check or a refusal returning an error
again, TestMoveToPlugin and TestMoveTriesEachAccount go red.
What was run:
- go test -tags nogui ./internal/provider -run
'Move|HandOver|Lapse|PutBack|Retir|Adopt|KeepMoved|ReleasePlugin|
ZCodeStartPlan|Devin|Cursor' passes.
- go vet passes and gofmt -l is clean.
- At ab7b28510 on
|
||
|
|
9fcf6a6e7f |
provider: every deprecated built-in moves onto its plugin, and there's no way back
The owner, 10-16: 陆续把内置Provider下线掉…一定要下线完毕. The plugins now do what the built-ins did (the parity batch up to |
||
|
|
2c72563dd1 |
usage: Requests splits and filters by gateway key, with "No gateway key" for the calls none made (#2521)
MauriceCarlo asked for two things on Usage → Requests. 1. The gateway-key filter should show even when one key has calls. The picker hides itself under two options, and with one key it had one, so calls made with that key couldn't be told from calls made with no key. A "No gateway key" choice (callerKey=none) now sits beside the keys whenever the period has calls with no key, or it is the current pick. A single key's picker therefore shows and separates the two. The hidden condition itself is left to #2499, which another session has. 2. The trend chart and the ranking can split by gateway key. LED_SPLITS gains "Gateway key". It's offered only while the period has a key's calls, and it falls back to Model otherwise. A click on a rank row picks that key, or none, and a second click lets go, as the other splits do. Server: - usage.Dimensions gains "callerKey". A row's key is its CallerKeyID, or NoCallerKey ("none") when it has none, and the filter takes "none" as calls without a key. - Filter.Without(d) is the one place that clears a dimension's own pick, so the by-split lists every value. RequestPage's fast and slow paths both use it now; they each had their own switch. - usageapi names the split's shares from the key labels: "No gateway key" for none, the ID if a key was deleted. - OwnPage keeps a held key's view to its own share in by and in the chart's split, so one key never learns another's name or numbers. The series was already only its own rows. - docs/reference.md documents callerKey=none and by.callerKey. "No gateway key" goes into the core i18n.js. The gateway keys page says "No gateway keys yet", and i18n-keys' "a plugin's words are its own" matches on substrings. Tests: - TestCallerKeySplitAndNone runs the fast and the slow path over {}, one key, none, and none+an agent, and checks by.callerKey. Broken by hand, it goes red: once with the none clause in the filter removed, and once with Without's callerKey case removed. - TestUsageOverGateway: on loopback the split names both keys. A held key's by.callerKey is only its own. With the OwnPage scrub skipped, it goes red (another key's name leaked). - usage-ledger-key-split is new, in both engines, all five languages, and 1400 and 760 px. It checks: - the picker's options with the none choice; - filtering on none; - the split's rows, and a click picking and letting go; - no sideways scroll; - that a period with no key's calls shows neither the picker nor the pill. 32/32 pass. With the none option removed by hand, 11 go red. Run on origin/main |
||
|
|
440f66701f |
gateway: a 429 for native compaction's one account says the compaction pinned it, not that every account is capped (#2517)
When a conversation was compacted natively, only the key or account that sealed the compaction can read it (#1099), so checkpointReaders keeps the candidates to that one. When that account was at its usage cap, the 429 and the call record said "every account that serves X is held at the usage cap", although the other accounts were never candidates. That sent lm0711 looking at routing modes, which can't change it. checkpointHeld tells this case apart: the plan held only the sealer's account(s), and others were left out for the checkpoint. The error then names the account and its window, says the compaction it sealed is what keeps the conversation there, that routing mode and stays don't change that, and to raise the cap / spend credits or start a new conversation. The record reads "native compaction's account at its usage cap" (or its credits / both variants). cappedError and cappedRecord are unchanged for every other 429; their text is split into heldReasons and heldAdvice so both share it. docs/subsystems/gateway-routing.md says so. Test: TestNativeCompactionWriterAtItsCap seals a checkpoint on one account, caps it, and checks the 429 body and the record. Broken by hand (checkpointHeld returning nil), it fails with the old "every account" text. Run on origin/main |
||
|
|
9b04c4e20f |
plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.
Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
*.gateway.mjs is already the middleware's alias, so a hook importing
node:fs was also loaded as moejs middleware and failed there.
TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
it throws, times out, returns non-JSON, or changes tools, tool_choice,
function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
hangs up on response.completed, and the reply it got is still captured
as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
line (outcome code, calls, avg ms, bytes, failures; no content), and
Options. Strings are in en, zh, zh-TW, ja and de.
Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.
Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
non-stream. onRequest's note reached the model (the answer had the
codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
was rolled back (the reply came from the asked model) and no onResponse
ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
/backend-api/codex: the hook saw origin=local, agent=codex and the
query; the answer had the codename; onResponse success=true (before the
hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
hook package, no failed middleware.
Tests (base origin/main
|
||
|
|
ea3dee96a8 |
gateway: a URL magpie didn't choose is downloaded from public addresses only, wherever the request came from
|
||
|
|
c5f15cae7c |
provider: Amazon Bedrock's Mantle endpoint (@marktoown on X)
"添加 AmazonBedrock 的时候,API 还是旧的 Bedrock-runtime 节点,不支持最新的
Bedrock-mantle 节点". The reporter wanted to add Amazon Bedrock at its
Mantle endpoint, but magpie only offered bedrock-runtime.
What it does:
- A new vendor preset, bedrock-mantle ("Amazon Bedrock (Mantle)"), takes
the same Bedrock API key as the runtime.
- It has 17 regions of its own (mantleRegions): the
bedrock-mantle.{region}.api.aws hosts that answered on 2026-10-16.
The runtime's eu-west-3 has no Mantle host.
- Chat completions and Responses go to /v1, and Messages to
/anthropic.
- Unlike the runtime, its models are listed from GET /v1/models.
NoList stays on the runtime preset only.
- Mantle serves each OpenAI-style model under one prefix.
- OpenAI's closed GPTs and xAI's Grok are under /openai/v1. Every
other model is under /v1. Asking at the wrong prefix gets "model `x`
isn't supported on this route".
- provider.MantleBase picks the prefix from the model id. The
gateway's forwardOnce and the provider test's tinyBody both use it.
- For a model whose maker the rule doesn't know, the gateway asks
again once at the other prefix when Mantle refuses it for its route
(internal/gateway/mantle.go).
- When the second prefix takes it, the gateway remembers that prefix
in unfit. When both refuse, the client gets the first refusal and
nothing is remembered.
- IsBedrockMantle is true for the preset and for any provider added at a
Mantle host. IsBedrock includes it, so the shared Bedrock rules apply
to Mantle too:
- Claude goes on Messages only.
- The key is sent as x-api-key alone, which is what Mantle's own
examples send.
- max_completion_tokens is used, and metadata is stripped.
- Beta renames and refusals apply.
- There is no Priority.
- GPTs go to Responses first.
- I checked every other IsBedrock caller. None is runtime-only except
the legacy /openai/v1 -> Responses migration in normalize, which is
harmless for Mantle.
- A provider added by its Mantle address gets the APIs it wasn't given
(mantleEndpoints, in normalize). A chat or Responses URL given at
/openai/v1 is moved to /v1, because /openai/v1/models is a 404 and the
list lives at /v1/models.
- GUI: the editor's Key header row is hidden for a Mantle Anthropic
address, as it already was for the runtime's.
- Docs: README (en, zh) preset lists, docs/reference.md,
providers-accounts.md (a new row) and gateway-routing.md (a new row,
plus a test command).
What was run, in the worktree at
|
||
|
|
e243937ca3 |
gateway: a fast pick can be sent as Ultrafast where the account offers it (#1954)
zhenghaowen0967 asked for an agent's fast pick of a ChatGPT model to go as
Codex's Ultrafast without the client asking for it. settings.UltraPicks
holds the agent's fast picks that are set to Ultrafast; each one is in
FastPicks too.
- The gateway marks those candidates `ultra` in fastPick.
- On Chat and Responses, a try sends service_tier "ultrafast".
- From Messages, a try carries withUltra to forwardTranslated, which
sets Request.Ultrafast for the ChatGPT backend.
- In every case, the #1784 check decides the account. One whose list
doesn't offer Ultrafast goes after a mate that does (tierMate). With
no mate left, it is sent priority.
- That check now covers Chat as well as Responses.
- Sibling fix: chat.go dropped a Chat client's own service_tier
"ultrafast" (Fast was false, Ultrafast unset). It now parses as
Responses does.
- provider: SetFastTier (""/priority/ultrafast) behind SetFastPick.
CanUltra and UltraModels say whether one of Codex's accounts lists
Ultrafast on the model. UltraPicks follow a provider rename
(renameModelPrefs) and survive a GUI settings save.
- GUI: an option gets ultraOk/ultra. Where ultraOk is set, the bolt in
the picker steps usual -> Fast -> Ultrafast -> usual, as a camera's
flash button steps its modes. Ultrafast shows two overlapped bolts, in
the row and after the field's model. Tooltips and the status line are
in en, zh, zh-TW, ja and de. POST /api/agent-fast takes `ultra`.
- No `:ultrafast` suffix for routing groups yet.
Tests, each broken by hand and seen red:
- TestUltraPickSentUltrafast covers omp/Responses with no tier asked
(acct-pro:ultrafast), the Pro account out (then acct-plus:priority),
another agent unchanged, opencode/Chat and claude/Messages picks, a
Chat client's own ultrafast, and switching back to Fast or off.
- Red with ultra forced false (4 cases).
- Red without withUltra (claude went priority).
- Red without the chat.go parse (2 cases).
- TestSetFastPick: red without UltraPicks in renameModelPrefs.
- TestSettingsSaveKeepsWhatItDoesNotSend: red without the api.go carry.
- fast-ultra.test.cjs (en zh ja de, window and 440px panel): red (9/9)
without the Ultrafast step.
Run (vet, gofmt, GUI and full suite at base 8b84dc902; the reruns
below at a rebase onto
|
||
|
|
e733b0722e |
plugins: a provider plugin says which service tiers a model serves, and Codex offers them (#2514)
Lovest on Discord (#general, v0.1.1267): a provider plugin had no way to
say a model is served at Fast or Ultrafast, so Codex never offered them for
plugin models, and the host dropped the field anyway.
- host.js keeps m.serviceTiers (tiersOf: string ids or {id} objects,
trimmed, de-duplicated, anything else dropped) as plugin.Model.ServiceTiers.
- pluginCatalog puts them on catalog.Model.Tiers; CodexTiers offers a
plugin's tiers when it declares any, so codexcat writes service_tiers
(priority named Fast) into Codex's catalog and /v1/models.
- forwardTranslated keeps service_tier (OwnTier) for a plugin provider only
when the request is translated to its Chat or Responses and the tier is
one the model declares (provider.PluginTiers). A request relayed in its
own protocol was already sent as the client wrote it; unchanged. Cursor's
fast flag and #1954's ChatGPT tiers are untouched (#1954 not on main yet).
- Docs: serviceTiers in site/public/docs plugins (en, zh, ja) and a
"service tiers" section in docs/subsystems/provider-plugins.md.
Tests (internal/gateway/plugin_tiers_test.go, fake plugin FAKE_TIERS):
TestPluginModelServiceTiersListed (fake-1 priority=Fast + ultrafast,
fake-resp ultrafast, fake-claude none) and TestPluginServiceTierReachesFetch
(Responses→plugin Chat and Chat→plugin Responses send a declared tier,
drop an undeclared one; same-protocol relays as before).
Broken by hand: OwnTier branch forced false → 3 translated cases red;
CodexTiers without IsPlugin → listed test red; host.js serviceTiers: [] →
listed test red. Restored → green.
gofmt -l clean; go vet -tags nogui with GOOS=darwin, linux, windows clean.
Not tried with a real vendor plugin that serves ultrafast.
Full suite: go test -timeout 45m ./... at af9e0d6b2 (sandbox HOME, load
average ~408 from other sessions): every package ok except agent and
gateway, which timed out at 45m with no failed test (rerun whole: timed
out again, 0 failures), gui (TestMainWindowCorners killed, #1936),
TestVendorThatStopsMidAnswerIsSaid (filed #2535) and
TestSetAnswersWhileDevinAndProvidersHang (#1375). The reds and the tests
running at each timeout (TestCodexKeptOnChatGPT, TestReplyNamesMember)
pass rerun alone, except TestMainWindowCorners (#1936). CI is the gate.
|
||
|
|
d9e87eb328 |
gateway: clients opt into Claude subscription cache marks and TTLs (#1717)
Problem: Messages clients need control of cache boundaries and TTLs when a Claude subscription answers. Ordinary clients must retain their run identity, prompt and environment. A routing group's API-key member keeps its marks and must not report the subscription bridge's drops. Change: Select client-owned marks only with X-Magpie-Cache-Marks: client. Map system and fresh-history boundaries and the request tail, default missing TTLs to 5m, validate slot and TTL order, and separate opted-in run identities. Retain prefix constraints across live and saved runs. Report unmappable marks only for the Claude subscription try. Bound its selection hold to two seconds and clear the report and hold for a non-Claude fallback. Check ordinary identity bytes without a version-specific hash golden. What was run: Sandbox HOME, nogui: go vet ./... on darwin; gateway vet with GOOS=linux and GOOS=windows; full gateway tests; focused cache and usage tests with -race. gofmt and git diff --check passed. The group probe failed before the fix with tools:1 on the API-key reply in both routing orders and both stream modes. Hand-broken candidate scoping, stale report clearing, keepalive holds and ordinary identity bytes each failed behavior tests. Live, Claude Code on a Claude subscription and an Anthropic API key, through a recording proxy: in a group whose API-key member answers, in either order and both stream modes, the reply has no dropped-mark header and upstream receives the tool mark; a Claude answer reports tools:1; a failed Claude try followed by an API-key answer leaves no report. With a delayed API-key reply, the group's first keepalive came 0.85 s after a direct request's. Without the header, the outgoing request equals one from a gateway built at the same base. No GUI or real Linux/Windows execution. |
||
|
|
a15e576564 |
agent: OpenPencil uses magpie's models (@JC_be_better on X)
OpenPencil (ZSeven-W/openpencil, the openpencil-desktop app) keeps the builtin agents its chat runs on in settings.json under Rust's dirs::config_dir()/openpencil (read from its settings_io.rs and settings_payload.rs). magpie adds one builtin_agents entry, id "magpie", kind openai-compat at the gateway's /v1 with the magpie-openpencil key, preset custom, the picked models as OpenPencil writes a list: the first as `model`, `models` only for two or more, at most 64. The user's other entries and settings stay, and so do the display_name and enabled they give magpie's entry; a sync with nothing to change doesn't write. A file magpie makes gets "version": 1 (OpenPencil sets a file without it aside as corrupt); a file with another version, or none, is left alone. Disconnect takes the entry out, and the file when nothing else is left. OpenPencil reads the file once at start and writes it all back when it quits, so a change is refused while openpencil-desktop runs (Windows can't be asked, so the notice says to quit it first). Notice translated in zh-CN, zh-TW, ja and de. README (en, zh-CN), docs/reference.md and docs/subsystems/agent-wiring.md list it. open-pencil/open-pencil, the other app of the name, keeps its providers in its webview's localStorage, so it gets no row. Run, under a scratchpad HOME with GOCACHE/GOMODCACHE pinned: - go test -p 2 -tags nogui -count=1 -timeout 45m ./...: ok, 66 packages ok, 18 with no test files - gofmt -l: clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean - go test ./internal/agent -run '^TestOpenPencil': ok - node --test agent-notice-lang, i18n-keys, header-relang (Chromium and WebKit, every language, wide and narrow): 37/37 pass Broken by hand, each went red: the running check, the 64 cap, the version check, keeping the user's display_name, the no-op sync, and writing the version into a new file. Real use: OpenPencil v0.8.4 (latest release, arm64, sha256 checked against its SHA256SUMS) under a sandbox HOME, started on a settings.json magpie wrote with the user's own Anthropic entry beside it. It started and ran 15s with the file intact and no .corrupt copy. v0.8.4 has no `models` field, so it lists only the first magpie model; main lists them all. Not tried: a chat request through OpenPencil's UI; its exit save (it didn't quit on an AppleEvent and was stopped with TERM, so the write-back wasn't seen); Linux and Windows; a build of OpenPencil's main. |
||
|
|
7597c13237 |
gui: a curl example pasted into a provider's editor fills it in (@mark_li21 on X)
@mark_li21 asked: 能支持通过curl例子直接导入provider不? A curl example
from a vendor's docs, pasted into a custom provider's Base URL or API key,
now fills in the editor instead of being pasted as text.
curlOf (app.js) is one pure function. It reads the paste the way a shell
would: lines joined by \, cmd's ^ or PowerShell's backtick; curl.exe;
quotes and escapes. From that it takes:
- the API that the URL's endpoint names: /chat/completions is Chat,
/messages is Anthropic and /responses is Responses;
- the base URL before that endpoint, spelled by respellURL the way the
editor already wants it;
- the key from Authorization: Bearer, x-api-key or api-key;
- the model in the JSON body.
A key that is only a placeholder ($X, ${X}, %X%, <token>, YOUR_API_KEY)
is not taken. The key box is left empty and focused instead. A new
provider adds the model to its models. A saved provider's picks are left
alone, because adding to an empty list would narrow what it serves. A
preset's editor only takes the key.
A note in the editor says what was filled in. It also points out a
placeholder left in the URL, such as {WorkspaceId}, and a URL with no
known endpoint. Its four strings are translated into zh, zh-TW, ja and
de. Text that isn't curl pastes as before, including several keys at
once.
Found along the way: url.onpaste = fromCurl cancelled every plain paste
into the Base URL, because an on-handler that returns false cancels the
event. The handler is now wrapped. The test fails on the unwrapped one.
Fixtures, in internal/gui/tests/fixtures/curl, are the docs' own bytes:
- OpenAI chat (API reference) and Responses (quickstart);
- Anthropic Messages;
- DeepSeek, Zhipu, Moonshot and OpenRouter quick starts;
- Alibaba Bailian's Windows cmd example (^ and \"-escaped JSON);
- SAP AI Core's PowerShell one-liner (curl.exe, <Deployment_url>);
- Unsloth Studio's PowerShell example, with backtick continuations, as
its usage panel renders the template. This one is not copied from a
static doc page.
The doc row is "A pasted curl command" in
docs/subsystems/providers-accounts.md.
Run at
|
||
|
|
674b6ca288 |
gui: a provider's per-key proxy lines fold past eight keys (@NetRozee on X)
@NetRozee on X: a custom endpoint given a thousand keys froze magpie.
Cause. The editor's Advanced > Proxy drew a line for every key, each
with a Provider's proxy | Direct | Custom control. Each control, once in
the page, looked up its place among every .segs in the editor and slid
its thumb (segsPlace, slide): quadratic, with a layout read each. The
Accounts list above it already folded (keyFold); this list didn't.
Fix. proxyLines folds a provider's keys as keyFold does: past KEYS_FOLD,
the first KEYS_FIRST and those with a proxy of their own, then All N
keys; opened, a filter (keyMatches, as the Accounts list's) over
KEYS_PAGE lines and how many more, and Show fewer. Typing draws the
lines again under the filter, which stays in the page (#1055). A key not
drawn keeps its proxy: Save posts every key's own, drawn or not.
Subscription accounts' lines are unchanged. No new strings.
Measured (Playwright, the editor opened on a provider of N keys):
1000 keys 5000 keys
Chromium 1067ms -> 100ms 55.6s -> 93ms
WebKit 4809ms -> 68ms 203s -> 81ms
DOM 9388 -> 434 nodes 45388 -> 434 nodes
Tests: provider-many-keys-proxy.test.cjs (new, en and zh, Chromium and
WebKit): fails in all four on the old app.js (no All 300 keys). With
account-proxy, provider-many-keys, filter-ime, usage-keys-fold,
i18n-keys, click-scroll, provider-proxy, proxy-own-wording,
routing-proxy, plugin-proxy-page, signin-proxy and proxy-test: 221 of
221 pass in both engines.
Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui
./... (clean); go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME (GOCACHE, GOMODCACHE pinned) on
|
||
|
|
af601541ef |
routing: a request opens to its request and response (Fate on Discord)
Fate asked on Discord to see what a single request on the Routing page sent
and got back, such as a Codex prediction. The bodies were captured already,
in the Gateway page's 40 recent calls and the opt-in request archive, but
nothing led there from a Routing request.
- gateway: a Call carries the Routing request it was (Call.Route = the
trace's Route.ID), set where serve, the Codex backend and a refused title
record it. Server.RouteCall finds it in the ring. A route id is not a
call id. A route names its archive copy (Route.Archive =
call.archiveName()), set only when the archive was on, so it reaches the
saved history too.
- gui: GET /api/gateway/call takes ?route= besides ?id=. It is the same
handler, the same no-store, the same key guard and the same 404 once the
ring has let the call go.
- Routing page: the story's head has "Request and response". It fetches
only when pressed, and shows the masked bodies through callBodyPanel (an
SSE reply reads as its events). A request the ring no longer has shows
the archive's copy through archivePanel when the route names one.
Otherwise it says the last 40 are kept until magpie quits and how to turn
the archive on. Nothing more is captured or kept than before.
- The head now wraps. At narrow widths its buttons ran past the story
("Back to live" was cut off at 440px).
- The two button words live in i18n.js: i18n-keys' "a plugin's words are
its own" found them inside core strings.
- docs/subsystems/gui-shell.md says how a route reaches its bodies.
Tests:
- TestRoutingRequestOpensItsBodies (new): each of two routes gets its own
bodies; route 0 and an unknown route get 404. Red without
`call.Route = tr.ID` ("route …: 404").
- TestArchiveWholeBodies now checks that the route names the archive. Red
without the t.Archive line (`route names archive ""`).
- routing-bodies.test.cjs (new), chromium and webkit at 440px, en, zh,
zh-TW, ja and de, 10/10. It covers the ring's copy read only when asked,
hiding, another request closing it, the archive's copy, the
how-to-keep note, nothing past the story and no left border.
- Red with the client asking ?id= and with the head's wrap removed.
- routing-request-metrics.test.cjs: with the head wrapped, its 480px
picker clicks in WebKit landed on the footer. Playwright's WebKit places
elements in the scrolled view hundreds of px lower than
getBoundingClientRect, which elementFromPoint agrees with. The test now
clicks where the page shows them. 5 runs of both engines, 20/20.
Run in a sandbox HOME at
|
||
|
|
ba17c4f90d |
provider: a Command Code plan key's card shows the month's credits as a meter (#2451)
tianxia3111 runs Command Code on the keyed preset with a plan's key. Its
card showed the 5-hour and weekly windows as meters, but the month's
credits only as dollars left ($5.27), with no share of the month. The
cause: billing/credits leaves out the planId, so the key's card couldn't
know the plan's monthly pool. The signed-in subscription's card gets
that pool from billing/subscriptions.
The key's card (planKeyWindows -> cmdKeyWindows) now asks
billing/subscriptions with the same key for the plan. It then makes the
month a "Credits" window beside the other two, through the same
cmdQuotaOf the subscription's card uses ("$4.78 / $10.00" on a Go plan).
- The plan id is kept per key for ten minutes, since
billing/subscriptions takes 15-20 s at times.
- The id read before still counts while the plan can't be read.
- A key whose plan was never read keeps its two windows alone.
- A pay-as-you-go key, with no windows, still gets no card.
planWindows' request and status handling move into planBody, so that
cmdKeyWindows can decode the reply itself; other vendors are unchanged.
Run:
- New TestCommandCodeKeyCardHasCredits uses the reporter's own
billing/credits reply. Its billing/subscriptions reply has the shape
the other Command Code tests use (individual-go-monthly), because the
reporter's plan id isn't known.
- With the new branch disabled by hand, the test went red: two windows,
no plan. With it, green.
- TestKeyQuotasKeepLast now answers billing/subscriptions with 503 and
still sees its two windows.
- gofmt; go vet -tags nogui for darwin, linux and windows.
- Not tried against Command Code's real API: there is no plan key here.
- Full suite (go test -timeout 45m ./..., at
|
||
|
|
97f264c7fb |
gateway: a 413 on the OpenAI routes says request_too_large, so pi compacts (@wilsonxuuuu on X)
@wilsonxuuuu's pi, on gpt-6.1 through magpie, stopped on
"magpie API error (413): {...,"type":"api_error"}" at 114k of a 1M
window and never auto-compacted. The vendor's 413 was a body byte cap.
pi's overflow table (pi-ai utils/overflow.ts) knows a byte cap only as
request_too_large, Anthropic's type, which magpie already gave on the
Anthropic route but not on chat/responses. writeErrorSaid now types
every 413 request_too_large (Gemini keeps its own status shape). The
status stays 413 and the byte-limit hint stays; it is not turned into
context_length_exceeded, so Codex and Claude Code read it as before
(Codex reads code, not type). pi compacts once and retries once
(_overflowRecoveryAttempted), so a body that is still too big after
compacting stops instead of looping.
Run:
- pi 1.1.0's own isContextOverflow on the reporter's body: api_error
false, request_too_large true.
- TestPayloadTooLargeSaysRequestTooLargeToPi (an nginx 413 page from a
chat upstream) and the new Chat/Responses rows of
TestBodyRejectionErrorShapes fail with the gateway.go change reverted
by hand, pass with it.
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME:
every package ok. gofmt clean; GOOS=linux and windows go vet of
internal/gateway clean.
Not tried: a real pi session hitting a real vendor 413.
|
||
|
|
6641e1b0ac |
provider: a plugin sign-in drops what a request holds at once (#2449)
TestPluginLoginInstallsItsCLIFirst went red on macOS CI (run
38798393584) with "not signed in after the install: []". cli's run()
sets catalog.Changed = agent.SyncCatalog, and a sync left going from an
earlier step holds the catalog (provider.Hold), plugins and their
sign-ins among it, for up to a second. The host's "auth" event dropped
that only through catalog.Touched, told in the background, so on a busy
runner provider.Logins right after the sign-in read the snapshot taken
before it.
plugin.OnChangeNow registers hooks run before changed() or listed()
returns, i.e. before the host's reply after the event is read; provider
registers dropHeld there. Changed() is filememo.Forget + dropHeld.
Reproduced by injecting a pause where SyncCatalog holds (patch kept
outside the tree): without the fix red 3/3 with the CI message; with it
ok -count=5. TestHeldGoesWithAPluginChange: red without the fix ("held
from before the change: built 1 times, want 2"), green with it, also
-race -count=20.
Run: -count=20 -run TestPluginLoginInstallsItsCLIFirst ./internal/cli
ok; internal/cli, internal/plugin, internal/provider whole ok; gofmt -l
clean; go vet -tags nogui for darwin, linux, windows on the three ok.
Full suite: go test -tags nogui -timeout 45m ./... at
|