4e85cac01dfb2fbec48c4cbb9fa8f4d8621e679f
1808
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
10f1e97883 |
search: a GLM Coding Plan searches its own models with the plan's web search MCP
young02036 on Discord asked for the GLM Coding Plan's Web Search MCP in
magpie's web search. The plan's key is given for that server, so magpie
now asks it with the provider's own key, with nothing to set up: a
Streamable HTTP session at <host>/api/mcp/web_search_prime/mcp
(open.bigmodel.cn or api.z.ai, docs.bigmodel.cn/cn/coding-plan/mcp/
search-mcp-server and docs.z.ai/devpack/mcp/search-mcp-server), the key
as a Bearer, initialize, one tools/call of webSearchPrime with
{"search_query"}, then the session's DELETE.
- provider.ZhipuCodingSearch: only a provider or key on the plan's
/api/coding/paas/v4 (Zhipu's or Z.ai's host, or the zhipu/zai preset).
A pay-as-you-go key isn't served by the server and never asks it.
ZhipuSearches reads p.Keys itself, since KeysOn is counted per list and
searchesOwn runs on every request. ZhipuSearchKeys lists the plan's
keys, which are asked in turn.
- searchesOwn/ownSearch: the plan's own models search there first, as
with Kimi Code and WorkBuddy, and fall to magpie's searcher and the
search APIs when it fails. This happens only while Settings names no
searcher (glmSearches): a searcher the user named still searches for
every model, which is a value the user set.
- It is not offered as a searcher for other providers' models. A plan
with the Responses base (/api/v1) already searches natively there
(searchHosts, #660), and making it a no-model service would change the
searcher those users have now.
- The reply's text is read as a list of results, a list in a JSON
string, or a list under search_result/results/items/data. isError, or
words with no results, is an error with the key masked. The query is
masked as Settings > Privacy says (maskedQuery). Each ask is a request
log row (logOwnSearch).
- No GUI change: the setting has no switch, the same as WorkBuddy's.
- docs/subsystems/gateway-routing.md has a section on it, and the
searchesOwn lists there and in plugin-runtime.md name it.
Run (mote, at this tree):
- go test -count=1 ./internal/provider ./internal/settings
- go test -count=1 -run 'Search|GLM|Zhipu|Kimi|LoopGuard|Docs|Guard|WorkBuddy'
./internal/gateway: ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/provider:
ok
- gofmt -l: clean
The tests use a fake server only and never reach the network:
- TestGLMCodingPlanSearchesForItsModels: Claude Code's literal WebSearch
request to a plan's model. The fake gives an event-stream reply with
a progress notification before the result, and a double-stringified
result. Then a refusal, an unnamed versus a named searcher beside a
search API, and a pay-as-you-go key.
- TestReadGLMSearch: each reply shape, and prose.
- TestZhipuCodingSearchAddress: hosts, presets, a plan key beside a
pay-as-you-go one, a key that's off.
Broken by hand:
- With the old searchesOwn/ownSearch, TestGLMCodingPlanSearchesForItsModels
is red: the model had no search, 400 "no search tool".
- With glmSearches ignoring a named searcher, the test is red at the
named-searcher step: the MCP was asked and the named searcher wasn't.
Not tried:
- No real GLM Coding Plan key was available, so nothing was sent to the
real open.bigmodel.cn or api.z.ai server. The docs give neither the
tool's argument names nor its reply's shape. search_query and the
result fields come from Zhipu's Web Search API and a third-party npm
wrapper (web-search-zaimcp 0.1.2). If the real reply differs, a search
falls to magpie's other searcher or the search APIs and says why.
- The plan's MCP quota, and how a spent quota is worded.
- A GUI hint in Settings > Web search.
|
||
|
|
2260390a01 |
gateway: a Gemini thought signature goes back only to the provider that gave it
mimi001234 on Discord: Pi (openai-completions) on auto/gemini-4-argon, a group of google-vertex and google-aistudio-paid. Vertex AI served turns 1 to 14 and signed its calls; on turn 15 it answered 429, the group moved to AI Studio, and magpie replayed Vertex AI's signatures from gemini-signatures/. AI Studio answered every try with 400 "Corrupted thought signature." A signature is the issuing backend's, and only it takes one. - The provider that gave a signature is noted beside it, gemini-signatures/<key>.by (noteSigner, written through temp and rename), wherever a reply is read: decoderFor (every translated path: Chat, Anthropic and Responses clients, plugins, search, continuations) and sigTidy (a Chat relay, and a Gemini client's reply relayed as it came, now only read, in native mode). - Every request is fitted to its provider: ownSignatures in forwardTranslated, chatCallSignatures and geminiBodySignatures in passthrough. Another provider's signature goes as Google's documented skip_thought_signature_validator on a call, and not at all on text. A signature of no known provider (ids from before this change, a note that couldn't be written) goes as before. - A 400 "Invalid/Corrupted thought signature" (signatureRefused) is asked again once without signatures at any upstream Gemini's signatures reach (signaturesReach), relayed too, not only Vertex AI translated; it rests no account (restAfterMarked) and lets a group go on to its next member (shapeRefused). The signer is the provider id, not the account: two accounts of one provider share signatures as before. Run on mote (mote-run), the targeted run and vets at this change on origin/main |
||
|
|
47d5839397 |
library: sync and backup files carry the hooks
VincentChan on Discord (v0.1.3005) said part of the Library doesn't reach his other computer through sync. Checked kind by kind what the library part of a bundle carries: instructions (each set's text, a linked set's file text, the agents ticked, each agent's own addition), MCP servers, skills and subagents all go. Hooks didn't: library.Bundle had no field for them, so a hook made on one computer never reached the other, by WebDAV/S3/GitHub sync or a backup file. - library.Bundle.Hooks (*[]*Hook): name, description, event, matcher, command, timeout, agents ticked. Collect always sets it, empty too. Applied.Hooks (the entries magpie wrote into each agent here) stays out: each computer writes them on the sync Put runs, beside the user's own hooks, and records its own entries, so an entry the user edited there stays theirs. - Put replaces the hooks with the bundle's, so one taken out on one computer goes from the others. A nil list (a bundle from a magpie before this) keeps this computer's. - check refuses a hook with no name, no command, or named twice. The event and agents are carried as they come: an event a newer magpie knows is a problem on the agent here, not a refused library. - davsync: an empty list hashes as before the field, so upgrading with no hooks syncs nothing. - The CLI's backup line counts hooks; the GUI's sync/export/import ticks say "instructions, MCP servers, skills, hooks and subagents" in every language. - library.md and sync-backup.md updated, and they now name what stays this computer's own: projects, skill groups, CopySkills/SkillHow, SharedSkills, MCPHub. Instructions: two sandbox computers through the fake DAV server carried a named set and a change to it, a set linked to ~/.agents/AGENTS.md and a hand edit of that file, both computers having their own text first, an agent's own addition, and an agent installed after the first sync. All reached the second computer's CLAUDE.md/AGENTS.md (exploration tests, not kept). So no instructions change here; what VincentChan saw is not reproduced yet. Run (worktree at 0e55a7593; origin/main bf60ea596's two commits touch none of these files): - mote: go test -tags nogui ./internal/backup ./internal/davsync ./internal/cli ./internal/library ok; go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four packages ok; gofmt -l clean; go test ./internal/gui -run 'TestCoreScriptBudget|Words|I18n|Builtins' ok - GUI (wsl-run, Linux): i18n-keys, github-sync, s3-sync, sync-*, webdav-settings-refresh, library-backups-top, gui-de, gui-ja, gui-zh-tw: 187/187 Broken by hand: with Collect not setting Hooks, Put ignoring them and the hash not dropping an empty list (the old code), TestCarryHooks, TestCarryOldBundleKeepsHooks, TestCarryNewerHooks, TestBackupFileCarriesHooks, TestSyncHooks and TestNoHooksHashAsBefore went red. Not tried: a real WebDAV/S3/GitHub remote between two real computers; Windows and Linux runs of the Go packages. |
||
|
|
234903cb23 |
cli: magpie model api sets the API a model is asked on, as the editor's picker does (yew_fence_931206)
A relay with many models behind one key can now have each model's API
set from a script, not only in the provider editor's Names, prices &
levels ("API this model is asked on"):
magpie model api <provider/model>... chat|responses|anthropic|gemini|auto
magpie model api <provider/model>... --reset (auto)
magpie model api <provider/model> what it is asked on
magpie model apis [<provider>] the settings; with a
provider, every model
It saves through provider.SetModelPrefs, the editor's Save, into
settings' modelAPIs, so a running gateway reads it on the next request
and the agents' model lists are told once. Choices are those the editor
offers (modelAPIs in app.js): the APIs the provider has a URL for, when
it has two or more; Vertex AI none. --help anywhere prints the usage. A
flag in place of a model, an unknown API, a model the provider doesn't
list, or an API it has no URL for is refused; several models are all
checked before any is written. A saved setting for a model the vendor
no longer lists can still be reset. Documented in docs/reference.md
("The API a model is asked on") and the gateway-routing page.
Run (mote, via mote-run, at this tree on
|
||
|
|
0e55a75936 |
remote magpie: a request that goes round magpies pointing at each other stops after 8, and a remote that is this magpie lists its models once
Follows |
||
|
|
1fd02d33ce |
agentplug: an agent plugin can pick the model its agent starts on in a second file (str_, PiG)
str_ on Discord (#help, v0.1.3005): PiG's row on the Agents page only
switched the model list on, where Pi's picks the model it starts on.
PiG, like Pi, keeps its providers in ~/.pig/agent/models.json and the
model a session starts on in settings.json (defaultProvider,
defaultModel; PiG's docs/site/docs/settings.md, startup_model.go). An
agent plugin could name a model key only in the one file connect
writes, so agent-pig 0.1.0 had to be connect-only.
An agent's descriptor can now say `startup: {config, format, model,
keys}`: the other file, the key that holds the model (the id without
magpie's prefix) and keys written beside it. With it the row gets a
model field as a built-in's does. Picking one of magpie's writes
connect's keys into config and the model and keys into startup.config,
each key kept aside as before; a model of magpie's picked in the agent
itself still reads as magpie's; a model of the user's own picked there
while magpie's provider is listed counts as connected (Beside), not
drift, and is kept on disconnect. Sync rewrites the list and leaves the
startup model where it is. Off, or `magpie <id> default` with the plugin
gone (RestoreGone), puts both files back. startup without connect, beside
agent.model, in config's own file, or naming the model key among keys
is refused. An older magpie ignores the field, so agent-pig 0.1.1
(plugins repo) stays connect-only there. Every other agent plugin
already names its model in its own config; pig is the only
connect-only one.
Run (mote):
- go test -count=1 ./internal/agentplug/: ok
- go test -count=1 -run 'TestPlugged|TestPlugin|TestRestoreGone|TestAgent'
./internal/agent/: ok
- go vet, GOOS=linux and GOOS=windows go vet of both packages; gofmt -l
clean
- the four TestPluggedStartup* tests on the old code: red (the row had
a provider field and only listed models)
- real PiG 0.5.3 (darwin-arm64 release, SHA256SUMS checked) in a sandbox
HOME, models.json written by agent-pig 0.1.1's own connect and
settings.json as startup writes it, against a fake OpenAI server:
`pig -p` sent model deepseek/flash with the gateway key. With an
enabledModels scope that leaves it out, PiG started on the scope's
first model (said in the plugin's README).
Broken by hand: no startRestore in Unwire (TestPluggedStartupModel and
OwnPickKept red); no Beside (OwnPickKept red, "wired false").
Not tried: the GUI and the TUI with the real row (app.js unchanged; the
row is the model field every built-in has), Windows and Linux runs of
PiG, a real magpie gateway in front of PiG, a real vendor model.
|
||
|
|
c2c991a5b3 |
remote magpie: two magpies each the other's remote no longer list each other's models back without end
cdredfox (Discord) saw 100-200% CPU while magpie used a remote magpie
over Tailscale, gone with the remote off. Their providers mask anyway
and their agent asks auto/ ids, so the earlier unmasked-group lead
doesn't explain it. What does: when A and B are each other's remote,
A's /v1/models (to another magpie) lists rem/<B's models>, B fetches it
as back/rem/..., lists that back to A, and so on: one level deeper on
every 10-minute fetch, without end. Each level is another member of
the found auto/ group and another route round the two machines, masked
again on each pass. On mote, two sandbox magpies in that setup went
from A: [auto/m1 own/m1 rem/auto/m1 rem/up/m1 rem/back/own/m1] to
[... rem/back/rem/back/own/m1, rem/back/rem/auto/m1 ...] after one
more scheduled fetch, and B had back/rem/back/own/m1. A request on the
loop route (rem/back/own/m1) cost A 1.07s CPU over 10 turns against
0.69s for own/m1.
The list a magpie gives another magpie now names, as magpie_via, the
magpies each model passes through, itself last. Each process has a
random id (catalog.Self). A fetched list leaves out a model whose via
has this magpie and another one (it left here and came back), or more
than 8 magpies. A remote that is this magpie itself (via only this id,
as the in-process tests set up) is kept. A magpie older than this sends
no via, and its list is taken as before: both machines need the update.
Stamped on every list a magpie gives: models(), its deciders, and the
drawer and video lists. A routing group's via is its members'
together, so A's auto/m1 holding B's auto/m1 (which holds A's) is left
out at B, and requests no longer go A -> B -> A through groups.
What a user of A loses: B's own auto/ group of a model when it holds
A's model (it reaches A again); B's own models stay listed at A one by
one, and A's group of the model holds them. The cached list keeps Via, so a model a remote served
through others keeps its path in this magpie's list too.
Run (mote, at this tree on
|
||
|
|
681a472cab |
agent: a Codex thread started during the takeover comes back to OpenAI once it is quiet, not hours later (nb5p on Discord)
nb5p on Discord (v0.1.3001, Codex app): after Send greyed out, Retry in
Codex did nothing. The model picker and Send spun, the same dialog came
back a few seconds later, and the model field read "model unavailable".
With the ChatGPT account Codex is signed in to used up, magpie makes
itself Codex's provider (codex.out), so a turn sent then starts a thread
saved with model_provider "magpie". When the account has room again,
Sync puts Codex back on OpenAI, and its deferred bringBack moves magpie's
threads to OpenAI. It skips a thread written to in the last minute,
which is the one the user was in, and leaves it "for the next Sync".
Nothing schedules one, though: Sync runs on a catalog change, which can
be hours away. The app then can't resume that thread on the provider it
is now on ("This chat uses magpie, but your current provider is
openai", the string still in the Codex the app bundles), so each Retry
failed the same way.
bringBack now asks whether a thread is still on magpie because it was
being written to (sessions.CodexThreadsBusyOn: the state databases' rows
on magpie whose rollout changed within ActiveWindow). If one is, it asks
for one more Sync after ActiveWindow+5s. Only one wait is pending at a
time.
docs/subsystems/agent-wiring.md says so beside bringBack.
Test: TestCodexTakeoverThreadComesBackOnceQuiet. The takeover is on, and
a thread on magpie is written to now. The account comes back, and the
thread stays on magpie while it is written to. A later Sync is asked
for, and that Sync, with the thread quiet, moves it to openai. No other
Sync is asked for after that.
Broken by hand: with the bringBack hook turned off (`if false && ...`),
it fails with "no later Sync asked for" (5.3s). Restored, it passes.
Run on mote at this tree (base
|
||
|
|
3d0d790606 |
codex: the Codex app left on an account that runs out is restarted onto the one Codex is signed in to (nb5p on Discord)
nb5p has two ChatGPT accounts in magpie, B first. The Codex app showed A, and once A ran out Send was grey for every model, magpie's and another provider's too. Cause: magpie's switch back to the first account (or to the account Codex is kept signed in to) leaves the Codex app's app-server running unless "Restart the Codex app to follow" is on. The app-server keeps the account it started on (CodexAppStale), so the app stayed on A while auth.json said B. magpie read only B, which had room, so nothing moved, magpie never took over, and the app-server was never restarted: the app greyed Send on A's allowed false for good. Fix: on each full look of KeepOnAnAccountWithRoom, restartCodexAppLeftOnSpent reads the account the app is left on, and once that is held (codexHeld) marks a spent switch (codexAppSwitched true), which codexAppStep restarts past the RestartApp tick, as a switch off a used-up account already does. Once per app-server left. Run (mote, at this tree): - go test ./internal/provider -count=1: ok - TestCodexAppLeftOnASpentAccountIsRestarted: user switches to A, magpie switches back to B and leaves the app running, A still has room (nothing ended), A runs out with B's room (app-server 7 ended), next look (not ended again). Broken by hand: - codexAppSwitched(true, false) commented out: red, "ended [], want the app-server left on the used-up account". - the once-per-app-server check off: red, "restarted again: [7]". Not tried: the real Codex app on a real account running out; the call in KeepOnAnAccountWithRoom's loop is covered by reading, not by a test. |
||
|
|
dabb5722f8 |
claude: Claude Code routed through magpie stays signed in where the user put it when that account is spent
oreoft on Discord has two Claude accounts: A, the main one, whose sign-in carries their claude.ai connectors (MCP), and B, a quota account. A's allowance was used up. They set A first and signed in, B second, and "跑着跑着" B came first again and became Claude Code's sign-in, and the MCP broke. They set it back more than ten times. Cause: the used-up switch (#208). KeepOnAnAccountWithRoom looks at Claude Code's sign-in every minute or five; A is spent, so NextLogin returns B and SwitchWhenSpent rewrites Claude Code's live credential to B. The GUI's list puts the account in use first (loginsInOrder), so B "moves to first". Each time the user signed A in again, the next look moved it back. Decision: when Claude Code's settings send its requests to magpie's gateway (ANTHROPIC_BASE_URL is the gateway, whether it signs in with magpie's key or keeps its claude.ai sign-in), NextLogin never moves its sign-in off a spent account. The gateway already routes every request to an account with room (it skips spent ones on its own), so moving the sign-in served nothing and only took away what the user signed in as. This keeps the user's choice and needs no setting. Still switching, unchanged: - not routed (Claude Code asks Anthropic as its own sign-in): the switch is the only thing that keeps it working (#208); - "Only switch Claude Code's sign-in" (SwitchOnly): the gateway serves none of those accounts, so switching is all magpie is asked to do; - the move back to the first account / the kept account (returnsToFirst, KeepLoginAs), which go toward the user's choice; - `magpie accounts switch claude next` and the GUI's own switch. - Codex is left as it is: the Codex app stops sending once its own account is out, so it needs the sign-in moved. ClaudeThroughMagpie is a provider hook the agent package sets (claudeRouted, the same check claudeIn's "routed" uses), like CodexAppRoute. Run (all on mote via mote-run): - new TestClaudeRoutedThroughMagpieKeepsItsSignIn (sandbox HOME: A spent, B with room; routed: three looks, no switch, credential still A's; SwitchOnly: switches to B; not routed: switches to B) with TestClaudeSwitchedWhenSpent, TestClaudeSwitchOnly*, TestKeepLoginAs*, TestNextLogin*, TestClaudeSwitch*, TestNextInOrder, TestCodexDrain*: ok. New TestClaudeThroughMagpieReadsItsSettings (agent): ok. - gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui; GOOS=windows go build: ok. Broken by hand: with the NextLogin gate turned off ("if false && ..."), TestClaudeRoutedThroughMagpieKeepsItsSignIn FAILs at line 80, "Claude Code routed through magpie was signed in to b@example.com". Not tried: real Claude accounts and a real Claude Code with claude.ai connectors; Windows and Linux boxes. Full suite runs after the push. A sign-in already moved to B stays on B until the user switches back once. |
||
|
|
49e382735f |
claude: a side question after a run's first reply of words branches by the reply's id
sleepy_shibe (Discord #feedback, magpie 0.1.2948, Claude Code 2.1.318,
claude-opus-5-5, macOS, interactive mode): when the last turn's reply
was words only, the turn after a prompt suggestion found no run
("claude: no run waits for this turn: its run ended 0s ago: the
interactive Claude Code can't go on with this turn") and a new Claude
Code was told the whole conversation as a transcript. With a tool call
in the turn it branched. 3 sessions, 7 times.
Cause (the reporter's reading, checked in a test): the interactive mode
streams a reply and the bridge hears its session line only later, from
the file. resume saves run.lastLine as the turn's backLine. A run's
first reply of words has no line heard yet, so backLine, behindLine and
the shelf's behindLine were empty while behindMsg (from message_start)
held the reply's id. branchAt returned nil at `at == ""` with no log,
and the run was let go. With a tool call, the run waited on the call and
heard the call's line first, so there was a line to cut at (
|
||
|
|
ed7aeb052f |
plugins: a package that declares magpie.agent is an agent, with a main or without (plugins#737)
miaocell's magpie-agent-deva ships a Bun module as its main beside its moejs agent file (deva.agent.js), because the agent needs a runtime. The market's GitHub list decided the kind by whether a main was there, so it listed the package under Providers, and the Installed row wore a Provider chip and a provider logo though the module serves no provider. Now readTagged gives Kind "agent" to any package that declares magpie.agent; middleware, page and hooks still need no main to be that kind. The file looked for in the repository is still the module Bun loads (its main), or the agent file when there is no main. The Installed row of an agent plugin wears Provider only when its module serves a provider, and its logo is the agent glyph unless it does. The moejs descriptor contract is unchanged. The community registry.json already gives kimi-desktop and reasonix-desktop (both with a main) kind agent; the plugins repo's check now fails an agent package listed as any other kind. Docs: docs/reference.md, docs/subsystems/provider-plugins.md, and site/public/docs plugins.html in en, zh and ja say an agent that needs a runtime keeps its agent file and adds a Bun main, and is listed as an agent either way. Run (on mote, at this head rebased on |
||
|
|
5ee9a18747 |
gateway: magpie's own summary ask keeps its status, so a compaction over the byte cap is summed up locally (#4862)
codexCompact asks a summary through the gateway's own handler (wantsWhole)
and reads a 413 as its cue to fit the conversation, then to sum it up
without a model. That ask was treated like a client's turn:
- with Codex's User-Agent, compactsInStream sent it a 200 and the 413 as
the stream's error, so codexCompact saw no 413 and answered 502 "so
there is no summary" for every compaction over the vendor's cap;
- with any UA, once the fitting tries took past keepHeldAfter (3s: a 40
MB upload asked four times, a slow link, -race on CI) keepAlive sent a
200 and a comment first, and the 413 after it came the same way.
keptAlive.whole (set from wantsWhole) now gets neither a keepalive nor
the in-stream 413. Codex's own turns are unchanged.
|
||
|
|
8b902e2879 |
checkin: a ZCode or Qoder captcha stands for the day, not asked again every 30 minutes (plugins#503)
ZCode's check-in is rechecked (pluginRechecks,
|
||
|
|
d892dd6a22 |
gateway: a Claude conversation keeps the folder it named first when its caller moves
EricWvi on X (Claude Code -> local magpie -> a magpie on a server -> a
Claude subscription): the cache read flipped between under 10% and over
90%, each drop on a turn whose folder had changed (.../frontend, then
.../frontend/src). Claude Code 2.1.316 says a cd as a later
"# Environment update" message, "Primary working directory: /y (was /x)".
clientNamedWorkPlace took the last folder named, so a run started again
for the conversation (saved session resumed, branch, replay) got a
different prefix than its first run:
- a caller elsewhere: envTurnsNote names the folder, so append.md changed;
- a caller on this computer: the run worked in the new folder, whose
session project doesn't hold the saved session, so --resume was lost
and the whole conversation was told again.
Either way the whole conversation was written to the cache again.
Now the first text that names a folder decides it (within that text, its
last line, so "said twice" in one system prompt keeps its meaning). The
move still reaches the model in the conversation as the caller said it.
No text is added to the prompt; the note's wording is unchanged.
The reporter's per-turn flips on a v0.1.2879 server are the earlier
safeguards restart (git_state.cwd in safeguardsKept), fixed by
|
||
|
|
9a51d644d6 |
gateway: a compaction's summary late past 4 minutes is magpie's own, sent before Codex gives up (#5275)
hayden4608 on Discord (#5275, asked as urgent): Codex Desktop compacting a ~108k-token conversation on volcengine/deepseek-v4.1-flash. The ~3.1MB summary request was still being written to Ark at 299s (TryNet Send ~299s, no first byte), Codex gave up at 300s (499), and only then did magpie log "the reply ended before it was complete; compacting locally". That local summary went to a request nobody was reading, and compactFails.done cleared the conversation's count as if it had worked. Codex sent the same history again, three times, 300s each, and the conversation never got shorter. - codexCompact gives the summary compactWithin (4 minutes, a minute short of Codex's 300s stream idle timeout, as agentQuietMost). Past it the vendor is no longer waited on (the ask's context ends with a sideTimedOut cause, so the usage log says "magpie stopped waiting: its compaction summary had no answer in 4m0s", not the agent canceling), and magpie's own summary (localSummary, saying "no summary came in 4m0s") goes to Codex while it still waits. Checked after the first ask, the ask as plain text, and the as-text ask after tool calls, so a late first ask is never followed by another ask of the same body. - A compaction Codex left before it was answered is counted a failure (499, "Codex left before the summary reached it") and nothing is written; done() is no longer called for it. After compactFailsMost in a row, the next is held with a 400 at once instead of another 300s. Why the upload was slow: not shown to be magpie's. From here a 3.1MB whitespace-padded chat request to ark.cn-beijing.volces.com/api/v3 was read whole in ~1.5s by curl over HTTP/2 and HTTP/1.1, and Go's client with vendorTransport's settings (HTTP/2, ping health) wrote it in 0.89s (HTTP/1.1 0.17s) from mote. The reporter's ~10KB/s, and their own 4MiB control not finishing in 40s by any route, point at the uplink or the Shadowrocket TUN in their path. Not tried through a TUN. Run (mote): TestCodexCompactLateSummaryCompactsLocallyInTime and TestCodexCompactLeftBeforeAnsweredStillCounts green with the fix; both red on the old code (the first: no answer before the client's 10s; the second: a completed compaction written to a Codex that left, and the next not held). go test -run Compact ./internal/gateway ok; go vet of internal/gateway for darwin, linux and windows ok; gofmt clean. Full suite: run after the push (go test -timeout 45m ./... on mote, log teed), result on #5275. Not tried: a real Codex Desktop session against a slow uplink; a reporter-side stream_idle_timeout_ms shorter than 4 minutes (then Codex still leaves first, and the count holds the conversation after 3). |
||
|
|
775630dac9 |
usage: the compaction picker says each window against the setting now
hayden4608 on Discord (#feedback): "上下文压缩阈值建议这里应该以当前选中的为
基准更直观 而不是以最省token的为基准". Usage › Context's "Other window…"
menu said every value's tokens past the leanest, so the window one had
set (ticked in the menu) read "+N tokens" like any other, and choosing
between them meant subtracting two notes in one's head. The reader
picks away from the setting in use, so that is the baseline now:
- each value says "−N tokens (−x%)" or "+N tokens (+x%)" against the
setting now's own point on the curve (the replay's cost at the current
value when the curve has no point there);
- the setting itself says "Your setting now";
- "Fewest tokens" stays, beside the leanest value's numbers (timed: the
cheapest, as before), so where the minimum is is still shown;
- the menu head says it: "Compact at · against the setting now, from
your calls of the range".
The chart and the "{pct} fewer tokens" line already compare with the
setting now and are unchanged. New strings in zh, zh-TW, ja and de; the
old head's key is replaced. docs/subsystems/agent-wiring.md says the new
baseline.
context-tune.test.cjs: the menu notes in every language at 360 and
1100 wide, against 300K set (−150M/−11% at 250K, −420M/−30% plus
Fewest at 160K, "Your setting now" at 300K), and again after 250K is
put in (250K is the setting, 300K +150M/+12%); the timed case against
120K set (100K −90M/−9% plus Fewest, 240K −20M/−2%).
Run on mote (mote-run), this tree before the rebase:
- context-tune: 120/120 chromium, 120/120 webkit
- i18n-keys 4/4 and compact-one-value 6/6 in each engine
- go test -run 'Budget|Script|Asset|I18n|Lang' ./internal/gui: ok
Broken by hand: the old context.js under the new test fails 20
subtests in chromium (both menu tests, every language and width).
Not tried: the real app with a real replay; the full GUI suite and
go test ./... (run after the push).
|
||
|
|
676b143175 |
gateway: a model refused for the user's region is asked once more, then the agent is told Google's restriction on that model (#5182)
taoxiaoxin (#5182) runs magpie v0.1.2738 with the built-in Antigravity provider, calling it with curl. antigravity/gemini-3.8-flash (upstream gemini-3.8-flash-tiered) answers 400 "User location is not supported for the API use.", while claude-sonnet-4-6 and claude-opus-4-6-thinking on the same accounts answer 200. The refusal is per model and comes from where the user is. A new connection doesn't help, and v0.1.2982 still asked every account and then retried the last two more times. - gateway.go: regionAsked counts region refusals per provider and model within a request. The first one goes on as v0.1.2982 does: the next account, or the same one again, on a new connection, which covers ggdayup's stale-edge case. On a second refusal, the provider's other accounts aren't asked that model (notMates), the last one isn't retried (protected), and another provider or model left is asked. Nobody rests (restAfterMarked, v0.1.2982). - fallback.go: regionNote and explained. The agent gets the vendor's words plus: "Google doesn't serve <model> to requests from the region this one left from: a regional restriction on the model, not on the account, so no account rests for it and the provider's other models may still answer. Use another provider for <model>, or give the provider a proxy in a region Google serves (its Proxy setting)". It is added at the four places that word a failed reply through Provider.Explain (translated stream and non-stream, pass-through, count_tokens). It still goes out as the 400 that SDKs don't retry. - docs/subsystems/gateway-routing.md: the bullet says this. Tests: - TestRegionRefusalOfTheModelEndsAfterOneMoreAsk: one and three accounts, stream and not, every ask refused. Exactly 2 asks, then a 400 that carries Google's words and the note. No account rests and no usage is re-read. - TestRegionNote: Google's and OpenAI's wordings. Nothing is added for another 400, or for a 200 that quotes the words. Run on mote (mote-run): - go test -count=1 -run Region ./internal/gateway/: ok, every #5182 test from |
||
|
|
79477604a5 |
providers: a plugin option that says placement "top" sits under the accounts, above Routing (#5269)
mycf_711 (#5269): WorkBuddy Pro's plugin-level "panel" switch was drawn in Plugin options, under the whole model list, so it took a scroll every time. An option in auth.options may now say `placement: "top"`: the provider's editor draws those in a Plugin options block right under the accounts, above Routing, and the rest under the models as before. The note that the plugin reads them goes with the first block. host.js keeps placement only when it is "top" (anything else is left out, so the option goes under the models), and plugin.Option carries it to /api/providers. A plugin that says no placement is drawn exactly as before, and an older magpie ignores the field. Documented in docs/subsystems/provider-plugins.md and docs/reference.md. Run (mote, through mote-run): - new internal/gui/tests/plugin-option-placement.test.cjs: chromium 31/31, webkit 31/31 (1100 and 420 wide, en/zh/zh-TW/ja/de; mixed, top only, none or an unknown placement; the top switch posted on Save). - plugin-options.test.cjs 11/11 and plugin-option-words.test.cjs 21/21, i18n-keys 4/4, each in chromium and webkit. - go test ./internal/plugin ok (TestPluginOptions checks "top" kept and "sidebar" left out); go test -run Budget|Script|Asset ./internal/gui ok. - gofmt -l internal/plugin empty; go vet ./internal/plugin ./internal/gui ./internal/cli, GOOS=linux -tags nogui and GOOS=windows vet of internal/plugin ok. Broken by hand: - app.js put back to its parent: the placement test fails "mixed" and "top" in both engines (blocks under the models), "none" still passes. - host.js's placement line removed: TestPluginOptions fails "second = {... Placement:}". Not tried: a real WorkBuddy Pro plugin (Gitee, private) with the field; the full go test ./... and the whole GUI suite run after the next commit. |
||
|
|
c32b820a91 |
gateway: a "User location is not supported" refusal rests no account, and the next try goes on a new connection (#5182)
ggdayup (#5182): Antigravity answered 400 "User location is not supported for the API use." on one kept-alive connection. magpie asked every account after it on that same connection, each was refused the same and rested, and the agent got a 400, while a new connection about 12s later was answered. The refusal is about the edge the connection reached, not about the account. - routing.go: restAfterMarked returns Rest{By: "off", Until: now} for regionRefused, as for zdr and offline, so no account rests and no failure is counted. - upstream_transport.go: regionFresh wraps each of upstreamTransport's three transports (any, draws, uploads), so every request through s.client is covered. It reads the first 8KB of each reply with status >= 400. When those match regionWords, closing the body calls CloseIdleConnections, and a pending flag calls it again before the next request. That flag covers an HTTP/2 connection that still carried another stream when the body closed. - fallback.go: passing() asks the last candidate again (lastRetries, after retryPause), on a new connection, so a user with one account is helped too. - docs/subsystems/gateway-routing.md: a bullet saying all of this, including what it doesn't cover. Tests (region_fresh_test.go, with a fake TLS edge that refuses every request on the first connection it sees and answers on any other): - TestRegionRefusalDropsItsConnection uses the real New() client, over h2 and h1. After a region 400 the next request goes on a new connection and gets 200. A plain 400 INVALID_ARGUMENT keeps its connection. - TestAntigravityRegionRefusalAsksTheNextOnANewConnection: two accounts. The second is asked on a new connection and answers, no account rests, and Tries[0].Rest.By is "off". - TestAntigravityRegionRefusalAsksTheLastAgain: one account. It is asked again on a new connection and answers. - TestRegionRefusalRestsNoAccount: Google's and Antigravity's wordings, two turns each. Both accounts are asked both times, with no rest, no failure counted and no usage re-read. A 500 still rests the account. - TestGroupFailsOverARegionRefusal (#1621) now asserts By "off" and no rest. Run on mote (mote-run): - go test -count=1 -run 'Region' ./internal/gateway/: ok. - go test -race -count=3 -run 'Region' ./internal/gateway/: ok (16.5s). - go vet ./internal/gateway/ for darwin, linux (-tags nogui) and windows, and go build ./... for all three: all ok. - gofmt -l: clean. - Full suite: run after the push, see #5182. Broken by hand, one at a time, each with a real FAIL and then restored: - regionFresh not wrapping the body: DropsItsConnection h2 and h1 region, AsksTheNext and AsksTheLast are red (the second request goes on the refused connection, and the turn gets 400). - restAfterMarked's early return removed: AsksTheNext and RestsNoAccount are red (By backoff, Failures 1). - passing()'s region case removed: AsksTheLast is red (the turn gets 400). Not tried: a real Antigravity account in a refused region. Nothing here can reproduce Google's per-edge refusal. Not covered: an HTTP/2 connection busy with another stream at that moment outlives the close until it is idle. The close also drops other vendors' idle connections, which costs one handshake each. A user who really is in a refused region now gets the refusal about 3s later, after the last candidate's retries. |
||
|
|
18726b9fb6 |
statusline: a held key is told how to see its line, ?format=json, and /v1/magpie/limit says what holds a key (steven_4422)
steven_4422 (Discord, #feedback): POST /v1/magpie/statusline answered 403
gateway_key_held to a key held to Claude's models, while GET
/v1/magpie/limit told the same key {"limited": false}. They asked for the
line scoped to what the key may use, /limit to agree, and a JSON line for
claude-hud's external usage snapshot.
The scoped view already exists (#2216): the status line goes through
scopeQuotas like the quotas routes, so a held key its owner turns Quotas
on for (Gateway -> Gateway keys, or `magpie gateway-key quotas <id> on`)
is told the accounts it may use of each provider whose every model it may
use, and nothing else. Its 403 never said so. Decision: the switch stays
the gate for every held key, budget, models or accounts alike. What holds
a key says nothing of whether its holder is the owner or a friend (#1981
was a friend's budget key seeing every account's email), and only the
owner knows that, so a model- or account-held key is not told quotas by
default either. The every-model rule of #2216 stays.
- scopeQuotas' refusal (heldQuotasOff) names the switch and what it then
tells. heldRefused, for the routes the switch doesn't open
(concurrency, trace, a card outside the scope, writeCards' told-none),
is unchanged.
- GET /v1/magpie/limit tells a held key heldTo (budget, models,
accounts), models, quotas and, with it on, quotaProviders (the
providers newQuotaScope tells it). No account is named. `limited`
keeps its meaning (the budget) for remote magpies that read it.
- ?format=json on the status line: {"text", "model", "accounts"}, the
cards the line shows in /v1/magpie/quotas?kept=1's shape (windows'
used, resetsAt), through the same scope.
- Docs: reference.md, integrating.md, gateway-routing.md; site docker
and remote pages in en, zh, ja.
Run at this head (
|
||
|
|
7661a0aa72 |
provider: Fetch models ticks each key's own models, the first key's too (young02036)
young02036 on Discord (#feedback, v0.1.2965): "点击供应商的获取模型,给这个 供应商的所有账号默认勾选上可用模型,和新增账号之后默认勾选上可用模型这个功能 好像失效了". Cause: no later change broke it; the two commits that built it each left keys out. |
||
|
|
0a6cccc3ff |
groups: a found group the user changed takes in a new provider with its model
Kxsg79bEYFP4 on X: magpie found auto/deepseek-v4.1-flash over two
providers, the user changed the group, then added a third provider (a
plugin's) with the model, and it never joined.
Cause: SaveGroup stores a changed found group under its auto-… id with
the members it had then, and buildGroupsIn skips the found group of
that id ("the user changed it: theirs now"). Nothing recorded which of
the found models the user had taken out, so a stored group could only
stay frozen. Plugin providers, id spelling and a one-time creation were
ruled out: a plugin's models are in providerEntries like any provider's,
and the found group itself has all three.
Fix: SaveGroup stores Group.Seen for an auto-… id: the models magpie
found in it by that save plus those the user names. Reading a changed
found group (joined) appends the found members it neither names nor has
seen, after the user's own. A model the user took out was seen and stays
out (magpie's default never overrides the user's value); a provider kept
out of found groups (AutoGroupSkip) doesn't join; with found groups off
nothing joins. Seen follows a provider's rename/SetModelID
(mapModelRefs) and a fold, and ShareGroup leaves it behind. A group
changed before this (no Seen) takes in nothing, since nothing says what
the user took out; its next save sees what is found then, and providers
added after that join. docs/subsystems/providers-accounts.md says so.
Tests: TestChangedFoundGroupTakesInANewProvider (join, order, routed by
FindGroup, the user's name/routing kept, taken out stays out before and
after joining, rename, skip, share), TestChangedFoundGroupFromBefore-
KeepsItsMembers (old stored group), TestChangedFoundGroupTakesInA-
PluginProvider (the reporter's surface: the fake plugin under real Bun).
Run on mote at base
|
||
|
|
387b386c84 |
codex: threads of the provider an older beside wiring took down move to OpenAI (yikelizi9438 on Discord)
yikelizi9438 (Windows, the Codex app): models wouldn't load, "This chat uses custom, but your current provider is openai. Switch to custom to continue", and "Model unavailable" in the composer. "custom" is CC Switch's provider id; magpie never names one so. Before #4347 ( |
||
|
|
d6e3a36ffc |
codex: threads of the provider Codex was on before magpie follow it onto magpie (hxy920830 on X)
hxy920830 on X: "magpie希望codex接入的时候自定义供应商名称,我现在名称被替换成了
magpie,原来的会话可以看到,但是加载不出来模型了". Codex had been on a
provider of the user's own (a relay's [model_providers.<id>] table, or CC
Switch's "custom"). Wired with no ChatGPT sign-in, magpie sets
model_provider = "magpie". bringOver moved only OpenAI's threads onto
magpie, so the relay's threads stayed on their provider. From Codex 0.166
(codex-rs app-server config_manager.rs load_for_resume) a thread resumes
only on the provider Codex is on now. The app lists them (thread/list
with model_providers [] lists every provider) but opening one stops at
modelProviderMismatch: "This chat uses <id>, but your current provider is
magpie". Nothing a user can set changes that, so a setting to rename the
provider wouldn't be needed. The threads should just open.
bringOver now moves the threads of the provider Codex was on before magpie
(stash codex.provider, "openai" when none was set), not only OpenAI's:
- an id of magpie's length ("custom") is relabelled in place
(RelabelCodexThreads), then packed ones from the last 30 days
(MovePackedCodexThreads), as OpenAI's already were;
- any other id ("myrelay") can't be written in place, so the threads of
the last 30 days, plain or packed, are rewritten with a copy kept in
the trash, newest first, 128 MB a sync (new
sessions.MoveRecentCodexThreads, sharing MovePackedCodexThreads' body
with packedOnly off). Older ones are left for Sessions' Move/Resume.
#887's guarantee still holds where it matters. Threads of any other
provider stay put. OpenAI's stay when Codex was on another provider. No
threads move for a provider a profile names (the user picks it with -p),
for cc-switch-official (bringOfficial handles it), or for a distro's
Codex. The Disconnect puts the user's model_provider back and bringBack
returns the threads to it, and CC Switch switching back to that provider
does the same. If Codex leaves magpie for a different provider,
bringBack hands them to that one, as it already did with OpenAI's moved
threads. profileNamed moved up so bringOver can use it.
docs/subsystems/agent-wiring.md says so.
Tests:
- TestCodexThreadsFollowMagpieIn "on a provider of the user's before"
used to assert that the custom thread stays. Now it moves to magpie in
place, with no copy, and goes back to custom at Unwire, with
model_provider custom restored.
- New subtest "on a relay's table of another length": myrelay's plain
and packed threads move with a copy kept, a 40-day-old one stays,
OpenAI's stays, and everything goes back at Unwire.
- New subtest "on a provider a profile names": the thread stays.
- New TestMoveRecentCodexThreads: newest first, a copy each, an old
thread and another provider's stay, and the packed-only move still
leaves a plain thread.
Run at this tree (on origin/main
|
||
|
|
cbb09383fb |
plugin: a GitHub-tagged package's card says its own name and summary (#3608, plugins#394)
MYCF711's #3608 (and plugins#394): a repository tagged magpie-plugin outside the community's list showed its repository's name and GitHub's description on its card under Discover → Unofficial, on GitHub, whatever its package.json said of itself. Ported from MYCF711's 1cc337001. Now readTagged keeps package.json's magpie.name (ownName, as main's row already does since |
||
|
|
7b5e773873 |
provider: a model at a window (claude-opus-5-5@300k) is priced as its model, so Cursor's sized ids have a cost
RyuJeXu on X (tweet 2117971061103100279), building an iOS board on magpie's
usage data: "cursor的用量好像不计费呀". Cursor calls showed no cost.
Cause: the Cursor plugin lists each model once per context size
(claude-opus-5-5@300k, @1m, gpt-5.5@272k, ...), lists them all at cost 0
(no price, pluginPrice), and its reply echoes the asked id, so usage rows
carry the sized id. pricedNames only took a window off grok- ids, so every
other sized id fell through the maker catalogs with no price. The plain ids
(claude-opus-5-5) were priced at the maker's list price all along.
Fix: pricedNames also tries the id with an "@<digits>k|m" window taken off
(modelWindow), for every provider. The window names the context size, not
a different model; long-context tiers still follow the call's own prompt
tokens through Price.At. Dated ids (claude-opus-4-5@20251101) and ids with
anything else after the @ are left alone. The regexp runs only for an id
with an @, since every listed model is priced on each Providers poll.
Tests:
- internal/provider/cursor_price_test.go: a moved Cursor provider prices
@300k, @1m, upper case, a maker-prefixed id and gpt-5.5@272k/@1m as the
plain model, through ListPrice, MakerPrice, PricedName(For), and its
tier at 300K prompt tokens; a dated id, "@272", "@", "@272kb", an
unknown model and auto stay as they were.
- internal/usage/cursor_window_cost_test.go: a Cursor row for
claude-opus-5-5@300k costs what the plain id does ($6 each), auto stays
unpriced, the page total is $12.
- grok_price_test.go: gpt-6-astra@500k under grok is now priced ($10/$50);
grok-4.7-build@500k still isn't.
Run (all through mote-run, go1.26.8, base
|
||
|
|
127f1e77dc |
gateway: a turn to another magpie goes as its new input after the turn it kept
LotusDecoder on X runs two magpies, each the other's provider. Codex says store false, so the leg between them carried the whole conversation every turn. Now passthrough asks a remote magpie to keep the Responses turn (X-Magpie-Keep-Turn: magpie/<version>). A magpie that does answers X-Magpie-Kept-Turn. This side records per route and scope a digest of each input item as sent, the reply's output types and ids, and the other magpie's id (remoteTurns: 16 per route and scope, 32 MB, prevTTL). The next request that continues exactly that input and reply goes as the items after them with previous_response_id. Anything else goes whole: an edited history, another answer, a magpie that never said it keeps (an older one). A refused delta is sent again whole at once, and the route goes whole for 30 minutes. The receiving magpie honours the header only from a magpie's hop (keepTurnAsks): its value starts magpie/ and the User-Agent is magpie's, or Codex's, which forwardOnce passes on for Codex turns. It keeps the turn under the caller's prevScope and the usual caps. An id such a caller names that isn't held gets previous_response_not_found before any vendor is asked. withCaller takes the header off on arrival, and X-Magpie- is never a passable request header, so no vendor gets it. Run on mote (mote-run) at base |
||
|
|
538026e62b |
gateway: an error frame inside a 200 fails at the status it names (#4855)
mycf_711's wps-lingxi rows read status=200: the plugin's stream already
sent its 200, then wrote {"error":{"message":"灵犀上游返回 AIError:
AI服务异常(上游暂时不可用,可重试)(HTTP 503)",...}}. On main a frame
mid-reply was booked at 200 and rested 60s as "other" with the error
"OK: ...", and one as the first event failed at the 502 the words'
guess gives. Routing never saw the 503 (or AuditFailed's 502).
Now the status an error frame names is what it fails, rests and is
booked at:
- a numeric status or code member, 400-599 (skygunner's patch: held
stream's errOf, errorReply, carriedStatus, and the sniffer's note on
the try's header for a reply already streaming, kept from the client);
- else "(HTTP 503)" / "(HTTP 503)" in the words, 429 and 5xx only, as a
quoted 4xx ("the image link answered (HTTP 404)") may not be the
provider's;
- a mid-reply call is booked at that status in Routing and Usage.
A quoted string code ("429", "1113") is the vendor's own code, not a
status. Words magpie wrote itself (loop guard, empty reply, relooped)
and too-long words name nothing, whatever members they carry: a LAN
peer's loop guard frame carries 502 in its Gemini shape. Such a frame
also no longer rests the route mid-reply (main rested it 60s as
"other" at 200); the model looping is not the provider failing.
Left out of skygunner's patch: streamFailure giving magpie's own Chat
frames a code and status. A peer magpie would read its loop guard frame
as a named 502.
Run (mote, at
|
||
|
|
8a80796805 |
gateway: the native route passes any path of a keyed provider's own API on, at its host
axelburks (Discord #feedback) asked for /v1/magpie/native/<provider>/... to reach the whole of a vendor's API, not only Ark's image and video task paths. Now GET, POST, PUT, PATCH and DELETE of /v1/magpie/native/<provider>/<path> go to the provider's host at /<path> (not under the base's /v1 or /api/v3), with the query and body as they came and the answer streamed back as it comes. Guards: - API-key providers only (nativeKeyed): no subscription, OAuth or plugin account, no remote magpie, no Vertex. 403 otherwise. - The gateway's own guards as every route: lanGuard's Host check, corsGuard (foreign Origin, null, *.localhost without a key), a key beyond loopback, read-only keys refused (PUT/PATCH added to readOnlyRefused), and a key held to models/accounts/limits refused (nativeHeld, as before). - nativeTarget refuses an empty path, "." / ".." segments (encoded too, across %2F), a backslash, a (encoded) leading slash, "://", a scheme-like first segment, and any URL whose host or scheme parsed back isn't the base's. 400, vendor not asked. - The caller's Authorization, x-api-key, api-key, x-goog-api-key, Cookie, ?key=, Origin/Referer/Sec-*/X-Forwarded-*/Cf-*, hop and X-Magpie-* headers are dropped; Sign puts the provider's key in the way it takes one. Set-Cookie, Alt-Svc and HSTS don't come back. - With masking on, a JSON body is masked (fails closed) and restored in the answer; a non-JSON body is a 415. Only a masked request's answer goes through restoring; every other answer streams in 32KB reads, never held whole. - Each request is a Requests row and a usage record (Operation "native"), with tokens when a JSON or SSE answer reports them. - Ark's short paths (nativeArkPath) keep their old code path, under the key's base, unchanged (nativeArk). Docs: gateway-routing.md (table row, native route section), reference.md (path table + paragraph), integrating.md, site integrate.html en and zh. Run (mote, darwin arm64, Go 1.26.8): - go test -count=3 -run 'Native|ReadOnly' ./internal/gateway: ok - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., gofmt -l: clean - Rebased on origin/main |
||
|
|
11d9d0a3a5 |
routing: each account one calm cell in Accounts and keys (danzi002 on Discord)
danzi002 (v0.1.2945): Accounts and keys "显示的好乱啊,没有之前一目了然". |
||
|
|
34116ec012 |
gateway: Codex signed in to one account lists another account's models
bigfisheatsmall on X: Codex was kept signed in to ChatGPT account A, on the Free plan. Account B (Team) was the only account on in magpie. dsh listed B's models and Codex didn't. codexMerged added CodexListed(), which leaves out every ChatGPT account's own models because it assumes the backend lists them. But the backend list is fetched with Codex's own sign-in (A, Free), so B's plan-only models were listed nowhere. Routing already sent codex/<model> to B (codexAccounts). - provider.CodexListedBeside(backend) lists an account's own model by magpie's id (codex/<slug>) when the sign-in's backend list lacks it. codexMerged uses it, and FitOwn keeps those entries. - spawnChoices (spawn_agent's models) had the same gap. It now uses the same rule with the slugs in Codex's models cache. - buildCodexListTag covers the accounts' own models, so another account gaining or losing one has Codex ask for the list again. Every Codex asks once after the update. - TestSyncCatalogAgesCodexCache built its "current" tag by hand from CodexListed(). It now uses provider.CodexListTag(), the tag SyncCatalog compares against. Tests (sandbox HOME, fake backend with per-plan lists): TestCodexListHasAnotherAccountsModels covers the list, routing of codex/gpt-6.1-sol to the Pro account, and spawn_agent's choices. TestCodexListOneAccountNoneTwice checks that a single account gets no codex/ duplicates. Run on mote at this tree: go vet (darwin, windows, linux) on gateway, provider and agent: ok. go test -count=1 on provider, agent and codexcat: ok. go test -run 'Codex|Spawn' on gateway and gui: ok. Run at the tree before the sync_test change and the buildCodexListTag tidy: the full gateway package was ok (1224s). Agent was red only in TestSyncCatalogAgesCodexCache, fixed above. Broken by hand: on the old codexMerged, the new test fails with "Codex's list lacks codex/gpt-6.1-sol: [gpt-6-luna gpt-5.6-terra gpt-5.6-luna]". With only codex_spawn_models.go reverted, it fails with "spawn_agent's models lack codex/gpt-6.1-sol". Not tried: real accounts or a real Codex. Not a full go test ./... run. Not tried: models the backend marks hidden. A Codex here for failover alone (codexOwnOnly) is unchanged. |
||
|
|
1b579ca4f8 |
router: Droid and omp get the hub's tools whole; find_tools' description names each server and its tools
tao5010 on Discord (11-04): with the MCP router on, omp, pi and droid
rarely called the servers behind it. Asked for a picture of a cat, the
model searched three times and stopped, and found magpie-image only when
told "我的mcp有啊".
Since v0.1.2950 an agent not in hubSearchesItself with more than 10 tools
is given only find_tools and call_tool. Droid (0.231) defers every MCP
tool to its own ToolSearch, showing the model names only, and omp (18.9)
mounts MCP tools in a catalog by each description's first line. Both were
handed two opaque tools whose description said only how to search, while
the servers were named in initialize's instructions, which Droid doesn't
show and omp shows apart from the tool. Read from droid's binary and
omp's dist/cli.js.
- hubSearchesItself gets droid and omp: they search their tools
themselves, so they get every tool whole as Claude Code, Codex and Pi do.
- find_tools' description, for every agent still given tools on demand,
starts with HubLine (each server and what it is for, <= 250 chars), then
how to search, then hubDetails (each server's tools) within
hubFindSayMax = 1200 characters.
Ran on mote at this head:
- gofmt -l internal/gateway (clean); go vet -tags nogui ./internal/gateway
on darwin, GOOS=linux -tags nogui, GOOS=windows
- go test -tags nogui -count=1 -run 'Hub|MCP|FindTools' ./internal/gateway: ok
- repro (sandbox HOME, magpie serve on 127.0.0.1:3563/3564, a fake stdio
server with generate_image/generate_video/generation_result and one with
12 tools, router on): the old build (
|
||
|
|
a1f1810e93 |
gateway: a 400 that only says the request is too long counts as an overflow once it is past half the model's window (#4420, MYCF711)
A group member answered 400 "内容太长了,请精简输入或开启新对话" at ~730K on a model it declares at 1M. |
||
|
|
7818dc316a |
gateway: a relay's Cloudflare 520 to 524 is asked again before the agent sees it, as a 502 or 503 is (vdaoren)
vdaoren on Discord: an API-key provider's 4xx/5xx now and then went
straight to the agent; they asked for retries on chosen status codes.
What a single API-key provider already did: the last one left is asked
again after a failure that passes (passing, fallback.go): 408, 500, 502,
503, 504 and 529 twice (lastRetries), a 429 that is a short rate limit
three times (rateRetries), pauses 1s, 2s, 4s or a Retry-After up to 8s,
then within the provider's patience (singlePatience, 60s by default,
`magpie provider set <id> patience=`) in rounds (busy, patience.go), all
while the reply is held and nothing has gone to the agent. A plan used
up, no balance, a 401, a request the vendor refuses for its content and a
conversation too long are the agent's at once.
What was missing: Cloudflare's own 520 (unknown error), 521 (origin
down), 522 (connection timed out), 523 (origin unreachable) and 524
(timeout), which a relay behind Cloudflare gives now and then, were in
neither list. Such a 5xx moved on to another member in a group, but on a
lone provider it reached the agent after one try. busyStatus now holds
the one list passing and busy read, with 520 to 524 added. No setting:
the default serves it, and patience= already exists for the length.
TestCloudflareErrorIsTriedAgain (retry_test.go): each of 520 to 524, as
Cloudflare words it to an API client ("error code: 520") and as its HTML
page, twice and then 200, is answered 200 after 3 tries; a stream's 524
then an SSE reply reaches the agent with nothing of the 524 in it; a 401
invalid key and a 400 content_policy_violation are tried once.
Broken by hand (busyStatus's list back to 408..529): red, every 52x case
"520 after 1 tries" and the stream "524 after 1 tries"; the 401/400 cases
pass either way.
Run on mote at this tree (base origin/main
|
||
|
|
b61c71448c |
keys: a custom provider's key can be made for its Gemini API (corddis_114)
corddis_114 on Discord has a relay that gives out a key per protocol,
one of them for Gemini ("gemini sk-d…SarG"), and the key row's protocol
menu offered Any, Anthropic, Chat Completions and Responses only. A
custom provider already serves Gemini upstream (its Gemini URL, the
"Gemini compatible" tab, x-goog-api-key, the model list through
FetchGemini, probes), so only the per-key layer lacked it:
- keyProtocolOK takes "gemini"; WithKey leaves a Gemini key the Gemini
URL only and takes the Gemini URL from a key made for another
protocol (it had kept it, so an Anthropic key could be sent to
generateContent).
- keyFit: a gemini* model (modelFamily Gemini) goes to the key made for
Gemini first, the other keys in their order behind it; a GPT model is
never put on the Gemini key (it ranked 0 there before). Claude's rule
is unchanged.
- app.js: Gemini in PROTO_OPTS ("Gemini API (generateContent) · Gemini
CLI, Gemini models"), offered when the provider has a Gemini URL;
keyLacksURL says "No Gemini URL" for a Gemini key without one. The
note in zh, zh-TW, ja and de. The provider-level tabs and Routing's
"keys for Gemini" already had it.
Run on mote (go1.26.8):
- go test -timeout 45m ./internal/provider ./internal/gateway: both ok (provider 229s, gateway 938s).
- TestKeyMadeForGemini, TestKeyProtocolGemini, TestKeysMadeForOneProtocol,
TestKeyForAProtocolWithNoURLIsSaid, TestKeyPoolsByProtocol,
TestCustomGeminiUpstream ok; internal/gui's budget tests ok.
- GUI (node --test, Chromium and WebKit, en/zh/zh-TW/ja/de, 420 and
1000px): key-gemini (new, 40/40), key-nourl, proto-menu-overflow,
key-row-chips-fit, key-plan, key-import, key-weight-fit,
provider-many-keys, provider-gemini, provider-add-gemini,
provider-url-each-api, model-api-gemini, provider-base-api,
routing-keys-fold and i18n-keys ok; the only red in the 360 was
tencent-cloud's region-strip test (#4321, open).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
go vet on provider, gateway, gui ok.
Broken by hand: the old fallback.go turns TestKeyMadeForGemini red
(Gemini models went to the Chat or Anthropic key, GPT to the Gemini
one); the old keys.go turns TestKeyProtocolGemini red (unknown
protocol "gemini"), and WithKey keeping p.Gemini turns it red too (the
Anthropic key speaks [anthropic gemini]); the old app.js turns
key-gemini red in all 40.
Not tried: the reporter's relay or any real Gemini-compatible relay;
the real app's editor.
|
||
|
|
4062cda781 |
provider: a custom provider at a Token Plan's or Ark's address is asked for no access key (ysm119)
ysm119 on Discord saved a custom provider (no preset) at https://tokenhub.tencentmaas.com/plan/v3 with a plain sk- key on the OpenAI-compatible tab, and its editor asked for a SecretId and SecretKey. AccessKeyVendor decides by host alone, so any provider at a Token Plan's /plan address (or an Ark plan's) got the access-key fields, and a Singapore Token Plan or Ark one also got a Usage card asking for them. Now AsksAccessKey(p) gates the two places a user is asked: the editor's listing (gui/providers.go) and the keyless Usage cards (tencentPlanQuotas, volcPlanQuotas). A preset's provider is asked as before; a custom one only once it has an access key saved (so a key the user did give is still shown and still used for its usage). The host rules themselves are unchanged, since presetAccessKey and the presets read them on providers with no preset of their own. The key itself was already sent as typed: no Tencent signing exists on chat, Responses, the model list or a probe; the access key only reads plan usage. TestCustomTokenHubIsSentAsTyped holds that (Authorization: Bearer <key>, on Chat and Responses). Run on mote (go1.26.8): - go test ./internal/provider ./internal/gui: provider ok; gui red only in TestMainWindowCorners (AppKit, #3949, macOS 27 on mote). - TestPlanCardWithoutAccessKey, TestCustomTokenHubIsSentAsTyped, TestProviderListTellsTencentAccessKey ok. - GUI (node --test, Chromium and WebKit, 5 languages): tencent-access-key, tencent-cloud, volc-access-key, usage-access-key-card, i18n-keys and the provider editor's key files ok, except tencent-cloud's "a region clicked right after the strip scrolled" (#4321, open, same on main). - gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on provider, gateway, gui ok. Broken by hand: AsksAccessKey returning AccessKeyVendor(p) always turns TestPlanCardWithoutAccessKey (my-ark gets a card), TestCustomTokenHubIsSentAsTyped and TestProviderListTellsTencentAccessKey (my-tokenhub, my-intl, my-ark asked) red. Not tried: the reporter's real tokenhub key; the real app's editor. |
||
|
|
7564e46690 |
library: a subagent names its model, written into Codex's role as model (#4421)
luckymanjc (Discord) set Codex's subagent model to Default on the Agents
page and gave a Library subagent a prompt that named a routing group.
Codex knew the group's name, but the subagent ran on Codex's own model.
A Library subagent had no model field, and Codex's role file
($CODEX_HOME/agents/<name>.toml) got only name, description and
developer_instructions. So Codex started the subagent on the model the
lead passed in spawn_agent, or on the lead's own model. The group was
only text in the prompt.
codex-rs reads a role file's model (AgentRoleOverrides). In
child_config.rs, prepare_agent_spawn_config applies the lead's
spawn_agent model, or [agents] default_subagent_model, first, and then
the role. So the role's model wins. A subagent now has a Model field: an
app menu with "Picked by the agent", the models and routing groups Codex
lists (groups noted as a routing group), and a saved id Codex no longer
lists. The Model is written as model = "..." to Codex's role only. A
subagent without a Model is written as before, byte for byte. Other
agents' files don't change; the hint names the agents that don't take
it. When the Agents page's Codex subagent model is set, the gateway still
puts that in place of the role's model (codexSubagentPick), and the hint
says so.
Run:
- Real codex 0.165.0 on mote, sandbox CODEX_HOME, fake Responses
server. With no role model, the collab_spawn request carried the
lead's model. With model = "group/review" in the role, it carried
group/review, also when the lead named gpt-6-sol in spawn_agent.
- mote-run go test ./internal/library: ok. TestSubagentModelGoesToCodex
went red with codexRole given "" for the model by hand.
- GUI library-subagents.test.cjs: 12/12 in Chromium and WebKit, in en,
zh, zh-TW, ja and de. Red with origin/main's client.js (timed out
waiting for the model picker).
- i18n-keys 4/4: it was red at first, because the plugin defined
"Routing group" and "Find a model". The change now uses core's
"routing group" and "Find a model…".
- gui-zh-tw, gui-ja, gui-de, library-all, library-gone-agents,
library-wsl-asleep: ok.
- gofmt -l is clean. go vet, GOOS=windows go vet, and GOOS=linux go vet
-tags nogui on internal/library and internal/gui: ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK is
red. It is red alone on origin/main
|
||
|
|
532d054bee |
sessions: every Cursor row has a delete, and the right-hand column lines up
ysm119 (Discord), Sessions page, Cursor tab: some rows had a delete and
some had none, and the time / "N sessions" column stood at a different x
from row to row.
Causes:
- Delete: listAgentWith set Deletable = Deletable(agent) && !ReadOnly, so
every editor-transcript row (read only) came back deletable:false, and
client.js drew .sm-del only for deletable rows.
- Alignment: a folder adds its ⋯ only when it has actions, and a session
row's Resume / terminal / Continue in / delete come and go per row, so
.sm-when, .cost and .num moved with them. "Copied" is wider than
"Resume", and at <=600px the cost line wrapped at different places.
Change:
- rowDeletable decides per row. An editor transcript the editor no longer
keeps (no state.vscdb, or it was read and has no composer for that id)
is "loose" and deletable: Delete trashes only its <id>/ folder or
<id>.jsonl/.txt, never state.vscdb. A chat the editor keeps, or a store
that can't be read, stays undeletable with undeletable:"cursor-editor".
- In an agent magpie deletes from, every row has its delete. One it can't
delete is aria-disabled, says why in its title, and a click shows the
reason in the status line and sends nothing (en, zh, zh-TW, ja, de).
- A row without Resume, Continue in or a terminal, and a folder without
its ⋯, keep that room with an inert, aria-hidden slot. Resume reserves
the wider of Resume and Copied; at <=600px the cost keeps a min width.
- docs/subsystems/gui-shell.md says so.
Run (on mote via mote-run, base f44fa2ef6; origin/main 93d5c76c0's 3
commits since touch none of these files):
- go test ./internal/sessions: ok. go test ./internal/gui: ok except
TestMainWindowCorners/macOS_26_SDK, an AppKit titlebar red on macOS 27
already filed as #3949.
- gofmt -l clean; go vet native, GOOS=linux -tags nogui, GOOS=windows ok.
- New sessions-cursor-align.test.cjs: 10/10 (chromium + webkit x en, zh,
zh-TW, ja, de; widths 1100/660/420, hover, Copied).
- Sessions GUI set (sessions-*, session-*, gateway-conversations,
gateway-mode-sessions, account-mask-sessions, header-session-hint,
routing-session*, routing-ctx-sessions, usage-session*, i18n-keys,
gui-de, gui-ja, gui-zh-tw): 728/728, and 728/728 again after the
rebase onto
|
||
|
|
93d5c76c0d |
router: an agent with many tools is given them on demand
ArvinCharl on X: the MCP router's tools fill the context. An agent that
doesn't search its MCP tools itself (all but Claude Code, Claude
Desktop, Codex and Pi) sends every tool's whole schema on every
request. Given more than 10 router tools, such an agent now lists two in
their place: find_tools (matches by name and description, the first 5
with their inputSchema, 15 more by name) and call_tool (runs one by
<server>__<tool>, its bare name, or arguments sent as a string; an
unknown name is told the close ones). The instructions still name every
server and its tools, and a tool called by its own name still runs. The
request log names the tool call_tool ran. The address for any other app
lists every tool, since which app connects isn't known.
Library → MCP gains a "Tools on demand" toggle (settings
routerAllTools, kept by KeepOwn and the settings API); turned off,
every agent gets every tool whole as before.
Run on mote (after the rebase onto
|
||
|
|
083821dc96 |
plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.
The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.
Run on mote at
|
||
|
|
f44fa2ef6a |
sessions: gateway mode lists only the gateway's sessions, never this computer's agents' files
paultian on Discord: magpie web in gateway mode, on a machine with Claude
Code and Codex installed, listed that machine's own sessions beside the
ones other computers sent through it. Owner's call (via the lead): keep
Sessions in gateway mode, scope it.
- sessions.OwnOff (set by the gui to ownSessionsOff): while it holds,
currentReads answers "none", Found and Dirs are empty, the trash lists
and restores/purges only what the gateway kept, and moving Claude
Code's folder is refused. Every route built on Reads follows: the list,
one, transcript, markdown, export, stats, overview, search, manage,
delete, carry, Usage's agent-file calls. Gateway-recorded sessions
(ledger projection, recorded conversations) are not behind the gate.
- ownSessionsOff: magpie web's page, and Settings' gateway mode On, or
Automatic with --gateway or no agents found (looked at once per 30s,
and again on another HOME/PATH). A turn of the answer resets the
sessions' caches and stats; the gateway-mode route does it at once.
- /api/sessions/reads says gateway:true: the page asks nothing, its empty
state names the gateway's sessions (en/zh/zh-TW/ja/de), and Settings ›
Privacy leaves out Agents' session history.
- The gateway-mode subtitle (5 languages), docs/reference.md and
site docs/docker.html (en/zh/ja) say Sessions stays and what it lists
(they said there was no Sessions tab, which was already wrong);
docs/subsystems/gateway-sessions.md has the design.
- Tests: Handler marks the process as magpie web for good, and 13 tests
served magpie web's page, so a later test's sandbox could be in gateway
mode by itself. webPageHandler ends the mark with the test, and
TestWebPageHandlerEveryWhere fails on a direct Handler(webHost{...}).
Ran (mote, at this tree rebased on origin/main):
- TestGatewayModeListsNoOwnSessions: red on the old code, green now.
- gateway-mode-sessions.test.cjs: chromium + webkit, en 900/390, zh,
zh-TW, ja 420, de 390: 36/36; red on the old client.js (every case).
- GUI files the change reaches (gateway-mode*, sessions-*, session-*,
privacy-*, usage-sessions-*, i18n-keys), both engines: 657/657.
- TestCoreScriptBudget ok.
- go test -shuffle=on ./internal/gui ./internal/sessions: sessions ok;
gui ok but TestMainWindowCorners/macOS_26_SDK, red the same on
origin/main
|
||
|
|
2f726b1f95 |
gateway: a request its vendor's risk control refused isn't sent on to the provider's other accounts (_teamtaylor_)
_teamtaylor_ on Discord: WorkBuddy's risk control spreads across accounts that send the same request, and magpie sent one request on from account to account until its tries ran out, so each account was restricted in turn. The gateway already read the refusal (WorkBuddy's 403 11140 as the plugin words it, provider.WBRestrictedHint; ZCode's 3012, ZCodeRestrictedHint) as failRestricted and rested the account 2h, but the candidate loop then went on to the next candidate, which is usually a sibling account. Now such a refusal (riskRefused: failRestricted and not a remote magpie's) walls the provider off for the rest of the request: its other accounts are dropped from the candidates (elsewhere), from busyNow's replan rounds and from roomy's left-out list (elsewhereWeighed). A group's other provider is still asked; with none left the agent gets the refusal. The last candidate's restricted refusal now rests the account too (before, only a non-last one did). Generic: any plugin ending its error in either hint gets it. The workbuddy plugin needs no change (it does no cross-account retry of its own). Run (on mote, through mote-run): - go test -count=1 -timeout 45m ./internal/gateway: ok (727s), before the rebase onto origin/main |
||
|
|
43849d51c3 |
routing: By session heads a session by its title, its folder quieter beside it (flandern1211_58540 on Discord)
Routing's By session headed each session "Claude Code · folder · title",
and with no title only the folder and id ("路由这里的会话名只能看到目录名和
会话ID吗"). Now the head is the agent and the session's title on one
line (whitespace folded), with its folder after it in a quieter .dir; with
no title the folder stands in, and with neither the id. The tooltip keeps
the title, the folder and the id.
The title comes from what magpie already reads, no second reader:
sessions.Titles (the agent's own title, else its first prompt) and Codex's
name index, and where both find nothing, the first prompt the gateway
recorded for that session (sessions.GatewayTitler, the title the Sessions
page shows for it), looked up under the agent the page names and the one
the gateway records it under (usage.AgentOf). A Codex thread Codex never
named now goes to sessions.Titles as a codex: key, so its rollout's first
prompt names it. withGatewayTitles and codexReadableTitles in trace.go.
Nothing is read that the Sessions page doesn't show already, and nothing
leaves the local GUI.
Tests: TestSessionTitlesFallBackToFirstPrompt (new): an unnamed Codex
thread gets its first prompt, a named one keeps its name, an unknown id
stays out, a pi session known only to the gateway gets its first words.
routing-session-folder.test.cjs follows the new head: title then .dir,
the first prompt on one line, the folder said once, the id with neither,
nothing clipped (chromium and webkit, en zh zh-TW ja de, 1100 and 420px).
Run on mote via mote-run, at origin/main
|
||
|
|
0f1b40bbc4 |
gateway: a reply in flight shows on Routing how much has arrived and roughly its tokens (#4951, Canda15)
A long or reasoning reply looked stuck on the Routing page. A request still out now shows, on its row and beside the account answering it, the bytes the agent has had, "≈ n tokens" once a rate is learned, and how long ago content last came; after 15s with no content the account's dot stops pulsing. Nothing stays once the request is done. Ported from Canda15's 7f7bdb189 (github.com/Canda15/magpie), the idea and the per-protocol content extractors kept, the hot path and storage reworked: - every write to the agent passes captureResponseWriter.Write, which calls liveRow.observe; the row hangs on the request's inflight (an atomic pointer), not a context value made per request - rates are in memory only (256 pairs); the fork wrote a JSON file under the estimate lock on every finished request - a whole JSON reply is counted in bytes only: the fork held and decoded up to 8 MiB of it at the end; a stream is cut into lines in place, only a line cut by a write's end is copied, a line over 1 MiB passed over, and each event decoded once (the fork ran json.Valid then Unmarshal) - the reply's kind comes from its first byte, not a header read on every write; the keepalive check allocates nothing (the fork split each write) - everything a row counts is under its own lock, and inflight.tr is read under f.mu; the estimate is in float64 (the int64 product overflowed) - the route's Seq is bumped on every write and traceGather batches the wake-ups; the fork's global throttle could drop the last update before a pause - learned only from a streamed reply that did not fail and had the vendor's output tokens - left out: the finished row's "Received" metric and the ended caption (layout restraint; an ended row has its own metrics), a duplicate "Received" i18n key, the receive-monitor doc (the design is in gateway-routing.md now), the fork's xmod and Windows CI commits The Routing plugin and i18n.js are outside TestCoreScriptBudget. Run on mote at this head unless named: gofmt -l; go vet (darwin), GOOS=linux -tags nogui and GOOS=windows go vet ./...; go build ./...; go test -race on the live tests; go test ./internal/gateway ./internal/gui (gateway ok; gui red only on TestCoreScriptBudget, #5139, 1533907 > 1533802 before this change and untouched by it, and TestMainWindowCorners/macOS_26_SDK, #3949); routing-live-bytes.test.cjs and i18n-keys in Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 420px (24/24); every routing-* and panel-routing* GUI file with i18n-keys in WSL Linux (Chromium all green; WebKit reds in 12 files, the same class at origin/main |
||
|
|
9095fd82d8 |
gateway: a conversation kept for its cache is asked again once on a passing 5xx before it moves (jiabubu)
jiabubu on Discord: a channel that errs once and answers a moment later had the conversation moved off it at the first error, under every rule, and the next one was sent it all uncached. Only the last candidate left (or Strict's lone one) was ever asked again. Now when the conversation is kept where it is (Affinity.Kept: Auto with a warm cache, Session, or within a turn) and that key or account fails in a way that passes (busy: overloaded 503/529, another 5xx that says nothing of quota, 408), and not as a 429, quota, refusal or sign-in, it is asked once more after retryPause (or a Retry-After up to longestPause) without resting. Once per request; failing again it rests and the next is asked as before. A conversation nobody answered yet, or under Stays Off, moves at once (keptAgain in affinity.go). The trace marks the try (Try.Kept) and the Routing page says it was asked again for what its vendor cached, not "nobody else is left to ask", in en, zh, zh-TW, ja and de. TestFixedMemberEffort and TestHeldRuleFailsOverWithinItsMember had a kept member fail with a lasting 500; they now expect it asked once more (kq1 kq1 kq2) before it moves, the outcome unchanged. Run on mote (mote-run): - TestKeptConversationAskedAgainBeforeItMoves (7 cases: Auto, Use before expiry, Session, failing twice, 429, new conversation, Off), TestFixedMemberEffort, TestHeldRuleFailsOverWithinItsMember: ok. - go test -count=1 -timeout 45m ./internal/gateway/: all ok but TestGroupBackupStandingInWhileTheFirstIsBackAndBehind and TestGroupMemberPutFirstOnItsMeritsKeepsItsCache, red with keptAgain switched off too: #5209. - routing-kept-again.test.cjs: 20 of 20 (chromium + webkit, en zh zh-TW ja de, 1100 and 420 wide). - GUI routing-*, group-*, i18n*, gui-* (2967 tests, concurrency 4): 42 red, all in files this doesn't touch; 14 of those files alone: 28 red, and the same files at origin/main |
||
|
|
7dd2434d31 |
remote quotas: a key with Quotas on but told no card shows why too (yi_time)
|
||
|
|
c03dee7e3e |
agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2 is a Tauri app that runs its models through K-brain, a Go backend it starts as `k-brain backend -data-dir <root>`; every provider lives in <root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME, else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to, else ~/.liveagent, on every OS (LiveAgent's data_home.rs and kbrain_backend.rs, K-brain's internal/config and internal/storage). Connect adds providers.magpie: type claude_code + api anthropic-messages (what LiveAgent's own settings write for an Anthropic-compatible provider), baseUrl the gateway root (K-brain appends /v1 and posts /messages with X-Api-Key), the key naming LiveAgent, activeModels null, modelOrder in magpie's order, models sorted by id with display name, window, output limit and input [text, image]. K-brain decodes with unknown fields refused, so only its fields are written. A default or compact model still K-brain's endpoint-less demo model1 becomes magpie's first; the user's own pick stays. Through a sync the user's name, the models they turned off, their order, K-brain's metadata and a model's own displayName stay; a new model is on and last; nothing to change writes nothing. A file K-brain wouldn't read as providers (not an object, providers not an object, top-level models, a bare provider) is left alone. Disconnect takes the entry out, puts picks back to K-brain's default, gives a file left with no provider K-brain's demo back (its CLI restores config.json.bak, which could hold magpie's, from a file with none), and removes a file holding only what magpie made. LiveAgent's backend holds the settings and writes them whole on any change, so a change is refused while liveagent or k-brain runs (macOS/Linux; the notice says to quit it first, in every language). Logo: the app's own 64px icon (src-tauri/icons/64x64.png, MIT) in an SVG. Run on mote at this tree: - gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin, linux (nogui) and windows - go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels' ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget red, which is red on its base too (app.js untouched here; #5139) - GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de: Chromium 27/27, WebKit 27/27 Broken by hand on mote, each red: the user's activeModels not kept (TestLiveAgentProvider "activeModels after sync [], want [...]"); the demo provider not put back (TestLiveAgentMakesItsFile "emptied file"); the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile). Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on 127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's bundled k-brain from the release dmg): - k-brain backend's first start wrote config.json as {}; magpie liveagent magpie then wrote providers.magpie and the default pick - `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config and routing code) answered "pong"; the upstream saw POST /v1/messages from magpie - the backend LiveAgent starts listed magpie's model in /v1/models with it as the default, and its /v1/text/generate answered "pong" through magpie - with k-brain running, connect/disconnect were refused with the notice; after it quit, disconnect removed the file magpie made Not tried: LiveAgent's window itself (its model picker was not opened; the backend's API it reads was); LiveAgent on Linux or Windows; a real vendor reply (fake upstream). |
||
|
|
0a5dc40abc |
gateway: a group's trusted Claude, GPT and Gemini thinking streams as it comes, a refusal or error after it going to the next member (#4166)
A try whose model's vendor may refuse after its reasoning (#248) had its reasoning held while another candidate could answer, whatever the member had answered lately. Through a routing group Claude Code saw a Claude member's thinking only with its text, all at once, and never its "thinking with <effort> effort". waynesguan measured it on one WorkBuddy account: `workbuddy claude-opus-5.5` alone, first thinking at 3.66s; through the group, all 67 thinking deltas with the text at 17.25s. Ported from waynesguan's 71aacaa (on |
||
|
|
e7b0c398ee |
sessions: find a ZCode title by its gateway id (#5195)
ZCode sends its session id to the gateway without the sess_ prefix stored in its database. Routing asks Titles with that bare id, gets no title, and falls back to the folder name even though the Sessions page can show the real title. Titles treats zcode:<id> as an alias for zcode:sess_<id> when it reads local session files, and returns the title under the key Routing asked for (the sess_ key too, which callers ignore). A regression test uses the database id shape ZCode writes and the bare request id it sends. Ported from Flandern's b1a952b73 (fix/zcode-routing-session-titles on flandern12111/magpie), code and test unchanged, reviewed line by line; the body is rewritten (the original had literal \n's), and gateway-sessions.md says it. Run on mote via mote-run, at origin/main |