char1eslu (#3766): AgentRouter answers gpt-5.6-sol, gpt-6-astra and
gpt-6.1-sol on chat completions with a 400, "模型 gpt-5.6-sol 不支持
/v1/chat/completions 接口,请改用 /v1/responses(OpenAI Responses API)。",
and serves them on Responses (gpt-5.6-sol on Messages too: the report's
provider test has ✓ anthropic). wrongEndpoint, the gateway's word that a
model is served on another API, which has the request asked there when
the provider has a URL for it (and remembers it in unfit), read English
alone. So while the provider had a Chat URL, a Chat client's request for
these models got that 400 back, whatever other URLs it had. The report's
200 ("/v1/chat/completions → /v1/responses") is a request translated
past chat, which d03779cc does for this host only while chat isn't
usable for the model, as after the report's url=. A Messages client's
request goes to the reporter's Anthropic URL and is answered there.
wrongEndpoint now also reads the message's two clauses, "不支持
/v1/chat/completions 接口" and "改用 /v1/responses", and asksResponses
the second, so a provider with its Chat URL alone gets the note that the
model is served on /v1/responses, which it has no URL for. Both read the
body's JSON strings decoded too (wordsOf), as the gateway's other words
are (#1669): the report quotes the message, not the body, and a relay
whose JSON escapes it (模型 ...) says the same. Neither clause
names a model, so the other two models' refusals match if their
messages differ only in the name (the report shows their 400 rows, not
their words). The routing page says so.
The same words now reach the group's checks, as retryable and
shapeRefused read wrongEndpoint. In a routing group (chat, drawing,
video, System One), a member answering this 400 ended the request there
on d03779cc: it was neither retryable nor shapeRefused, as
unservedWords' 模型.{0,12}不支持 misses these model ids by one
character. Now the next member is asked and this one isn't rested, as
for the English words. The image-tool and cache-key retries, which ask
again on a 400, don't on this one.
Not changed: a model's test, which still asks one API (the next
commit). Other relays' wordings: only the report's two clauses are
added, nor AgentRouter's other way round (a chat-only model asked on
/v1/responses), which the report has no words for.
What was run (tree 4e5bb297, on origin/main d03779cc, go1.26.8,
linux/amd64):
- TestChineseRefusalFallsBackToResponses, new: a provider with a Chat
and a Responses URL whose chat completions answers the report's 400
(its message verbatim; the JSON around it is a guess), as it is and
escaped as Python's json.dumps escapes it. A request on
/v1/chat/completions and one on /v1/messages each get the reply from
Responses, chat asked once and Responses once.
- TestWrongEndpoint: the report's 400, escaped too, and each of its
clauses alone are the wrong endpoint; "当前分组 default 下对于模型 gone
无可用渠道" (new-api's wording for a model no channel serves, written
from memory, not from the report) is not.
- TestWrongAPINote: AgentRouter with its Chat URL alone and the report's
400, as it is and escaped, gets " (asked at
https://agentrouter.org/v1/chat/completions; gpt-5.6-sol is served on
/v1/responses, which AgentRouter has no URL for)".
- The three, -count=50 -v: 150 PASS. -race -count=20 -cpu 1,2 over them
and the fallback tests beside them (WrongEndpoint, WrongAPINote,
FallsBack, OpenCodeGo, OtherRelayKeepsItsOneAPI): ok, no race.
- Broken by hand, each red:
- wrongEndpoint without the two clauses: every case of
TestChineseRefusalFallsBackToResponses, and TestWrongEndpoint's
rows of the whole message.
- wrongEndpoint with one clause of the two: TestWrongEndpoint's row of
the other clause alone (each).
- wrongEndpoint reading the body as it came: the escaped cases of
TestChineseRefusalFallsBackToResponses and TestWrongEndpoint's
escaped row.
- asksResponses without its clause: TestWrongAPINote, both bodies;
reading the body as it came: its escaped one.
- A real run: magpie built at d03779cc and at this tree (go build -tags
nogui -buildvcs=false), in a sandbox HOME, a local server standing in
for AgentRouter (its /v1/models lists gpt-5.6-sol, chat completions
answers the report's 400, /v1/responses and /v1/messages answer), set
up as the report has it: magpie provider add agentrouter url=...
key=... models=gpt-5.6-sol and anthropic=..., then responses=..., then
url= (the chat URL cleared). At each step magpie serve, and curl on
/v1/chat/completions (whole and streamed) and /v1/messages:
- Chat and Anthropic URLs: d03779cc answers both chat requests with
the 400; this tree 200, chat asked once and /v1/messages after it.
- Chat, Responses and Anthropic URLs: d03779cc answers both chat
requests with the 400; this tree 200, chat asked once and Responses
after it (the streamed one went to Responses at once: unfit).
- The chat URL cleared: both builds 200, the chat requests answered
on Responses.
- /v1/messages: 200 at every step on both, from /v1/messages.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit
1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
67 ok, and 7 red, none in what this changes: agent
TestInstalledVersion, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141);
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync TestSync
(#3420); edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram
(#3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); provider's "close of synctest channel from outside bubble"
from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
package's tests after it didn't run: go test ./internal/provider
-skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
PATH: ok.
Not tried: the real AgentRouter (no account here), macOS, an agent's
own requests (curl's stood in).
---- provider (second commit of the branch) ----
provider: a model turned away on one API is tested on the next (#3766)
char1eslu (#3766): after Test models, the three models AgentRouter
turns away on chat completions were red in the provider's Models list,
and Working only hid them, while the gateway answered them on
Responses. Their usage rows (kind provider_test, source probe: the
editor's test) were each a 400 on /v1/chat/completions, "模型
gpt-5.6-sol 不支持 /v1/chat/completions 接口,请改用 /v1/responses(OpenAI
Responses API)。". They stayed red after the reporter cleared the chat
URL (magpie provider set agentrouter url=), with their provider test
printing only ✓ responses and ✓ anthropic.
A model's test (testOne) asked one API, the first the provider speaks
unless the vendor's list, the user's pick or the client names another,
and took its answer as the model's. The editor's Test models sends the
editor's form, whose fields that aren't empty win over the saved
provider (typed), so a form that still names a chat URL the saved
provider no longer has asks chat: in the real run below that is red at
d03779cc, as the report's rows are.
Now, when the vendor says the model isn't served there
(catalog.WrongEndpoint: the gateway's wrongEndpoint, moved with its
words so both read the same), the test asks the next API the provider
has a URL for that may serve the model, by the gateway's rule (usable:
the model's listed or picked APIs, else each API the provider isn't
named-only on), with a key that sees the model on that API (keySeeing,
testOne's pick taken out as it was). That API's answer is the model's.
One that says the same has the next asked; when none is left the first
answer stays, so a provider with its Chat URL alone still shows the
vendor's message. Test models, a model's own test and Test as in the
editor, and magpie provider test <id> <model> (--as too), go through
it. As Codex the next API is asked with Codex's headers, as the gateway
sends them on Responses and Chat; as Claude Code the test isn't moved,
since the gateway sends Claude Code's headers on Messages alone.
docs/subsystems/providers-accounts.md says so, and the routing page
points there.
Not changed: which API is asked first, so a model that moved is asked
on chat again at each test before the API that serves it (the
gateway's unfit is its own). magpie provider test <id> with no model,
which tests each endpoint with a model of its own pick (testModel), is
as it was: its chat row can be red for a model the vendor serves
elsewhere, #3844.
What was run (tree 519dee3b, on origin/main d03779cc, go1.26.8,
linux/amd64):
- TestTestModelsMovesToTheAPIServingIt, new: AgentRouter with a Chat
and a Responses URL and a key for each (sk-chat made for Chat,
sk-responses for Responses), its chat completions answering the
report's 400 (its message verbatim; the JSON around it is a guess), as
it is and escaped. gpt-5.6-sol is OK on Responses, asked on chat with
sk-chat and then on responses with sk-responses, and nothing else. A
model chat turns away with new-api's "无可用渠道" (written from memory,
not from the report) is red after one ask. With the Chat URL alone,
gpt-5.6-sol is red after one ask, its error the vendor's message. When
both APIs say it, both are asked and chat's answer stays.
- TestTestModelsKeepsAModelOnItsAPI, new: a model the user picked chat
for, and one the vendor's list names on chat alone, is red on chat
after one ask, as the gateway keeps its request there.
- TestTestModelsAsAClientMovesAsTheGatewayDoes, new: turned away on
Responses with the word, a test as Codex is green on chat, asked with
Codex's User-Agent; a test as Claude Code is red on Messages after one
ask.
- The three, -count=50: 150 PASS; the gateway's
TestChineseRefusalFallsBackToResponses, TestWrongEndpoint and
TestWrongAPINote at this tree, -count=50: 150 PASS.
- -race -count=20 -cpu 1,2, internal/provider's TestTest and TestDetect
tests and internal/gateway's WrongEndpoint, WrongAPINote, FallsBack,
OpenCodeGo and OtherRelayKeepsItsOneAPI ones: ok, no race.
- Broken by hand, each red:
- the test never hearing the vendor's word, as at the previous
commit: TestTestModelsMovesToTheAPIServingIt, and
TestTestModelsAsAClientMovesAsTheGatewayDoes as Codex;
- the next API asked with the first one's key:
TestTestModelsMovesToTheAPIServingIt, red on responses;
- the next API asked whatever API the model is picked or listed on:
TestTestModelsKeepsAModelOnItsAPI, both models green on responses
after two asks;
- a test as Claude Code moved too:
TestTestModelsAsAClientMovesAsTheGatewayDoes, green on chat;
- the words in English alone, as at d03779cc:
TestTestModelsMovesToTheAPIServingIt, the report's message as it is
and escaped;
- the words matched in the body as it came:
TestTestModelsMovesToTheAPIServingIt, escaped.
The previous commit's own breaks of the words are red at this tree
too, in the gateway's tests.
- A real run: magpie built at d03779cc, at the previous commit and at
this tree (go build -tags nogui -buildvcs=false), in a sandbox HOME,
the previous commit's stand-in and steps. magpie provider test
agentrouter gpt-5.6-sol:
- Chat and Anthropic URLs: "✗ chat gpt-5.6-sol · 400 · 模型
gpt-5.6-sol 不支持 ..." at d03779cc and the previous commit, chat
asked alone; "✓ anthropic" at this tree, chat asked and then
/v1/messages.
- Chat, Responses and Anthropic URLs: the same ✗ chat, then; "✓
responses" at this tree, chat asked and then /v1/responses.
- The chat URL cleared: "✓ responses" at all three, responses asked
alone.
Then, the chat URL cleared, magpie web's /api/provider/test (the
editor's Test models) for gpt-5.6-sol: with the form naming the old
chat URL, red on chat with the vendor's message at d03779cc and the
previous commit, green on responses at this tree (chat asked, then
responses); with the form's chat empty, green on responses at all
three. The gateway answered as at the previous commit.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit
1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
67 ok, and 7 red, none in what this changes: agent
TestCodexDriftReached and TestCodexBehindReverseProxy (#3398);
TestInstalledVersion, TestHowInstalled,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141);
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640);
gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); provider's "close of synctest channel from outside bubble"
from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
package's tests after it didn't run: go test ./internal/provider
-skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
PATH: ok.
Not tried: the editor itself (magpie web's route, which its Test models
posts to, stood in), macOS, the real AgentRouter (no account here).
Review (yetone/magpie maintainer agent): the two commits of
JoeyWu-tech's branch (387191d5a, f8fcf936e, patch sha256 15d451ff…,
as the issue says) squashed into one, one commit per issue. Read every
line. The only other place reading these words, asksResponses (the
note that a provider lacks a Responses URL), reads the Chinese and the
escaped body too; no other matcher of a wrong-API refusal is left
(grep for the English phrases outside catalog.go).
Run at this tree on 6cb1cfb79, macOS, go1.27:
- red by hand: the two Chinese phrases taken out of WrongEndpoint:
TestChineseRefusalFallsBackToResponses (all four subtests) and
TestTestModelsMovesToTheAPIServingIt red. The next-API loop in
testOne off: TestTestModelsMovesToTheAPIServingIt and
TestTestModelsAsAClientMovesAsTheGatewayDoes red. Green restored.
- real run, macOS: base and patched builds in a sandbox HOME, a fake
AgentRouter (chat answers the report's literal 400, Responses
answers), magpie provider add agentrouter url=… responses=…, then
magpie provider test agentrouter gpt-5.6-sol and magpie serve with a
/v1/chat/completions request. Base: "✗ chat … 400 · 模型 gpt-5.6-sol
不支持 …" and the client gets the 400. Patched: "✓ responses", and
the client gets the answer from /v1/responses (vendor log: chat,
responses, chat, responses).
- at the pushed head (rebased on 5f3146be0; the docs conflict with
#3696's sentences merged, both kept): go build ./..., go test
./internal/catalog ok; gateway -run
'WrongEndpoint|WrongAPI|Fallback|FallsBack|Chinese|OtherAPI|Endpoint|OpenCode'
ok (50s); provider -run 'TestTestModels|TestTest|TestOne|Probe' ok;
vet linux and windows of the three packages ok; gofmt -l clean.
The whole gateway and provider packages were not run at this head:
another session's go test ./... held the machine (one suite at a
time).
Not tried: the real AgentRouter, the GUI editor itself.
What changed: on a DeepSeek model behind an Anthropic Messages endpoint
(anthropicReplaysThinking), magpie gives each tool turn that has no
thinking a block of its own, {"type":"thinking","thinking":" "}
(withThinkingOnToolTurns), and replays a turn's unsigned thinking as its
text (anthropicBody with replay). Both went out with no signature field:
aBlock's Signature is omitempty. OpenRouter's /api/v1/messages holds a
thinking block's signature to a string, so become2206's Claude Desktop
conversation on openrouter/deepseek/deepseek-v4.1-flash-1017 was turned
away after its first tool call ("OpenRouter: Invalid Anthropic Messages
API request", metadata path [..., 0, "signature"], "expected string,
received undefined"), on every retry. The reporter's capture shows the
same body with only "signature": "" added getting 200.
aBlock.MarshalJSON already writes a thinking block's "thinking" even
when empty; it now writes "signature" the same way. That is the one
place both blocks above are written, so the placeholder, a redacted
block turned into it, and replayed reasoning all carry "signature": "".
A signed block goes as before. Claude's own models and api.anthropic.com
are never replayed and are sent only signed thinking (anthropicBody), so
nothing changes for them.
Tests: TestOpenRouterDeepSeekThinkingHasASignature sends Claude
Desktop's Messages turns (relayed, gateway.go's withThinkingOnToolTurns)
and a Chat client's translated turns with reasoning_content to a fake
upstream that answers as #2883 quotes OpenRouter when a thinking block
has no string signature. The three tests that pinned the old bytes
(TestDeepSeekAnthropicToolTurnsGetThinking, TestDeepSeekAnthropicNoThinkingField,
TestAnthropicReplyAfterToolGetsThinking) now expect "signature":"".
Run:
- Breaks: with aBlock.MarshalJSON reverted,
TestOpenRouterDeepSeekThinkingHasASignature fails at the Messages case,
"messages: 400 after 1 calls: {"error":{"message":"OpenRouter: Invalid
Anthropic Messages API request",...". With a narrower fix that only
gives the placeholder in withThinkingOnToolTurns a signature, it fails
at the Chat case, "chat: 400 after 1 calls: ... Invalid Anthropic
Messages API request", so the replayed-reasoning path is held too.
Both pass restored.
- gofmt -l clean on the three files. go vet ./... for linux -tags nogui,
windows, and darwin -tags nogui: ok. go build for the same three: ok.
- Full `go test -tags nogui -timeout 45m ./...` on Linux amd64, go1.26.8,
at base c483feadf (origin/main as of 10-19 05:33 UTC) + this: 57
packages ok (20 of them from Go's test cache, unchanged since a first
full run of this tree that lacked only the
TestAnthropicReplyAfterToolGetsThinking line), 20 with no tests. Every
red is in a test this change doesn't reach, and each was run on
unmodified c483feadf:
- umask 077 on this box: edit's TestWriteAtomicReadOnlyHardLink and
testenv's TestProgram (fixtures written 0444/0755 come out
0400/0700). Both pass with umask 022.
- a broken /tmp/.git left on this shared box: agent's
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout ("error obtaining VCS
status: exit status 128" building their fixture).
- red on c483feadf too, cause not pinned (this box's PATH and proxy
setup): agent's TestInstalledVersion, TestOmpDetectedWithPiDir,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (3 of 3),
TestQoderSettingsFromAnIDEPluginIsNotTheCLI/qoder-cn (3 of 3),
TestCursorFolderFromTheEditorIsNotTheCLI (1 of 3) and TestZedAppPath
(2 of 3); claudebridge's TestCallbackGoesPastTheAgentsProxy;
gateway's TestClaudeToolCallbackOnANonLoopbackAddress; gui's
TestGatewayHeldByAContainer.
- red only in a full run, ok alone 3 of 3: davsync's TestSync, and
imagemcp's TestStalledDownloadSaysWhereTheImageIs (red in the first
full run only).
internal/gateway run again alone at the final tree: ok but for
TestClaudeToolCallbackOnANonLoopbackAddress, as above.
Real DeepSeek: on 2026-10-19, api.deepseek.com/anthropic,
deepseek-flash, a conversation whose assistant turn calls a tool and the
next user turn answers it, the assistant turn sent five ways: with no
thinking block, 400 "The `content[].thinking` in the thinking mode must
be passed back to the API"; with {"thinking":" "} (magpie before this),
with {"thinking":" ","signature":""} (after), with replayed text and no
signature, and with replayed text and "signature":"": each 200 with a
thinking block and the answer. So DeepSeek's own endpoint takes the
empty signature.
Not tried: OpenRouter itself (no account here); the fix rests on the
reporter's single-field experiment against it. darwin with the GUI
(cgo, Wails) wasn't vetted, as it can't be cross-built from Linux.
Review (yetone/magpie maintainer agent), for #3696 (magicseek), which is
#2883's problem A plus a problem B this patch didn't look at:
B: Claude Code 2.1.302 puts a turn's effort as output_config on a
{role: "system"} message; OpenRouter takes it as a configuration_update
and answers 400 "Mid-conversation reasoning effort (configuration_update)
is not supported on <model>" on DeepSeek and GLM. magpie already learns a
relay's refusal of exactly this field ("messages.1.output_config: Extra
inputs are not permitted", refuseShapes/shapeTurnEffort) and asks again
without it, keeping the request's own output_config and the system
message's text, then never sends that provider it again while it runs.
turnEffortRefused now also matches OpenRouter's wording, so the same
mend runs there. It is learned per provider, so a Claude model on the
same OpenRouter provider loses its per-turn effort too, as Claude Code
itself does after such a 400; the request's top-level effort stays.
Not done from the report: re-roling system messages to user, and pinning
a conversation's effort. The report's row "system message, no
output_config, DeepSeek: 400 Invalid Anthropic Messages API request" is
footnoted as the A/B combination, and OpenRouter's generic 400 names no
field magpie could learn from without also catching A's; asked on the
issue for that error's metadata path.
Tests: TestOpenRouterTurnEffortLeftOut sends the report's minimal
conversation plus Claude Code's system message with output_config, on
deepseek/deepseek-v4.1-flash-1017 and z-ai/glm-5.3-flash, to a fake that
answers the report's literal 400 for a message's output_config and
openRouterRefuseAnthropic's for an unsigned thinking block: 200 on the
second call, and the next request goes on the first.
Run at 810b00d07 + this on b92cb2f59 (origin/main), macOS, go1.27:
- red with turnEffortRefused reverted: both subtests "400 after 1 calls"
with OpenRouter's Mid-conversation message. Red with aBlock.MarshalJSON
reverted and B kept: the deepseek subtest "400 after 2 calls ...
Invalid Anthropic Messages API request", and
TestOpenRouterDeepSeekThinkingHasASignature. Green restored.
- go test -tags nogui ./internal/gateway -run
'Shape|Refus|OpenRouter|DeepSeek|Thinking|Effort|SystemMessage': ok.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
./internal/gateway: ok.
- full go test -tags nogui -timeout 45m ./internal/gateway at 136f96b22
(on 47175a68f): ok (549s).
Not tried: OpenRouter itself (no account here); both halves rest on the
reporter's captures.
jilen (#3728): fx asked magpie for codex/gpt-6.1-sol on
/v1/chat/completions and showed "system: InvalidChunk: Invalid Chat
Completions response at model (event 1).", while the usage log had the
vendor's 502, an EOF from chatgpt.com. No stream was saved, but fx's
InvalidChunk at event 1 says one had begun: magpie had kept fx alive
with the stream's headers and comments, so the failure went as an
event of that stream (streamError). The encoder streamError made, from
an empty Request, began the message before the error with a Chat chunk
whose "model" was "". fx takes a chunk with an empty model for a broken
one and stops there, so it never read the error after it. Anthropic's
message_start and Responses' response.created, response.in_progress
and response.failed went out with an empty model the same way.
keptAlive now keeps the model the request names when serve takes it,
as magpie spells it there: a flat id (a~m) is its catalog id, a dashed
Claude id its dotted one, and Codex's own model through magpie's
accounts codex/<model>. An effort the agent put on the model is kept on
it (a/m:high), the name it asked by. serve has it from the body it
already read for askedAt; on Codex's own sign-in (codexUpstreamOn) it
is the model Codex wrote, which its turn already read. Neither reads
the body again. streamError begins with that model, from failTo,
holdWriter.release and Codex's failWith. Gemini's error names no model,
as before. docs/subsystems/gateway-routing.md says so.
fx still shows no reason. Its Chat reader ends the stream with
ProviderError at an event with an "error" key and keeps nothing of it
(src/gateway/chat_completions_protocol.zig:723 in fx 0.0.14, :710 on
fx's main e71a663b); only an error status's body reaches its message.
So fx says ProviderError where it said InvalidChunk, and the vendor's
EOF is in the stream and magpie's usage log, not in fx.
Not changed: an error after a reply that already went, a loop cut's
(cutLoop), starts a message of its own after the vendor's, under a new
id. A model in it wouldn't help, fx stops at the new id: #3792. Nor the
error's shape: the encoders still begin a message ahead of it. fx looks
for an event's "error" before its id and model, so an error alone would
get past it too, but no other agent was tried on one; that is #3792's
question as well.
What was run (tree 908b9857, on origin/main 2beed3b0, go1.26.8,
linux/amd64):
- TestStreamErrorNamesTheModel, new: streamError in each protocol with
the report's model and message. Chat's, Anthropic's and Responses'
events name that model and no other, Gemini's none, and each has the
message.
- TestKeptAliveChatErrorNamesTheModel, new: a Chat stream through serve,
kept alive while the vendor says nothing, then the vendor gone with no
reply (the EOF), or answering 502, 413, a 200 that isn't a stream, or
a JSON 200 that is no reply. In each, the stream's first chunk names
a/m and the error follows; the 413's says request_too_large. Asked
for a/m:high, the vendor gone, the first chunk names a/m:high.
- TestKeptAliveChatOnCodexErrorNamesTheModel, new: the report's route, a
Chat stream on magpie's codex provider (Codex's sign-in), the ChatGPT
backend a local server that says nothing until the stream was kept
alive and then hangs up, each time it is asked. The first chunk names
codex/gpt-5.5, and the error after it has the backend's EOF.
- TestKeptAliveCodexErrorNamesTheModel, new: Codex on its own sign-in,
the backend overloaded, Codex kept alive while the turn waits to be
asked again, then the backend gone. Every model its events name is
gpt-5.5, the model Codex asked for, and they name one.
- The four, -count=50: ok.
- -race -count=20 -cpu 1,2 over them and the stream tests beside them
(TestStreamError*, TestGroupLastFailureInStreamSaysItPasses,
TestStreamedByteCap, TestLoopEnds, TestLoopCutMidLine,
TestCodexOneAccountOverload, the Quiet ones): ok, no race.
- Broken by hand, each red:
- streamError's encoder made from an empty Request again:
TestStreamErrorNamesTheModel, every case of
TestKeptAliveChatErrorNamesTheModel,
TestKeptAliveChatOnCodexErrorNamesTheModel and
TestKeptAliveCodexErrorNamesTheModel.
- serve's keptAlive with no model: every case of
TestKeptAliveChatErrorNamesTheModel and
TestKeptAliveChatOnCodexErrorNamesTheModel.
- keptAlive given the model without its effort: the a/m:high case
alone.
- failTo naming none: the 413 case.
- holdWriter.release naming none for a reply that is no reply: the
JSON 200's case; for an error status: the vendor gone, a/m:high,
the 502, the 200 that isn't a stream, and
TestKeptAliveChatOnCodexErrorNamesTheModel.
- Codex's keptAlive with no model, or its failWith naming none:
TestKeptAliveCodexErrorNamesTheModel.
- A real run: magpie built at 2beed3b0 and at this tree (go build
-tags nogui -buildvcs=false), magpie serve in a sandbox HOME, a
provider (a local server) that holds its first answer 20s and then
hangs up, or answers 502, and fx 0.0.14 asking it through
/v1/chat/completions (fx ask, its settings' provider
openai-chat-completions at the gateway), with --json and without.
fx exits 1 after about 53s each time: InvalidChunk at 2beed3b0, all
four times (hang-up and 502, --json and not), ProviderError at this
tree, all four. curl asking the same: ": keepalive" lines, then a
first chunk with "model":"" (2beed3b0) or "model":"up/m" (this
tree), then the error with the vendor's EOF or 502.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit
1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
67 ok, and 7 red, none in what this changes: agent
TestCodexDriftReached (#3398); TestInstalledVersion,
TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir (#3141);
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640);
gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); provider's "close of synctest channel from outside bubble"
from TestUnreadLoginsWriteErrorsKeepCredentials (#3632).
Not tried: the real chatgpt.com (it needs a ChatGPT account); the
ChatGPT backend was a local server that hangs up. fx's interactive
view, where the report's line came from.
Review (yetone/magpie maintainer agent), for jilen's #3728:
- Read every line. The only encoder built with an empty Request is
streamError's; its five callers (failTo, holdWriter.release's two
cases, cutLoop, Codex's failWith) are each given a model, cutLoop ""
on purpose (#3792).
- Red by hand at c711c3391 on 1cbdda25b, macOS, go1.27: streamError
back to &Request{}: all four new tests red; keptAlive built without
model: the two Chat kept-alive tests red; Codex's kept.model unset:
TestKeptAliveCodexErrorNamesTheModel red. Green restored.
- go test -tags nogui -race ./internal/gateway -run
'NamesTheModel|TestStreamError': ok. Full go test -tags nogui
-timeout 45m ./internal/gateway: ok (573s).
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
./internal/gateway: ok.
- Real run: magpie serve (base and patched builds) in a sandbox HOME, a
fake Chat vendor that holds 20s then answers 502, a streamed
/v1/chat/completions for fakev/fake-model. Base: the kept-alive first
chunk says "model":"", then the error. Patched: "model":
"fakev/fake-model", then the same error.
- Rebased onto ab546a4ee (gateway changed since): gofmt, vet linux and
windows, and go test ./internal/gateway -run
'NamesTheModel|StreamError|KeptAlive|KeepAlive|Alive|Codex' again
there: ok. The full package ran at the earlier base only.
- Not tried: fx itself, the real ChatGPT backend.
fremontdango on Discord ran two magpies. On the local one, a routing
group held one model from two providers of the remote magpie
(office/first/m, office/second/m). Its conversations were kept as if the
two were one vendor, because both are the one remote-magpie key here
(candidate.who()). The same group made on the remote behaved
differently:
- strict: when the first provider ran out, the conversation failed over
to the second, though strict means it never moves
- session/auto: with the first gone, the "same account, other model"
match kept the conversation on the second as "session", though nothing
of it was cached there
- the second's refusal of the first's sealed reasoning was recorded
against the whole remote, so the first's own seals were then taken out
of requests to it
- a native compaction one sealed went to the other too
There is now a vendor identity for these: candidate.vendor() and
sameVendor(who, model). Behind a remote magpie it is the key plus the
remote's provider, the model id's first part (remoteUpstream). A remote
group is one vendor by its whole id, and a model named without a
provider is the key alone. It is used by:
- affine's widest match
- strictOnly and strictKeep
- unanswered
- refused/withoutRefused
- checkpointReaders (native compaction)
- Codex leadFirst
Lanes, requests a minute and leastHeld's per-model seat stay on who(),
the limits the user set on the key here. Sticks and compaction writers
are stored as before (who plus model), so the sticks saved on disk still
match after the update. Only the local magpie (the one with the group)
needs this version.
Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
(559s) at 040a4ec29. After rebasing onto ab546a4ee (busy.go,
draw.go, gateway.go changed upstream): vet, gofmt and -run
'TestRemote|Strict|Affinity|Stick|NativeCompaction|Refused|Lead|Busy|Draw':
ok
- go vet (darwin, GOOS=linux, GOOS=windows, -tags nogui)
./internal/gateway, and gofmt -l: clean
- Two sandbox magpies, each under its own HOME/XDG dirs: the remote on
127.0.0.1:47611 with providers first and second (model m1, one fake
upstream on :47613 that answers 429 to first's key once a flag file
exists), and the local on :47612 with a Remote magpie provider and a
strict, ordered group of office/first/m1 and office/second/m1. Turn 1
of a session went to first. With the flag set, turn 2:
- local on origin/main: 200 from office/second/m1 (moved)
- local on this change: 429 "Office: First: usage limit reached"
(kept), and a new session went to second
Broken by hand: sameVendor reduced to c.who() == who made
TestRemoteMagpieStrictKeepsTheRemotesProvider fail (went to second) and
TestRemoteMagpieOtherProviderIsNotTheSameAccount fail (traced
"session", want "gone").
Not tried: the sealed-reasoning and native-compaction paths through a
real remote. They use the same sameVendor/vendor, and the package tests
for them pass. Three layers (local, middle, remote): the middle's
provider is the vendor here, and the middle keeps its own providers
apart.
Part 1 of 2, pruneDist (coffemon's first commit):
pruneDist took out every tarball in plugins/dist that
plugins/package.json doesn't name, as encoding/json reads it. Bun
installs a package from the tarball bun.lock's packages has it at, and
that can be one package.json has moved on from: gkd2323c's lock (#3622,
Windows, Bun 1.4.4) had autoclaw, codearts and cloudflare-workers-ai at
the tarballs before the ones package.json names, and those were gone
from plugins/dist, where nothing but pruneDist takes a file out. With
Bun's own copy of such a tarball, every bun command that changes
plugins/ puts the older version back; with none, every add and removal,
of any plugin, fails with "ENOENT extracting tarball from <that
package>" (part 2 has the likely why there was none).
Now a tarball the lock's packages has a package at stays, beside the
ones package.json names. Kept, it is what Bun installs: a package whose
lock is behind package.json stays at the older version without a word,
where 4e5b2ad8, once Bun had no copy, failed every command with ENOENT.
part 2 sends such a lock back to package.json before each bun
command when package.json has the package at a dist tarball too; with
package.json at npm it stays behind (#3720). package.json is read as
text, every dist/<file> in it counting, where encoding/json keeps one
value of a key named twice: Bun 1.4.0 adds a tarball's package a second
time instead of replacing it, the new tarball first, which Bun reads,
and encoding/json reads the second, so 4e5b2ad8 took out the tarball Bun
installs from. No magpie runs plugins on that Bun unless MAGPIE_BUN
names it (BunVersion has been 1.4.2 since 10-03, before plugins/dist
was), so that is how a decoded package.json loses it, not a path a user
is known to have taken. A tarball only the lock's workspaces names goes:
Bun 1.4.2 and 1.4.3 leave the one an add replaced there until their next
command, and nothing installs from it. With no bun.lock, package.json
alone decides, as before; with one that can't be read, nothing goes, as
with a package.json that can't be read.
This keeps the tarballs a lock has from going, and mends no lock: one
behind package.json's dist tarball, the reporter's or one that falls
behind later, is sent back by part 2, its tarball there or
gone.
What was run (tree 8f285445, on origin/main 4e5b2ad8, go1.26.8,
linux/amd64):
- TestDistTarballTheLockNamesStays (new): the reporter's package.json
and lock, built around the lines #3622 quotes; the package.json real
Bun 1.4.2 writes for `bun add ./dist/<0.2.6>` over 0.2.1, and the one
Bun 1.4.0 writes (the package named twice), each with the lock both
write, and the Bun 1.4.0 one with no lock; no lock; a lock that can't
be read (a folder in its place). The tarballs the lock's packages or
package.json name stay, the one only the lock's workspaces name goes,
and one nothing names goes; with no lock package.json alone decides,
and with an unreadable one nothing goes. With the change the TestDist
tests are ok on each Bun. Broken by hand, each put back after, with
Bun 1.4.2, 1.4.3 and 1.4.4 (outside graftcp, the proxy wrapper this
box runs commands in, umask 077, logs kept):
- 4e5b2ad8's pruneDist: the reporter's, both named-twice and the
unreadable-lock cases red on each ("<tarball> taken out");
- package.json decoded as 4e5b2ad8 did, the lock still read: the
named-twice case with no lock red on each ("<0.2.6> taken out");
- the whole lock read for tarballs instead of its packages: the
workspaces case red on each ("0.2.1 kept"), and
TestDistInstallsAPackageNPMDoesntHave red on 1.4.2 and 1.4.3
(0.1.4's tarball stays after 0.1.3 is pinned: those two leave it in
the workspaces).
- internal/plugin, -tags nogui, with Bun 1.4.4, the one magpie runs now:
ok but TestPluginSOCKSProxy, red the same at origin/main 7a60e78c
(#2207, open, filed for 1.4.3); TestFlowBigReplyProd and
TestRenewOtherHost skip by their own condition.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go build
-tags nogui ./... and GOOS=windows go build ./...: exit 0 each. go vet
and go build without the tag on linux: exit 1 (no GTK, WebKitGTK or
fontconfig headers on this box).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
(systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
45m, log kept): 64 ok, internal/plugin among them, and 8 red, none in
what this changes:
- agent TestCodexDriftReached and TestCodexBehindReverseProxy: #3398;
TestCursorFolderFromTheEditorIsNotTheCLI,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir: #3141;
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
#3641.
- davsync TestSyncTeraCloudStillSeesOtherWrites: #3420.
- edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
- gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
#3675.
- gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
this box's millions of open fds, #3649.
- provider: "fatal error: close of synctest channel from outside
bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
red, #3632; the package's tests after it didn't run.
- sessions TestAgyTitleLater: a same-size write in the same mtime
tick, 2 of 200 on main alone, #3708.
- testenv TestProgram: this box's umask 077, #3640.
Not tried: Windows, where the reporter is (CI's Windows job runs none of
these tests: it compiles them and runs a named few). package.json and
the lock are read for the forward-slash form magpie hands Bun
("./dist/<file>"), which the reporter's Bun 1.4.4 on Windows kept in
both. A tarball they name only with backslashes goes, where 4e5b2ad8 on
Windows kept one package.json named so (it read package.json through
filepath.ToSlash).
Part 2 of 2, mendDist (coffemon's second commit):
The commit before keeps the tarballs bun.lock has packages at, but a
lock behind package.json stays behind: gkd2323c's (#3622, Windows, Bun
1.4.4) had autoclaw, codearts and cloudflare-workers-ai at tarballs
pruneDist had taken, while package.json and the lock's workspaces had
moved on. Bun installs what the lock has, at every command that changes
plugins/. From that tarball, kept now, or from its own copy of it, it
put the older version back without a word; with neither, every install,
update and removal, of any plugin, failed with "ENOENT extracting
tarball from <that package>". Bun keeps its copy of a local tarball in
its install cache as @T@<16hex>@@@1 on 1.4.2 and 1.4.3, and as
@T@sha512-<32hex>@@@1, the start of the tarball's sha512, on 1.4.4, so a
Bun moved to 1.4.4 has no copy of one an older Bun made (magpie takes a
Bun release two days after it is out, bunSettle: 1.4.4, out on 10-22,
from 10-24). pruneInstallCache leaves these copies alone (no package
name before their first @). On Linux, such a lock and copies made by
1.4.2 or by 1.4.3 give an add on 1.4.4 the reporter's error, for both
packages locked at gone tarballs; the same Bun's add succeeds and puts
both back at their older versions.
Now mendDist runs before each bun command that changes plugins/ (in
runBun and install, under installMu): the packages the lock has at a
dist tarball package.json doesn't name, while package.json has them at
one plugins/dist holds, get one `bun update --ignore-scripts` of them
all, which resolves them from package.json again. It comes after
a9242eb6's mendPackageJSON, which cuts what follows package.json's
object (plugins#405): mendDist decodes package.json, and with that tail
there it would return without a mend, leaving the lock behind for the
command. A package.json that names the lock's tarball too, as Bun
1.4.0's names a package twice, isn't behind. Nothing is asked of the
registry: no package on dist has a dependency (its index.json, 42
packages, on 10-26). `bun add` of them doesn't do it on Bun 1.4.2 and
1.4.3, which keep what the lock has, and with no copy of them, an update
of one package alone fails on the others still locked at gone tarballs.
Each mend is logged with the packages it sent back, so a lock that falls
behind again, which nothing here explains, leaves a line saying when.
What it can't mend is left to the command it comes before, as before:
package.json's tarball gone too, or a package.json or bun.lock it can't
read. A lock behind package.json across npm and plugins/dist it leaves
alone, and Bun installs the lock's version (#3720). A lock with nothing
stale costs reading the two files, decoding package.json and a scan of
the lock; a tarball is looked at only where the lock and package.json
name different ones.
A lock already behind, the reporter's among them, is sent back at the
next bun command magpie runs that changes plugins/, as package.json's
tarball is in plugins/dist: pruneDist never takes one package.json
names.
What was run (tree 5ae0b4a1, on origin/main 4e5b2ad8, go1.26.8,
linux/amd64):
- TestDistLockBehindPackageJSONIsMended (new), with real Bun: autoclaw
and codearts installed from plugins/dist at 0.2.1 and 0.2.0, then at
0.2.6 and 0.2.1 (the reporter's), and the lock's packages given back
the entries Bun wrote for the first ones; with Bun's copies kept, with
them gone, with the older tarballs put back in plugins/dist, as the
commit before keeps them, and with the copies gone and plugins#405's
tail after package.json's object. From each state an unrelated
plugin's add (zcode) and then its removal succeed and leave both
packages at package.json's versions, in node_modules and alone in the
lock, and package.json's specs for both as they were; the add's prune
takes the older tarballs. With the change the TestDist tests are ok on
each Bun, and the two new ones at -count=10 on 1.4.2 and 1.4.4. Broken
by hand, each put back after, with Bun 1.4.2, 1.4.3 and 1.4.4 (outside
graftcp, the proxy wrapper this box runs commands in, umask 077, logs
kept):
- no mendDist: every case red on each, the older versions back with
the copies or the older tarballs kept (`is at "0.2.1", want 0.2.6`),
the add failing with "ENOENT extracting tarball from" both packages
with the copies gone;
- mendDist before install's add only: every case red at the removal on
each, the older versions back, or with the copies gone package.json
still naming zcode after Remove;
- one `bun update` a package: both copies-gone cases red on each, the
add failing with "ENOENT extracting tarball from" both packages, as
with no mendDist (each update alone fails on the other's gone
tarball);
- `bun add` of package.json's tarballs instead of `bun update`: every
case red on 1.4.2 and 1.4.3, ok on 1.4.4;
- the trigger as first written (the lock's tarball gone): the
tarballs-kept case red on each, the older versions back (`is at
"0.2.1", want 0.2.6`);
- mendDist before package.json's tail is cut: in install, the tail
case red on each at the add, "ENOENT extracting tarball from" both
packages; in runBun, red on each at the removal, package.json still
naming zcode after Remove.
- internal/plugin, -tags nogui, with Bun 1.4.4, the one magpie runs now:
ok but TestPluginSOCKSProxy, red the same at origin/main 7a60e78c
(#2207, open, filed for 1.4.3); TestFlowBigReplyProd and
TestRenewOtherHost skip by their own condition.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go build
-tags nogui ./... and GOOS=windows go build ./...: exit 0 each. go vet
and go build without the tag on linux: exit 1 (no GTK, WebKitGTK or
fontconfig headers on this box).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
(systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
45m, log kept): 65 ok, internal/plugin among them, and 7 red, none in
what this changes:
- agent TestCodexDriftReached: #3398; TestInstalledVersion,
TestHowInstalled, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir: #3141;
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
#3641.
- davsync TestSync and TestSyncTeraCloudStillSeesOtherWrites: #3420.
- edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
- gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
#3675.
- gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
this box's millions of open fds, #3649.
- provider: "fatal error: close of synctest channel from outside
bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
red, #3632; the package's tests after it didn't run.
- testenv TestProgram: this box's umask 077, #3640.
Not tried: Windows, where the reporter is (CI's Windows job runs none of
these tests: it compiles them and runs a named few); the reporter's own
plugins/ folder; the step that left their lock's packages at the
tarballs before while package.json and the workspaces moved on. On Linux
each Bun from 1.4.2 to 1.4.4 writes the packages at the tarball an add
names, so the test makes that state by hand.
Review (macOS arm64, go1.26.8, squashed into one commit per issue, on
origin/main 1cbdda25b), plus the class plugins#405 belongs to, a file
here written over a longer one without truncating:
- bun.lock: real Bun 1.4.4 reads the lock's first object and goes on
past bytes after it (a lock with an older lock's packages appended:
`bun install` checked 1 install, no changes, tail left as it was). So
a tail doesn't stop Bun, but pruneDist's and mendDist's regexp read
the whole file: the tail's older tarball was kept, and sent to bun
update before every command. Both now read lockHead, the first
object, braces and quotes inside strings skipped.
TestDistLockTailIsntRead (bun update run for a lock whose object is
behind, not for one whose tail is, nor one with "}\"{]" in a string)
and a TestDistTarballTheLockNamesStays case (the tail's tarball
goes). Broken by hand: lockHead returning the whole file turned the
tail case and both tail subtests red ("0.2.1 kept", "bun update run:
true"); escapes not skipped turned the braces-in-strings subtest red.
- package.json: every magpie write of it is temp+rename (mendPackageJSON
since a9242eb68) but the first one install makes, an os.WriteFile;
that goes through edit.WriteAtomic now. bun's own writes are bun's.
- TestDist* ok on Bun 1.4.2, 1.4.3 and 1.4.4; broken by hand with
1.4.4: mendDist's calls removed turned
TestDistLockBehindPackageJSONIsMended red, and the old pruneDist
turned TestDistTarballTheLockNamesStays red ("taken out").
- internal/plugin whole package ok (144s); gofmt clean; vet ok for
linux nogui, windows, darwin nogui.
Not tried: Windows, where both reports come from.
Ethereal499 and Isdavexxx on X, MasterYi on Discord, #540. The Codex app greys
Send for every model, magpie's too, while the ChatGPT account it is signed in
to is used up. Its composer's gate (ChatGPT.app 26.1013) reads authMethod
"chatgpt" plus rate limit allowed=false, and it asks account/read only when its
app-server starts. ef37b6fb7 (v0.1.1381) could fail in practice:
- (a) The reopen was macOS-only, ran once per time out, only from the GUI
process. A Windows or Linux user, a magpie without its window, or a second
time out stayed greyed.
- Switch-back: the app stayed on magpie (authMethod null, no cloud tasks or
Log out) after the reset. Nothing restarted it.
- (c) Detection lag: the account was read every 5 minutes.
- The notice sat on the Providers page, not on Codex's Agents row.
Now:
- The gateway process (`provider.KeepCodexAppOnItsProvider`, every 3s, on
every OS) ends the Codex app's own app-server each time `Agent.AppOut`
flips, both ways. The app starts another at once and reads account/read
afresh. Its window, threads and drafts stay.
- It never ends an app-server while a Codex request is in flight through
magpie or ended in the last 10s (`Server.CodexBusy`, Codex's requests only),
or while a session under the Codex home has a turn open (`codexTurnOpen`).
- It ends only the app's own app-server. That one runs on stdio; one another
program starts with `--listen` is left alone (Miyi Helper runs one on this
Mac). It must also run on magpie's Codex home (`proc.EnvOf`: ps -E on macOS,
/proc on Linux; Windows can't tell).
- The exit is clean (`proc.End`: SIGTERM, or TerminateProcess with code 0 on
Windows). The app shows any other exit as a crash.
- A listing that fails is taken up again at the next look. One that outlives
3 ends, or is denied, makes the row say to quit and reopen.
- The active account is read every minute while it is held or a window is at
90% or more (`codexLookEvery`).
- Codex's Agents row says "On magpie until <reset> · ChatGPT allowance used
up". Hovering it, or opening the row, says what is off until then (cloud
tasks, the usage meter, Log out) and that it all comes back on its own. In
en, zh, zh-TW, ja and de.
- Removed: gui's keepCodexAppSending/codexAppOut, provider's episode
bookkeeping, and the Providers-page notice.
Not changed, by design:
- A Codex own model that no magpie account serves stays as it is: magpie
can't serve that turn.
- Account discovery off and "Only switch Codex's sign-in" (login=chatgpt) are
the user's own choices, and are left alone.
Full suite green at cff1a9686 (on origin/main 6ce0f14b9), below. At
4541b3e97 (rebased on 430e3050d, which touched gateway.go, app.js and
i18n.js beside this) ran: gofmt -l, go build ./..., go vet on darwin,
linux (-tags nogui ./...) and windows; go test -run Codex ./internal/provider
./internal/agent ok; GUI codex-app-out (22 ok) and codex-app-stale (20 ok),
chromium and webkit. Pushed rebased on b92cb2f59 (two more commits,
neither in these files), built, not rerun.
Run at this commit (cff1a9686, on origin/main 6ce0f14b9), with a private
GOCACHE (another session ran go clean -cache mid-run):
- gofmt -l: clean. go build ./...: ok.
- go vet: darwin (touched packages); GOOS=linux -tags nogui ./...;
GOOS=windows (touched packages).
- go test -count=1 -timeout 45m: internal/proc, internal/provider,
internal/agent, internal/gateway, internal/gui all ok, skipping four
tests red on main without this change, each already filed:
TestUnreadLoginsWriteErrorsKeepCredentials (#3632, a synctest crash
since 091153bf) and TestFetchAsksOneListOnceForTwoBasesOfIt,
TestFetchUnionsProtocolListsWithoutChat, TestFetchAsksASharedBaseOnce
(#3854, since 6eb510f78). All three of the latter fail the same at
origin/main 6ce0f14b9 and at 353519f55 without this commit.
- GUI at cff1a9686, chromium and webkit, 231 cases ok: codex-app-out (5 languages, 980 and 440px),
i18n-keys, gui-de/ja/zh-tw, codex-app-stale, codex-accounts-via,
agent-stale-copies, agent-app-restart, agent-failover, agent-connect,
agent-layout, agent-expand-steady, agent-connected-unfolded,
agent-notice-lang and codex-signin-always.
- Windows box (cross-built test binaries): proc and provider's Codex app
tests pass. TestEndExitsClean passes there and goes red with exit code 1.
- Broken by hand, each went red:
- Codex-only busy: TestCodexBusy.
- The 90% cadence: TestCodexLookEvery.
- The retry after a failed listing: TestCodexAppServerUnknown.
- The turn guard: TestCodexAppServerRestartedEachWay.
- The --listen exclusion: TestCodexAppOwnServer.
- Code 0 on Windows: TestEndExitsClean.
- The row's notice: codex-app-out.test.cjs, 4 of 4.
- Real app: ChatGPT.app 26.1013 in a sandbox HOME/CODEX_HOME, with this
build serving on 3492/3493. Codex was put on magpie as Sync does for a held
account (model_provider = "magpie", codex.out in stash.json). OpenAI's usage
reading to the app was never faked.
- The first listing ran out at load ~200, so the timeout is now 30s. The
next look ended the app-server, and the app started another 12s later.
Its profile went from "Pro · Usage · Log out" to "magpie" with no reopen,
and /api/state carried appOut.
- Undoing it ended the app-server again, and the profile came back to Pro,
Usage and Log out.
- The owner's own ChatGPT app (its app-server on ~/.codex) was never
touched.
- One webkit codex-app-out run at load 291 had one red subtest, name lost.
It passed 3 of 3 alone and in two full webkit runs.
Not tried:
- The Windows Store app (not installed on the box), and a real Codex app
on Linux.
- A real used-up account.
- A turn running in the real app while the switch happens (unit-tested
only).
linkaww on Discord: Pi through a local magpie to a remote magpie with
masking on. The remote's masking log named the request "magpie", while
its usage already said Pi. The local magpie already sends the agent
(X-Magpie-Agent / X-Magpie-Via, passOnCaller). The remote's masking log
read agentOf, the real sender, instead of callerOf, the recorded label.
So the fix is on the remote: only the remote magpie needs this version.
There is one rule now, callerFrom/callerOf, for every place the remote
says who sent a request:
- the masking log (noteMasked)
- the requests in flight (/v1/magpie/concurrency). counted runs before
withCaller, so active.add calls callerFrom itself.
- observed calls
- Codex title / tool-loop answers (answeredHere)
- Codex search and backend records, which recorded agentOf
Usage and sessions already used callerOf. The trust rule is unchanged.
The headers are taken only from a magpie/ User-Agent and are a label
only: access, key limits and behaviour (middleware Info.Agent, models
shown, stand-ins, group rules) still go by the key and agentOf. A client
that isn't magpie is logged as itself.
Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
(562s) at bdd6a6c73, this change on 1cbdda25b
- after rebasing onto 430e3050d: go vet (darwin, GOOS=linux,
GOOS=windows, -tags nogui) ./internal/gateway, gofmt -l, and -run
'TestRemoteMagpie|TestMasked|Active|Concurrency|CodexTitle|ToolLoop':
ok
- Two sandbox magpies on 127.0.0.1:47611 (remote, masking on, a fake
upstream on :47613) and :47612 (local, a Remote magpie provider to
:47611), each under its own HOME/XDG dirs. A Pi request
(Bearer magpie-pi) carrying an API key went through the local. With
the remote on origin/main, its masking/<day>.jsonl line said
"agent":"magpie" and its usage said "pi". With the remote on this
change, both said "pi". The upstream got the key masked.
Broken by hand: masked.go back to agentOf made
TestRemoteMagpieMaskedNamesTheAgent fail ("logged as \"magpie\", want
pi"). active.go back to agentOf made TestRemoteMagpieActiveNamesTheAgent
fail (Agent:magpie).
Not tried: the GUI's Privacy page on the remote. It shows the record's
agent field, which the jsonl above has. A remote reached through a
Claude Code or Codex client User-Agent (passUserAgent): there the remote
reads that agent from its own User-Agent, as before.
aiirobyte (#3695): the gateway exited five times on 2026-10-26, and
every client was refused until it was started again. The one exit with
a stack died of "fatal error: concurrent map read and map write": two
of seenBody's goroutines in middleware.(*Run).Tried at once, one of
them in moejs's InternGoString.
A request's middleware runs in runtimes of the request's own
(serveAgent). Only one goroutine may use a runtime at a time (moejs),
and Run has no lock to hold callers to it. serve runs each try's
onProvider on them (triedOn) through the Tried the request's context
carries. For a model that can't see, magpie has each image of the
request described (seenBody), up to four at a time, and each
description is a request it makes of its own gateway on a context made
from the agent's (magpieChose(ctx)). So the descriptions carried the
agent's Tried and ran onProvider on one runtime from as many
goroutines. A model that can't search has its searches made the same
way (searchWith): a search is asked beside the agent's own stream,
which goes through the middleware's onEvent, and beside the round's
other searches, so one search is enough to share the runtime when the
middleware has onEvent. The runtime's maps were read and written from
two goroutines and the gateway died. When it didn't, the calls' values
crossed. In the runs below, hooks threw on values that weren't there
("Cannot read properties of undefined (reading 'push')", and "(reading
'messages')"), and a description went out as
{"0":0,"messages":[0,{"content":[0,{"image_url":0}],...}],...}, its
max_tokens, system prompt, text and image each turned into 0. An
earlier run of the same break (tree e1c90a00, this code with older
comments) had one image asked about twice and another never.
ownAsk takes the request's Tried off the context of those two asks, so
they go without the agent's middleware, as serveAgent's comment already
said of them ("search and vision stand-ins") and as magpie's other own
requests (titles, the classifier) go. The agent's own tries are as
before: each runs onProvider once, on its runtime. The subsystem page
now says why, and the user docs (en, zh, ja) name searches and image
descriptions among magpie's own requests.
Going without also keeps what the docs tell a hook. Its ctx.protocol,
ctx.model and ctx.stream are the agent's request's, while a
description's body is a Chat request and a search's an Anthropic one,
whatever the agent speaks. A description is also kept for later
requests (sights), so one asked through a request's middleware was
handed to later requests, other agents' too. The one community
middleware with onProvider, antigravity-cloak, rewrites Claude Code's
and Codex's lines in the system prompt, which a description's or a
search's prompt, magpie's own, doesn't have.
Not changed: the report's other fixes, a lock over the runtime, one ask
at a time, or a Run per ask. Each keeps the gateway up but still runs
the agent's middleware on asks that are magpie's own, which the docs
say go without it, and with the first two onProvider still gets bodies
its ctx doesn't describe. With ownAsk nothing else uses a request's Run
from two goroutines (holdWriter's keepalive writes under the h.mu the
handler's writes hold). magpieChose is left as it is: it says whose
pick a call is, and its other callers, Codex's thread titles,
descriptions and predictions (codex_titles.go), run before serveAgent
with no Tried to take off.
What was run (tree 4f97ac18, on origin/main 865df247, go1.26.8,
linux/amd64):
- TestImagesDescribedWithoutTheAgentsMiddleware, new: a text-only model
asked with four images, and a middleware whose onProvider adds a line
naming the provider's model. The four descriptions reach the model
that sees without the line, the text model's request has it, and
onProvider is called once, with no failure.
- TestSearchesWithoutTheAgentsMiddleware, new: a model that can't
search makes two web_search calls in one round, with a middleware that
has onProvider and onEvent. Both searches reach the searcher without
the line, the model is asked twice, its first ask with it (the second
goes on from that ask's body), and no hook failed.
- Both, without -race: -count=50 -v, 100 PASS; -count=40 three more
times, ok.
- go test -tags nogui -race -count=20 -cpu 1,2 ./internal/gateway with
this -run, ok, no race:
'WithoutTheAgentsMiddleware|TestMiddleware|TestTextOnlyModel|TestVisionSetting|TestImageThatCant|TestGroupsTextOnly|TestDescriberThatCant|TestSeerPicks|TestManyImages|TestWebSearch'
- Broken by hand, each run with -race -count=1, then without -race at
-count=40 three times:
- main's vision.go: the test red, onProvider called 5 times (each
description and the agent's try), 3 of the calls throwing "Cannot
read properties of undefined" (reading 'push' twice, 'messages'
once), the fourth description reaching the model that sees through
the middleware as the mangled body above, races reported. At
-count=40 all three runs died: of "concurrent map read and map
write" in InternGoString (intern.go:167) twice, and of "concurrent
map writes" in internASCII (intern.go:195) once.
- main's search.go: the test red, both searches through the
middleware, races reported. At -count=40 each run had 40 of 40 red,
and none died.
- ownAsk returning the context as it is: both tests red, races
reported. At -count=40 all three runs died of "concurrent map read
and map write" in InternGoString.
- A real run: magpie built at 865df247 and at this tree (go build -tags
nogui -buildvcs=false), magpie serve in a sandbox HOME, a provider (a
local server) with a text-only model and one that sees (from its
/v1/models' modalities), Settings' vision model set to the one that
sees, and a middleware added with magpie plugin add whose onProvider
adds a line. 200 requests to the text-only model on
/v1/chat/completions, four new images each, twice per build.
865df247's gateway answered 6 and died on the 7th request, of
"concurrent map read and map write" at the report's intern.go:167 in
InternGoString, reached from Run.Tried; in the other run it answered
7 and died on the 8th, of "concurrent map writes". 24 and 28
descriptions reached the vendor, all but one with the line; that
one's onProvider threw "Cannot read properties of undefined (reading
'push')", so it went as it was. This tree's answered 200 of 200 both
times, its 800 descriptions without the line and its 200 text
requests with it.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go
build -tags nogui ./... and GOOS=windows go build ./...: exit 0
each. go vet and go build without the tag on linux: exit 1 (this box
has no GTK or WebKitGTK dev packages).
- node --test site/*.test.mjs, as CI runs it (node v22.22.1): 45 pass
(none of them reads plugins.html).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
(systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
45m, log kept): 65 ok, and 7 red, none in what this changes:
- agent TestCodexDriftReached and TestCodexBehindReverseProxy: #3398;
TestCopilotFolderFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath: #3141;
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
#3641.
- edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram: this
box's umask 077, #3640.
- gateway TestPluginToldWhereTheAgentWorks, the package's only red:
this box's /tmp/.git, #3675.
- gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
this box's millions of open fds, #3649.
- pii TestFindJoinsTextsAndMapsBack, TestGPUDeathMovesToCPU,
TestServeStartsWithoutResidencyHeartbeat and TestWarm: #3741, fixed
on main by c84f859d.
- provider: "fatal error: close of synctest channel from outside
bubble", #3632; the package's tests after it didn't run.
Not tried: macOS, Windows (built and vetted only), the reporter's
middleware (the report doesn't name it), a real vision model or
searcher.
Hu9956 (#3782): with masking on, DeepSeek Harness's computer use
(cua-driver: a window's state, then a click on one of its elements) went
to the vendor with element_token values as {{SECRET_...}}, found by the
rules. cua-driver hands the model a token for each element of a window:
s, the snapshot's counter in 8 hex digits, a colon and the element's
index (s0000002a:14). The model clicks by it. The SECRET rule takes a
value of 8 or more letters and digits after a field whose name holds
"token", and element_token is one, so each token in a window's state, in
a click's arguments and in a shell command's JSON went as a placeholder
and its index ({{SECRET_...}}:74). Two of the report's places show the
token with no index ("element_token": "s00000001"), so that is taken as
it is written too.
noIDs, which lets a backend's id (a UUID, 32 hex digits or more) go as
written unless its field is named for a credential, now takes an element
token for one too (elementToken): s and 8 lowercase hex digits, then a
colon and the index, with no letter, digit or _ on either side. Without
the index, s and 8 hex digits is one only as the value of a field named
for an element: alone in a text it may be a student's number
(s12345678), which the local model may call an account. A field named
for an element is no credential's, as one named for a page, a cursor or
a request isn't (credentialField, whose field name reading is now
fieldWords). So element_token's value goes as written, while the same
value after password=, token:, "refresh_token": or "api_key": is
masked, and so is a value of any other shape in element_token. A token
the local model takes for a secret, or anything else, goes as written,
as a UUID does. The user's own words still mask one.
docs/subsystems/gateway-routing.md says so.
A UUID in a field named for an element (element_token) goes as written
now too, as one in next_page_token does.
What was run (tree bb52fa4d, on origin/main 5215108e, go1.26.8,
linux/amd64):
- TestElementTokensGoAsWritten, new. Five tokens (s00000001,
s00000003:74, s0000002a:14, s00007a3f:42, s00010001:3) in seven
places, as the report has them (JSON laid out and compact, a space
after the colon, a shell command's JSON, element_token=, inside a JSON
string, elementToken), go as written. MaskJSON of a window's state and
a click, DB_PASSWORD=hunter2abc9 beside them, masks the password
alone. The local model's every label goes as written on s0000002a:14
in a text and on s00000001 in element_token. s12345678, in a sentence
or under student_no, labelled an account number or a secret by the
model, is masked. s00000001 and s00000003:74 after password=, token:,
"refresh_token": and "api_key" are masked, and so is element_token
holding abc123def456, s0000000g1, S0000002A, s000000012, s00000001x or
s00000001:x9. The user's own word masks one.
- It and TestIDsGoAsWritten -count=50: ok. internal/redact,
internal/maskrec, internal/gwmw, internal/masking and plugins/redact:
ok.
- Broken by hand, each red in TestElementTokensGoAsWritten:
- idAround not taking an element token: every kept place, the
MaskJSON body, the model's every label on s00000001 in
element_token (the rule masks it there), and its address and secret
labels on s0000002a:14.
- "element" not among credentialField's words: every kept place, the
MaskJSON body and the model's every label on s00000001 in
element_token (the rule, again).
- the model's secret kept on a token: its secret label on both.
- s and 8 hex digits a token anywhere: s12345678's four cases.
- a token only with its index: s00000001 in its seven places and the
model's labels on it.
- A real run: magpie built at 5215108e and at this tree (go build -tags
nogui -buildvcs=false), in a sandbox HOME with masking on
(settings.json "redact": true), a local server standing in for the
vendor that keeps each body it is sent. One request on
/v1/chat/completions with the report's three places: a window's state
as compact JSON with "element_token": "s00000003:74", one laid out
with "element_token": "s00000001", a shell command's cua-driver click
with "element_token": "s0000002a", a click by s00000003:74, and a user
message with DB_PASSWORD=hunter2abc9. 5215108e: the vendor got each
token as a {{SECRET_...}} placeholder (s00000003's with its :74), four
places. This tree: each as written, the password still a placeholder.
- gofmt -l; go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit
1 (this box has no GTK or WebKitGTK dev packages).
- go test -tags nogui -count=1 -timeout 45m ./..., Bun 1.4.2 on PATH:
68 ok, and 7 red, none in what this changes: agent
TestCodexDriftReached and TestCodexBehindReverseProxy (#3398);
TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141);
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640);
gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); proc TestProbeTimeoutEndsWhatItStarted (#3848, passes 40 of
40 alone); provider's "close of synctest channel from outside bubble"
from TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so the
package's tests after it didn't run: go test ./internal/provider
-skip '^TestUnreadLoginsWriteErrorsKeepCredentials$', Bun 1.4.2 on
PATH: ok.
Not tried: DeepSeek Harness and cua-driver themselves (no macOS here);
the request was written by hand from the report's places.
Review, applied on origin/main 8e2ba36de (git am, sha256 of the patch
matches the issue's 1db65568…), with two changes to the patch:
- The patch made any field with "element" among its name's words no
credential's (credentialField) and the field an index-less token may
sit in. That widened a key-name exemption: a UUID in element_api_key or
elementSecret went as written. Now only cua-driver's own name,
element_token (elementToken, element-token), is that field
(elementField); any other name is a credential's as before.
- A token known from before (ByKnown) was still masked as a credential.
One the local model labelled in prose ("I will click s00000001 now")
was then masked in every element_token after it, a click on nothing.
An element token is no longer masked by a value known from before;
the user's own words and rules, and the password, API key and token
rules, still mask one.
Not scoped to tool calls and results by place: the exemption is held to
the token's shape (s, 8 hex digits, :index; index-less only as
element_token's value), so a value of any other shape under that key is
masked, and every route masks through redact.mask (masking.Masker's
MaskJSON and Text), so each route gets it.
What was run in review (darwin/arm64, go1.26.8, sandbox HOME):
- TestElementTokensGoAsWritten red with origin/main's ids.go (the
report's laid-out "element_token": "s00000001" went as
{{SECRET_…}}), green with this.
- Broken by hand: elementField back to "any word element": red, a UUID
and s00000001 in element_api_key and elementSecret went out; ByKnown
masking a token again: red, the click's element_token masked after
the prose turn.
- go test -tags nogui ./internal/redact/... ./internal/masking/...
./internal/maskrec/... ./internal/gwmw/... ./plugins/redact/... and
internal/gateway -run 'Redact|Mask|Masked': ok. gofmt -l: nothing;
GOOS=linux go vet -tags nogui and GOOS=windows go vet of
internal/redact: ok.
- Real run: magpie built at 8e2ba36de and at this tree, `magpie serve`
in a sandbox HOME with "redact": true, a local fake vendor recording
bodies; one /v1/chat/completions request with the report's three
places (a laid-out window state with s00000001, a compact one with
s00000003:74, a Bash call's cua-driver click with s0000002a) and
DB_PASSWORD=hunter2abc9. Base: all three tokens went as {{SECRET_…}}
(the second with its :74). This: all three as written, the password
still a placeholder.
Not run: the full suite (one suite per machine; other sessions' runs
are on this box). Not tried: DeepSeek Harness and cua-driver
themselves.
Settings › Privacy's masked words (脱敏词) were found anywhere: ABC masked
the ABC inside XABCD, and 123456 the middle of 91234567 or 0.123456. A
new row under "Masked words in any case", "Whole words only" (仅完整单词
匹配), makes each word match only where no letter, digit or _ is beside
it, and for a number no "." and digit either, so a decimal counts as one
value: ABC masks "ABC IS xxx" and name='ABC' but not XABCD or ABCDEF;
123456 masks a 123456 of its own but not 91234567, 0.123456 or 123456.78
("the code is 123456." still is). Chinese and Japanese letters count as
no letter there, since those scripts put no spaces between words: 张三
is still found in 我的同事张三今天来了, and ABC in 用ABC做. It is
independent of any case and works with it (xabc then Abc! masks only
Abc). A match inside a longer word is passed over one letter at a time,
so a whole one after it is still found. Off by default and for every
existing user: settings.json without redactWordsWhole reads false, and a
page from before it that saves without the field keeps what was set
(api.go, as redactWordsAnyCase). Each match goes as {{TERM_…}} and comes
back as written. Translated in zh, zh-TW, ja, de.
redact.Options.WordsWhole (wholeWord, wordRune); settings.RedactWordsWhole
(redactWordsWhole) reaches it through internal/masking; prefsKeep sends it
on every Settings save. docs/subsystems/gateway-routing.md has a bullet
for the user's own words, any case and whole words.
Tests, each red when its part is broken by hand:
- TestWordsWhole (internal/redact), the reporter's literal examples plus
CJK and any case: with the whole-word check skipped, 10 cases FAIL
"1 masked, want 0"; with the decimal check off, FAIL on 0.123456 and
123456.78; with Han/kana counted as letters, FAIL on 张三, 用ABC做 and
これはABCです. Every case round-trips through Restore.
- TestWordsWholeJSON: a request body and a tool call's escaped
arguments; with the check skipped, FAIL "XABCD not kept as written".
- TestCountTokensRedacted/words_whole (internal/gateway): with
masking.go not passing the setting, FAIL "redaction off changed
content: …X{{TERM_…}}D…"; words_inside holds the default unchanged.
- TestSettingsRedactWordsWholeKept (internal/gui): with the not-sent
guard removed, FAIL "…redactWordsAnyCase…: whole words false".
- redact-words-whole.test.cjs: 20 of 20 (Chromium and WebKit, en, zh,
zh-TW, ja, de, 1100 and 640px); with prefsKeep's field removed,
WebKit fails "a later save keeps it".
Run, in worktree magpie-wt/redact-wholeword at base 353519f55, sandbox HOME,
pinned caches, pipefail, tee'd:
- go test -tags nogui ./internal/redact ./internal/masking
./internal/settings ./internal/gui (TestCoreScriptBudget, i18n)
./internal/gateway ./plugins/redact: all ok.
- GUI: redact-words-whole, redact-words-any-case, i18n-keys 44/44;
gui-zh-tw, gui-ja, gui-de 9/9.
- gofmt -l clean; go vet (darwin), GOOS=linux -tags nogui and
GOOS=windows vet of the changed packages clean; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build ok.
Not run: the full go test ./... and the whole GUI suite (machine load
over 200 with other sessions' runs); the change reaches only the
packages above. Not tried: a real vendor request with the switch on;
the gateway test checks the body that goes out. A letter written as a
\u escape inside a tool call's arguments reads as no letter beside a
word (unescapedView), so it doesn't stop a match there.
Rebased onto origin/main 83368d994 (usage, signin, agent, gateway stream,
web page port, guard; app.js and gateway-routing.md touched elsewhere):
go test -tags nogui ./internal/redact ./internal/masking ./internal/gui
(budget, i18n) ok; redact-words-whole and i18n-keys 24/24.
Then onto 83368d994 (Codex thread descriptions; settings.go, app.js, i18n.js):
gofmt clean; go test ./internal/settings ./internal/masking ./internal/redact
and ./internal/gui -run 'Budget|I18n|Settings' ok.
cybercaius on Discord asked to turn Codex's thread descriptions off.
Titles and predictions had an Off; descriptions only had "as Codex
sends it" or a model.
Codex's settings on the Agents page now offer Off for "Thread
descriptions", worded as the titles' Off ("Off", "no description,
nothing sent", in zh, zh-TW, ja and de too). settings.CodexDescriptions
takes "off", /api/settings/codex-descriptions accepts it, and the
gateway answers a thread_description side turn itself through
sentNowhere, as titles' Off does: a finished response.completed with no
output, nothing sent upstream, and Routing/Usage recording it as
answered by magpie with the reason. Both routes take it (the Codex
backend path and /v1/responses).
Why an empty reply is enough: in ChatGPT.app's app.asar the
thread_description helper reads the reply's {"description"}; with no
message it records an "empty" result, not an error, and the thread's
description is left as it was.
The docs (gateway-routing.md) say each of titles and descriptions has
its own Off and neither turns off the other. No CLI change: titles' Off
isn't settable from the CLI either. docs/reference.md doesn't list
these settings.
Run:
- gofmt -l: nothing. go vet: darwin ./..., GOOS=linux -tags nogui
./..., GOOS=windows ./...: ok.
- go test -timeout 45m ./internal/gateway ./internal/gui
./internal/settings before the rebase: gui ok, settings ok; gateway
had TestDisabledCodexModels ("no space left on device") and
TestHistoryKeepsDaysAndDropsOld red during a moment the disk was
full; both pass -count=5.
- Rebased on f0ffee34c: TestCodexDescriptions/Titles/Predictions in
gateway, gui and settings ok; go vet of the three packages ok.
- Whole GUI suite (916 files, both engines, every language,
--test-concurrency=4, box at load 100 to 200 from other sessions):
13328 tests, 13144 pass, 184 fail. The 33 red files were run again
on main 508911e43: the same tests red there (quota-refresh-order
#3679, routing-* #3408#3409#3410#3411#3412#3799#1612#2658,
gateway-caller-keys #3797, menu-input-scroll #3402, key-replace
#3476, phone-web #3180, old-webkit #3403, header-centre #3479,
quota-count-wrap #3404, icon-tile #3858 new, provider-detect-draft
#3859 new, ...). The rest, run again at the rebased head: green
except s3-sync (#3413), search-first (#3795), usage-agents-hide
(#3414), usage-fold (#3415), usage-ledger, all red the same on
f0ffee34c, and library-row-remove 1 of 3 (#3099). codex-descriptions,
codex-titles, codex-predictions and i18n-keys green at the rebased
head.
Broken by hand:
- the gateway's off branch removed: gateway TestCodexDescriptionsSetting
red (magpie knows no model "off", no response.completed);
- the API's "off" check removed: gui TestCodexDescriptionsSetting red
(400);
- settings validation without "off": gui and gateway tests red (400 /
"must be a model's id ... not \"off\"");
- the picker's Off option removed: codex-descriptions.test.cjs red in
chromium and webkit, en and zh.
Not tried: a real Codex app session with descriptions Off; the app's
side is read from its minified code only.
rankyurky_80676 on Discord (macOS): PenguinHarness's desktop app
installed, and magpie didn't detect it. The app runs its own server on
the CLI's root, ~/.penguin/data, and needs no penguin command: it links
/usr/local/bin/penguin only if the user lets it (cli-install.ts). So
~/.penguin with no CLI was taken for an uninstall's leftover (cliHeld),
and an app never opened had no ~/.penguin at all.
Now "penguin" is in desktopApps, read from Prism-Shadow/penguin-harness
main (packages/desktop/electron-builder.yml, desktop 0.2.17): bundle id
com.prismshadow.penguinharness, PenguinHarness.app in /Applications or
~/Applications (or a folder one level down, or where Spotlight has it);
on Windows PenguinHarness\PenguinHarness.exe under
%LOCALAPPDATA%\Programs, or the folder registered under
8bb9acb7-2bdc-596b-9669-7b014ab1c47f: electron-builder's UUID v5 of the
appId, the same derivation giving dsh's known 1bf39983-… from
com.deepseek.dsh. penguin.go's sign is HasApp, as dsh's is, so the app
alone is detected before its first start, its version shown and no CLI
install offered. Connect then writes default_project's
.project_config.toml, which the app's server adopts without overwriting
(project-service.ts provisionInitialProject; app-identity.ts: the
release profile shares the CLI's root). Linux's deb links
/usr/bin/penguin, found as the CLI; an AppImage is anywhere and is not
looked for. A WSL twin never has the app.
Tests: TestPenguinDesktopAppDetected (app only, opened, another bundle
id, ~/Applications, the Windows exe, WSL), TestPenguinDesktopAppRegistered,
TestPenguinDesktopOnlyConnects. The Agents page is unchanged (it already
shows an app's version for dsh), so no GUI test.
Run at this head (rebased on origin/main 6ce0f14b9):
- go test ./internal/agent -count=1 -timeout 45m: ok at the previous base (616s); at this head it
started before the push, its result is in the follow-up. Targeted at this
head: go test -run 'Penguin|Dsh|DesktopApp': ok
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok
Broken by hand: without the sign, TestPenguinDesktopAppDetected (app
only: detected false, offered true) and TestPenguinDesktopOnlyConnects
red; without the desktopApps entry all three red.
Not tried: the real PenguinHarness.app (its Info.plist fixture is built
from the electron-builder config, not read from a downloaded dmg; the
disk was too full for one); Windows; the guid isn't read from a real
installer.
youyo.p on Discord (Windows, magpie 0.1.1609): Claude Code on
/v1/messages, translated to a custom provider's /v1/responses, was
canceled with 499 at ~357s and ~795s while the provider was still open.
Once the provider had begun its reply, a translated stream sent the
client something only when the provider did: the encoder's keepalive
went out on each upstream keepalive, and a provider silent mid-turn
(a long reasoning step sent whole at its end) sent nothing at all.
Now streamTranslated runs keepThroughSilence beside readSSEAlive: every
keepaliveEvery with the provider quiet, the client gets its own
protocol's keepalive through the encoder (Anthropic a ping, Responses
response.in_progress, Chat a comment, Gemini nothing), for up to
translatedQuietLongest (30 min: longer than upstreamHeaderWait's 10, long
enough for a reasoning turn sent whole), then nothing, so a provider
that never answers still ends. Writes from the reader and the ticker go
under one lock. Failover is unchanged: nothing is kept alive once a try
failed, was cut or relooped, and a held try's writes still go through
holdWriter.
Anthropic pings are spaced pingEvery (1 min) apart, comments in
between: Claude Code's 300s event watchdog takes at most 30 pings in a
row, and one ping per upstream keepalive spent them in minutes. Before
message_start the keepalive is a comment, as the SDKs' MessageStream
fails on any event before it.
Sibling: search.go's askTranslated, the other readSSEAlive caller, hands
on a KAlive from the same ticker under the same bound. The relays
(claude_subscription relay/relayEvents) keep keepaliveLongest (5 min)
and are unchanged, as is holdWriter's held comments.
Not changed: a provider that sends headers and then no byte at all is
waited out by notAnAPIReply's first-byte read under the held writer's
comments only, before any encoder exists; that path stays as it was.
A translated try held for failover (holdWriter) has two keepers: the
held writer's own comments, bounded by keepaliveLongest (5 min), and the
encoder's. Its comments bypass the encoder's writer, so for the first 5
minutes such a client can get two keepalives per keepaliveEvery. That is
harmless (comments and spaced pings) and left as is;
TestQuietKeptAliveOnlySoLong now sets both bounds and allows both
keepers' count.
Tests: TestTranslatedSilenceStillTimesOut is replaced by
TestTranslatedSilenceKeptAliveForABound (anthropic from responses,
responses from chat, chat from responses: the provider begins, then is
silent; it waits for 10 keepalives, not a duration, and checks they stop
after the bound, with room both ways). TestTranslatedStreamKeepsClientAlive
bounds pings by pingEvery; TestAnthropicKeepaliveBeforeStartIsAComment;
TestRelayKeepsClientAlive counts comments too; TestSearchQueueKeepsCodexAlive
sets the bound; TestQuietKeptAliveOnlySoLong sets both bounds
(red with the quiet bound removed). Prompts and headers sent upstream are unchanged.
Run at this head (rebased on origin/main 6ce0f14b9):
- go test ./internal/gateway -count=1 -timeout 45m: started before the push, its result is in the follow-up
(owner rule: ship a verified fix at once). Targeted at this head:
go test -race -run 'TestQuiet|Keepalive|KeepAlive|KeptAlive|TestTranslatedSilence|TestSearchQueue|TestRelay': ok
- go test -race on the keepalive tests: ok
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok
Broken by hand:
- the ticker never calling keep: the bound test red in all 3 (0, 1, 3 of 10)
- no quiet bound: red, 125/199/220 more after the first 10
- a ping on every keepalive: TestTranslatedStreamKeepsClientAlive red
(75 pings in 1.5s, want at most 20) and the encoder test red
- a ping before message_start: TestAnthropicKeepaliveBeforeStartIsAComment red
Not tried: a real Claude Code against a real silent provider, or
youyo.p's provider; Windows.
Since 1b32bdcf (v0.1.1444) the page port of `magpie web` / `serve --web`
hands the gateway's client routes to the gateway. The gateway counts a
loopback request with no forwarding header as an agent on this computer,
which needs no key. A request reaching the page port over loopback without
such a header was answered that way, so the page port gave the gateway's
routes without a gateway key, with sharing off. Before 1b32bdcf every
request there needed the page's key.
Now every request the page port hands over is marked
(gateway.FromPagePort, the X-Magpie-Page-Port header) and local() is false
for it: answered only while magpie is shared (or on the network), with an
enabled gateway key, from loopback too, under any Host or browser marks,
and with MAGPIE_TRUST_PROXY set. While not shared lanGuard refuses it 403,
saying to use the gateway's own address. lanGuard moves the mark into the
request's context and drops the header, so it never goes upstream.
toGateway (another magpie serves the gateway) passes the mark on and adds
the loopback peer as X-Forwarded-For when no forwarding header came, so an
older gateway that doesn't know the mark still asks for a key. Agents on
this computer keep the gateway's own port (3425), key-free from loopback as
before. The page itself calls no client route (checked app.js and
plugins.js: the /mcp and /v1 addresses there are copied, not fetched), so
nothing in the GUI needs a key on the page port. The routes covered are
all of gateway.ClientPath (/v1, /v1beta, the routes without /v1, the Codex
backend path, the search path, /mcp), since the mark is set in onePort for
each of them.
docs/reference.md's one-port paragraph, gui-shell.md and
gateway-routing.md now say the page port answers these routes as from
another machine and that agents here use the gateway's port; the old text
said a same-machine proxy's requests carry forwarding headers, which a
forward that adds none doesn't.
Tests:
- TestWebOnePortServedHere / ServedElsewhere: a loopback request with no
key and no forwarding header to /v1/chat/completions, /chat/completions,
/v1/responses, /v1/messages, /v1/models, /v1beta/models, /mcp/github,
/mcp/magpie/web-search and the Codex backend, under Host 127.0.0.1:3430,
127.0.0.1, localhost:3430 and a public name, with a browser's marks, a
CLI's user agent and an IPv6 loopback peer: 403 not shared, 401 shared.
Red on the old code (404 "knows no model" / "isn't signed in to an MCP
server": the handlers were reached). The old "for an agent here" 200 is
now 401; loopback with a gateway key 200. Origin null, foreign Origin
and rebound Host without a key now 401 (lanGuard asks the key first);
a foreign Origin with a key still 403. A 429 from the process's
failed-key bucket counts as the 401 it replaces.
- TestWebOnePortAgentsHereUseTheGatewayPort: the gateway's own Front from
loopback without a key 200; the page port 403 with the reason and the
gateway's URL; MAGPIE_TRUST_PROXY=1 doesn't make it local.
- TestPagePortMarkIsNeverLocal (gateway): marked requests never local
under MAGPIE_TRUST_PROXY; refused unshared; with a key the handler sees
no header and local false.
Broken by hand, each red, then restored:
- onePort not marking: ServedHere and AgentsHere red; ServedElsewhere
stays green on the X-Forwarded-For fallback alone (the older-gateway
path).
- local() ignoring the mark: ServedHere, AgentsHere, PagePortMark red.
- lanGuard not taking the header off: PagePortMark red (handler saw it).
Real try (built binaries, sandbox HOME, MAGPIE_NO_ACCOUNTS=1,
MAGPIE_TEST_SANDBOX; gateway 127.0.0.1:3561, page 3562, a raw TCP
forwarder (a Go listen/dial/copy loop, as socat would be) on 3563 -> 3562,
a fake OpenAI-compatible upstream on 3564 added as a provider):
- `serve --web` (gateway in process), origin/main c37bcdbfc binary: through
the forward with no key, chat 200 (upstream called), /v1/models 200,
/v1/responses and /v1/messages reached the provider, /mcp/magpie/web-search
with Host 127.0.0.1 200; the page's /api/settings 401. 5 upstream calls.
This change: every one of those 403 with the page-port reason; the
gateway port's agent chat 200; 1 upstream call (the agent's).
- `serve` plus a separate `magpie web` (served elsewhere): old binary 200
for chat and MCP through the forward, shared or not, with no key or the
page's cookie only. This change: 403 not shared; shared, 401 with no key
and with the page's cookie only, 200 with a gateway key; the page signs
in through the forward and /api/settings is 200 with its cookie; the
upstream request carries no X-Magpie-Page-Port.
Run at this head (rebased on origin/main f0ffee34c):
- go test ./internal/gui ./internal/gateway -run 'TestWebOnePort|TestClientPath|TestWebAssets|TestPagePortMark|TestAllowList|TestLAN|TestRebound|TestProxied' -count=1: ok
- gofmt -l internal/gateway internal/gui: empty; go vet (darwin),
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet -tags nogui
./... (before the rebase), GOOS=linux/windows go vet of gateway, gui and
cli at this head: ok
- The full suite (go test -tags nogui -count=1 -timeout 45m ./..., one per
machine, waiting behind another session's run) was not run before this
push: a security fix ships at once. It runs at this head next; any red it
names gets its own commit.
Not tried: Windows and Linux beyond vet; nginx (its XFF path is unchanged
and covered by the "through a proxy" cases); a real vendor account; the
GUI suite (no GUI asset changed).
yyhhyyyyyy on X asked for CoreML. internal/pii/guard now runs the
encoder (everything after the embeddings) as a CoreML program on a Mac
with macOS 13 or later, on the Neural Engine or GPU (MLComputeUnitsAll).
bert.go still does the embeddings and stays the path everywhere else.
- coreml_gen.py builds the program with coremltools' MIL builder from
the pinned int8 model: the int8 weights dequantized, float16 compute.
The repo keeps only the graph (coreml.mlmodel, 112KB) and coreml.json
(each blob's offset, weight.bin's size and sha256). On each Mac the
weights are written from the model already downloaded (coremlWeights,
float16 rounded to nearest even as numpy does), checked against that
sha256, compiled once into <model dir>/coreml/<sha>.mlmodelc (about 5s,
41MB), and opened from there after that (40-170ms). Nothing new is
downloaded or hosted.
- The cgo lives in internal/pii/guard/coreml, because guard has Go
assembly. Without cgo or off darwin it is a stub (Available false).
- A window under 16 tokens (coremlMin) stays on the CPU, which is faster
there (8 tokens: 8.7ms CPU, 12.5ms CoreML; 16: 17 vs 13). A Mac before
macOS 13, a failed write, compile or open, or a failed run goes to the
CPU too. Model.MLErr keeps why.
Accuracy against the publisher's fp32 ONNX (onnxruntime): CoreML's
probabilities are within .067, the CPU's within .129, and both agree
with fp32's labels on the same tokens. The CPU quantizes activations as
the int8 model does and CoreML doesn't; fake quantization in the program
was tried and didn't match the CPU (.75 on CPU fp32, .70 on GPU,
unstable in fp16), so it was dropped. A span near the threshold can fall
the other side: TestModelFinds' go.mod module path is a common_secret at
.814 on CoreML, .788 on the CPU and .785 in fp32, so on a Mac it is
masked at the default 0.8. TestModelFinds now tests bert.go alone
(m.ml = nil), and TestCoreMLMatchesGo holds CoreML to it.
Run (M4 Pro, macOS 26.2, under load ~50):
- gofmt -l internal/pii: clean. go vet ./internal/pii/... with GOOS
darwin, linux, windows and CGO_ENABLED=0: clean.
- MAGPIE_GUARD_DIR=<pinned model> go test ./internal/pii/...
./internal/redact/... ./internal/masking/... -count=1: ok. In guard:
TestHalfRounds, TestCoreMLWeights (weight.bin's sha256),
TestCoreMLMatchesGo (99%+ argmax agreement on a 512-token window, the
same spans as the CPU with scores within .2; loaded in 6.3s cold,
17ms for 512 tokens), TestCoreMLFailureFallsBack and TestModelFinds.
- TestMaskEval/astrlink-guard replayed with outputs recorded through
CoreML: the same verdicts at the default threshold; scores moved a
little and one account_number span at .508 is new, under 0.8.
eval-astrlink.json stays the CPU's recording.
Broken by hand: half() rounding ties up instead of to even turns
TestHalfRounds red; a wrong sha256 in coreml.json makes Load fall back to
the CPU with MLErr set, find the same spans and leave the compiled
program in place (TestCoreMLFailureFallsBack).
Not tried: an Intel Mac, macOS 13 or 14 (only 26.2), the real app's GUI
with Find with a local model on (the gateway path calls the same Find).
ctopsc's custom provider points at a self-hosted sub2api (Responses). Its
plain /v1/models gives id, display_name, owner and created alone; asked
with Codex's client_version it answers Codex's own catalog shape per model
(window, max window, levels, base_instructions, tools, truncation, tiers).
magpie read the plain list and made Codex's entries up from models.dev, so
GPT-6.1 Terra went to Codex at 922000 where the relay said 272000.
What changed:
- catalog: a list row in Codex's shape (slug, supported_reasoning_levels,
shell_type, base_instructions: CodexEntry) is kept whole on the Model
(Codex), its window, max window and input modalities read off it.
- provider: for a provider the user added by its address (no preset, no
account) whose Responses list has no such row, fetchOne asks the same
URL once more with client_version (codexEntries). Only where the list is
fetched (add, key change, Refresh), never per Codex poll. The answer only
adds entries to models the plain list has. One that fails or can't be
read keeps the last list's entries (a failed read is unknown); one that
answers plainly says there are none. The entry's levels become the
model's levels, and withUltra adds none to it.
- codexcat: listedEntry hands Codex the relay's entry as given,
base_instructions included and unchanged, with magpie's slug, name,
priority and " via magpie" description. The user's window, compaction,
levels and image setting still win (levels keep the relay's
descriptions). A model without one is made as before.
- agent: Codex's magpie-models.json gets the same entries.
- docs: providers-accounts.md, "A relay's Codex entries".
Run at this head (sandbox HOME, pinned caches):
- go test -tags nogui -count=1 ./internal/catalog ./internal/codexcat
./internal/provider ./internal/agent ./internal/gateway before the
rebase onto 508911e43: catalog, codexcat, agent and gateway ok;
provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials with
"close of synctest channel from outside bubble" in filememo.Forget,
which is #3632 (open, not this change).
- After the rebase onto 508911e43 (it changed internal/agent): catalog,
codexcat ok; agent whole, with TestWSLMoreAgentsPick, TestZooCode and
TestZooCodeFresh red on "no space left on device" (the machine's disk
was full), then those three and -run Codex ok; provider -run Codex ok;
gateway -run Codex ok (its first link failed on the full disk).
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
./... and GOOS=windows go vet ./... clean.
- Not run: the full go test ./...; it was started and stopped when the
disk filled (under 1GB free), and is to be run after the push.
Broken by hand, TestCodexListedEntry red each time (restored after):
- no client_version ask: "asked with client_version 0 times on one
fetch, want 1";
- listedEntry turned off: service_tiers, levels, model_messages,
shell_type ("unified_exec"), base_instructions (magpie's "You are
Codex, based on GPT-5…"), max_context_window and more differ;
- a failed read taken as none: the keeps-last subtest red (truncation
limit 10000 vs the relay's 12000, shell_type unified_exec);
- the user's levels ignored: all four levels and default "medium".
Not tried: a real sub2api or ctopsc's literal reply (the fixture follows
codex-rs ModelInfo, with values magpie never writes); a Codex binary
reading the list; /backend-api/codex/models directly (same
codexcat.Entries as /v1/codex/models, which the test reads). Not changed:
a user-set models URL is not asked again with client_version, and a
model on a dead side loses its entry with it. A list saved before this
gets the relay's entries at its next Refresh, not by itself.
What changed: CodexNativePicked narrows the backend's own list to none of
the account's visible models when the codex provider is Usage only
(noModels, ServesNone), before the empty-picks fallback that left the list
whole. codexModels' existing filter then drops them from
/backend-api/codex/models; the hidden entries Codex runs jobs of its own on
(codex-auto-review, gpt-reserve) and other providers' models stay. A
provider switched off keeps the native list as before.
Ported from skygunner's a016fcee (on ggbdpq's diagnosis and proposed
ServesNone fix in #2530), with its test TestCodexUsageOnlyCatalog. Two
siblings that read the same narrowing were missing it, for picks too:
- spawnChoices (spawn_agent's list of the account's models, from
models_cache.json) used Hidden and Unlisted but not the picks, so it
still named every native model;
- buildCodexListTag (the list's ETag and each reply's X-Models-Etag) had
no mark of the picks, so a running Codex never asked for the list again
after Usage only or a new pick; it now carries ~picked and each slug.
The test covers both, and the docs row (providers-accounts.md Model picks)
says so. Not changed: codexNativeOff, so a request Codex still sends for a
native model is served as it is for an unpicked one today.
Run at this head (sandbox HOME, pinned caches):
- go test -tags nogui -count=1 ./internal/catalog ./internal/codexcat
./internal/provider ./internal/agent ./internal/gateway before the
rebase onto 508911e43: catalog, codexcat, agent and gateway ok;
provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials with
"close of synctest channel from outside bubble" in filememo.Forget,
which is #3632 (open, not this change).
- After the rebase onto 508911e43 (it changed internal/agent): catalog,
codexcat ok; agent whole, with TestWSLMoreAgentsPick, TestZooCode and
TestZooCodeFresh red on "no space left on device" (the machine's disk
was full), then those three and -run Codex ok; provider -run Codex ok;
gateway -run Codex ok (its first link failed on the full disk).
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
./... and GOOS=windows go vet ./... clean.
- Not run: the full go test ./...; it was started and stopped when the
disk filled (under 1GB free), and is to be run after the push.
Broken by hand, TestCodexUsageOnlyCatalog red each time:
- ServesNone narrowing removed: usage_only "models = [codex-auto-review
fake/m1 gpt-5.5 gpt-6-sol gpt-reserve], want [codex-auto-review fake/m1
gpt-reserve]";
- picks left out of the tag: "ETag kept across Usage only" (all four
ETags +magpie-68fdb6e54074);
- picks left out of spawnChoices: usage_only "spawn_agent offers the
account's [gpt-6-sol gpt-5.5], want []", picked_again "[gpt-6-sol
gpt-5.5], want [gpt-6-sol]".
Not tried: a real ChatGPT account with Codex Desktop refreshing its list;
the backend reply is a synthetic catalog of the reported visible/hidden
shape.
Refs #2530 (left open for the reporter)
Co-authored-by: vincent <webmaster@palmit.com.au>
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
ninja_s6114 runs magpie in Docker and put the web UI on an iPhone's home
screen; it opened with Safari's address and bookmarks bars. Now it opens
standalone, with no setup:
- index.html links manifest.json (display standalone, name magpie, start_url
and scope "./", 180 and 512 px icons) and an apple-touch-icon, and sets
apple-mobile-web-app-capable, mobile-web-app-capable, the title and status
bar style "default". theme-color is set only under (display-mode:
standalone), light #f4f4f6 and dark #1a1a1e, so a browser tab and the
Wails windows look as before.
- webGuard serves exactly /manifest.json, /icons/apple-touch-icon.png and
/icons/icon-512.png on GET/HEAD without the key, since a home screen may
fetch them without the page's cookie. Everything else still needs it.
- The header's safe-area padding already in app.css (body.web .top) keeps it
out from under the status bar and notch; app.css is unchanged.
Run, at this head (rebased on origin/main):
- go test ./internal/gui: ok, except TestRestartHandsTheGatewayOver, the
handover EOF under load (#3451); it and TestWebAppAddsToHomeScreen pass
3 of 3 alone.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui, and
GOOS=windows: ok; go build ok.
- GUI web-app-standalone + i18n-keys: chromium 8/8, webkit 6/6 (the
standalone cases are Chromium only, as WebKit can't emulate
display-mode standalone; they run under --app with iPhone 13 safe-area
insets 47/34 and touch, portrait and landscape, light and dark).
- Before the rebase, 34 GUI files picked for strict fixtures/assert.fail on
unexpected requests, plus menu-scroll, phone-web, mobile-web, web-page,
old-webkit, usage-ledger and i18n-keys, in both engines: 563 of 576 pass.
The reds fail the same on an origin/main copy and are filed:
old-webkit Safari 15 (#3403), phone-web flick under load (#3180),
gateway-key-models webkit under load (#2648), usage-ledger
return-to-live (#3104). provider-detect-draft timed out under load and
passes 20/20 alone.
Broken by hand:
- the guard exemption removed: the Go test fails with 401 on the manifest
and the icon;
- the old index.html: the Go test fails on the missing tags, and the GUI
test fails in WebKit too;
- theme-color media without display-mode: the GUI test fails in both
engines;
- app.css's body.web .top safe-area padding removed: the standalone test
fails, ".top .brand under the status bar: 8".
Not tried: a real iPhone or Android device and a real install; the whole
GUI suite (the machine is loaded and nearly out of disk; run afterwards).
iOS keeps the display mode it saw when the icon was added, so a user
removes the old icon and adds it again. A home-screen app on iOS may not
share Safari's cookie, so it can ask for the key once; MAGPIE_WEB_KEY keeps
the key the same across restarts. iOS 27's top blur over the header is
#3515, not changed here.
Yayoi_no_yume on X asked for the privacy model's threshold to be
adjustable: they read it as fixed at 0.5, and from their own use find
0.85-0.95 right for AstrLink. The 0.5 is Privacy Filter's (pf-serve's
argv default); AstrLink Guard already masked at its publisher's 0.8.
Both models now find at a floor of 0.5 (pii.Floor) and give each span
its score: Guard's least token probability (rounded through float32,
so a span read back from the cache file sits on the same side of a
threshold), pf-serve's own. masking.model keeps the spans at
pii.Threshold or over: settings.RedactModelScore[model] when it is in
[0.5, 1), else the model's MinScore (Privacy Filter 0.5, AstrLink
Guard 0.8). Settings -> Privacy shows a Confidence threshold row under
the model (app menu, 0.5 to 0.95 and Default), /api/privacy-model
takes do:"score". The setting is this computer's own, like the model.
The defaults stay. TestMaskEval's cases, rules + model + magpie's
checks, by threshold:
Privacy Filter 0.5-0.8 masked 41/42 kept 112/113
Privacy Filter 0.85-0.95 masked 40/42 (a Chinese name lost)
AstrLink Guard 0.5-0.7 masked 42/42 kept 112/113
AstrLink Guard 0.8-0.85 masked 41/42 (a phone in a tool result)
AstrLink Guard 0.9 masked 40/42
AstrLink Guard 0.95 masked 40/42 kept 113/113
The model alone does raise fewer false alarms higher up (Privacy
Filter's found-in-keep falls from 47 at 0.5 to 27 at 0.95, Guard's
from 8 to 2), but the checks after it drop most of those already, so
a higher threshold mostly costs values that should be masked.
Cache file: found-<model>.bin is now "pfound02" with a float32 score
per span. A "pfound01" file is still read, each span with score 1, so
texts cached before mask as they did and aren't asked again. For those
texts a higher threshold drops nothing and a lower one doesn't add a
Guard span scored 0.5-0.8 until the cache turns over (20000 answers).
merge() keeps the surer score of spans it joins. The eval recordings
(eval-model.json, eval-astrlink.json) were made again with scores,
from a scratch cache, the live found files untouched.
Run in the worktree at 11dcc743f + this change:
- go vet / gofmt -l on the touched packages: clean
- go test -count=1 -timeout 45m ./internal/pii/... ./internal/masking
./internal/redact ./internal/settings ./internal/gui ./internal/gateway: all ok (gateway 546s, rerun
after an earlier run hit "no space left on device" on this machine;
every failure in that run was a TempDir mkdir). This run caught
TestSettingsSaveKeepsWhatItDoesNotSend wanting RedactModelScore set;
it is now
- GUI: privacy-model.test.cjs 64/64 (chromium + webkit, 5 languages,
1100 and 640px; the new threshold menu test among them),
i18n-keys 4/4, redact-kinds, redact-rule-edit,
redact-rule-row, redact-shape, redact-words-any-case all pass.
masking-records 82/82, routing-masking 10/10, privacy-usage-stats 4/4,
mask-actions 22/22. privacy-hides-accounts was 3/4 once (webkit en,
page.goto's 5s at load ~290, the class of #3525, commented there),
then 4/4 three times. Not run: the rest of the GUI suite.
Rebased on 508911e43 (which touched internal/pii fetch and mirror): at
that head, go build ./..., Linux and Windows go vet of pii, masking,
settings and redact, gofmt -l, and go test of pii/..., masking, redact,
settings and gui all ok; gateway not run again after the rebase.
Broken by hand: masking.model keeping every span (TestModelThreshold
red); Threshold taking any value (TestModelThreshold red); the cache
writing 1 for every score (TestRestartReadsWhatWasFound red); merge
not keeping the surer score (TestMergeAcrossPieces red, after its
joined span was made surer than the one it joins).
Not tried: the real app's window, Windows, Privacy Filter on a GPU
with the new score read (pf-serve itself is unchanged; it always sent
the score).
noahhrreion runs magpie in Docker and sets the gateway's address with
MAGPIE_PUBLIC_URL; the address at the foot of the page didn't show it.
Since #1551 a page other machines open (magpie web) shows
MAGPIE_PUBLIC_URL, while they are let in, as the gateway's address on the
Gateway page, starts Connect and its snippets at it, and uses it for
Settings' MCP addresses. Two places still said the container's loopback:
- the sidebar's gateway line (renderSideGw): it drew providers' and
boot.js's `url` only. It now draws `publicURL` in magpie web, and
boot.js's `sideGateway` carries it (same rule as settingsState: shared,
or MAGPIE_ADDR on the network, as the image's 0.0.0.0 is)
- Settings › About's Gateway URL: in magpie web it is the public URL,
and the separate Public address row, then the same, is left out
In the app on this computer both stay the local address that agents here
are pointed at, as before. The address list in Share on local network
already gives MAGPIE_PUBLIC_URL alone, and Connect and the copy buttons
were already at it.
Run (worktree at origin/main 11dcc743f + this, darwin/arm64, load ~150):
- go test -count=1 ./internal/gui/: ok (TestBootSaysWhereItsGatewayListens
now checks publicURL is in sideGateway on the network and absent on
loopback; the script budget tests pass, not raised)
- gofmt -l clean; go vet darwin and windows on internal/gui. The linux vet
of internal/gui doesn't build Wails without cgo on this Mac, in Wails
itself, as on main
- public-url-default.test.cjs, Chromium and WebKit, en zh zh-TW ja de,
1100 and 420 wide: 26 pass
- the 18 GUI files on the changed caller-keys fixture plus sidebar,
gateway-port, i18n-keys, settings-general, settings-sections and
settings-search, 3 wide: 322 pass, 4 fail. Rerun 1 wide, 3 passed and
gateway-caller-keys webkit stayed red at line 137; it is red 4 of 5
on 11dcc743f without this change too, #3797. gateway-key-models webkit
(#2648) and gateway-own-key zh 440 (#3842, filed now) passed alone.
Broken by hand:
- renderSideGw back on g.url: public-url-default's magpie web test red
at 1100 wide
- About back on s.gateway: red at both widths
- boot.js without publicURL: TestBootSaysWhereItsGatewayListens red
Not tried: a real Docker container with MAGPIE_PUBLIC_URL; the page was
driven with a faked API. Not asked of the reporter yet: whether they open
magpie web, or the desktop app, which keeps the local address.
hh0592821 (China) couldn't download the local masking model: "EOF",
"x509: certificate is valid for *.facebook.com ... not huggingface.co",
"net/http: TLS handshake timeout", while the same file came through
their proxy outside magpie.
Cause: internal/pii's download client cloned http.DefaultTransport when
the package loaded, before netproxy.Install set its Proxy, so it kept
only ProxyFromEnvironment. An app started from the Dock has no
HTTPS_PROXY, so the proxy set in magpie and the system's were both
skipped, and the request went direct to a poisoned huggingface.co. Every
other client magpie builds (update, mcp_check, mcpauth, gateway/mcp)
sets t.Proxy = netproxy.Func; pii was the only one built at init without
it. And hf-mirror was asked only with the 「国内镜像」 switch on.
Fix:
- pii's client: t.Proxy = netproxy.Func, through netproxy.Dispatch,
ResponseHeaderTimeout kept.
- source.URLs: a masking model's file (the two pinned repos' /resolve/
paths, https, no query; modelMirror) has hf-mirror after
huggingface.co with the switch off and no MAGPIE_MIRRORS; with the
switch on it stays first, once. fetch still checks each file against
its pinned sha256, so a mirror can't hand over anything else.
- docs/subsystems/gateway-routing.md says both.
Checked against the real mirror (curl, outside the tests): hf-mirror.com
serves AstrLink Guard's three files at 7216b6a3 with their pinned sizes
and sha256 (model_int8.onnx 330781 0a070d31..., model_int8.onnx_data
37124608 0ba34216..., tokenizer.json 1502881 0cf3b235...). For Privacy
Filter's gguf it answers 308 back to huggingface.co, so the mirror
helps AstrLink Guard (the default) only.
Tests, none reaching the network: TestFetchGoesThroughMagpiesProxy (proxy
set in Settings is an httptest server; a fetch of a TEST-NET-1 URL is
answered by it), TestModelFromTheMirrorWhenHuggingFaceFails (huggingface.co
failing with the reporter's certificate error, a handshake timeout and
EOF: the file comes from hf-mirror; a mirror file that isn't the pinned
one fails the checksum), TestModelMirrorWithoutTheSwitch,
TestModelFallsToTheMirror (source).
Broken by hand, each red then restored: without t.Proxy =
netproxy.Func, TestFetchGoesThroughMagpiesProxy is red (context deadline,
direct dial); with modelMirror out of URLs, the three mirror tests are
red.
Run: the full suite (go test -tags nogui -timeout 45m ./..., sandbox
HOME) at 7065e3734, this change on the zoecats commit on 11dcc743f,
while the disk was full (1 GB free, other sessions' runs and a 57 GB
shared Go cache): internal/pii 134s, internal/source and 69 more
packages ok; agent, gateway and library red only on "no space left on
device" (TempDir and file writes); provider on the synctest crash open
as #3632. Rerun at that head: internal/pii, internal/source and
internal/netproxy ok, and the gateway's 429/patience tests ok.
The previous commit's full run at its base had every package ok but
provider (#3632).
gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... clean; go build for darwin, linux (nogui) and
windows ok.
Not tried: a download from China through a real poisoned DNS, or with
the reporter's proxy; ModelScope for Privacy Filter's gguf.
zoecats's LAN aggregator answered 429 "Usage has exceeded the frequency
limit. We will switch you to another model. Your usage limit for the
original model will reset in 1 minutes." magpie handed it straight to the
agent. Its words matched plannedWords/usedUpWords ("usage limit",
"exceeded ... limit"), so failure() called it failQuota and busy() was
false: no wait, no retry, and the provider rested as a used-up plan.
Fix, no setting:
- failure(): a 429 that says it is back within soonest (PatienceLongest,
240s) and isn't about money (creditWords) is failRate, whatever plan
words it has besides (backSoon/backIn). One back in hours stays
failQuota; "insufficient balance ... try again in 30 seconds" stays
failCredit.
- rateWords takes "frequency limit"; resetsAfter also reads seconds and
N 秒/分钟后 (soonWords), so restAfter rests about what it says.
- replan: a vendor's time is read in whole seconds, so a member back
within one second past its budget is asked as the budget ends, and the
budget check is inclusive. Without it the reporter's own minute
(Retry-After 60 from keepRetry) landed a hair past a lone provider's
default 60s patience and was dropped.
- docs/subsystems/gateway-routing.md says both.
Tests (internal/gateway/frequency_limit_test.go, the reporter's literal
body): TestShortResetIsARateLimit (rate for the literal body, seconds,
Chinese; quota for hours, Cline's 23h 59m, a bare usage limit and the
billing quota; credit for money; a 403 is not rate),
TestShortResetRestsWhatItSays (rests ~1 min as failRate),
TestReporterResetFitsTheDefaultPatience (Retry-After 60, replan keeps it
with singlePatience; 1.5s or 1h past the budget is dropped),
TestSingleProviderWaitsOutAFrequencyLimit (end to end through the
gateway: 429 then 200, asked twice, after its 2s). single_busy_test's
TestSingleProviderPassesALongLimitThrough gets a "reset in 5 hours" case
that still goes straight to the agent.
Broken by hand, each red then restored: the backSoon case off (three of
the new tests red); the replan clamp off
(TestReporterResetFitsTheDefaultPatience red, "replan [] 0s false");
soonWritten out of resetsAfter (the seconds/Chinese cases and the end to
end test red).
Run: the full suite (go test -tags nogui -timeout 45m ./..., sandbox
HOME) at 8d55158fc, this change on 6a6c06868: every package ok,
internal/gateway 755s and internal/agent 598s among them, except
internal/provider, which crashed on "close of synctest channel from
outside bubble" in filememo.Forget, open as #3632 and untouched here.
Rebased on 11dcc743f (one sessions commit). At the pushed head, stacked
with the next commit (7065e3734 before these bodies), the full suite ran
again while the disk was full (1 GB free, other sessions' runs and a
57 GB shared Go cache): pii, source and 68 more packages ok; agent,
gateway and library red only on "no space left on device"; provider on
#3632. So I reran internal/gateway at that head with -run
'FrequencyLimit|ShortReset|ReporterReset|SingleProvider|Patience|Busy|Replan|Rest|Quota|Rate|Credit|Failure': ok 58s.
gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... clean; go build for darwin, linux (nogui) and
windows ok.
Not tried: the reporter's real aggregator; a Retry-After header alone on
a quota-worded 429 still doesn't make it a rate limit (only its words
do).
The first `codex --yolo` in a terminal had macOS say magpie wanted files
in the Desktop folder. magpie keeps Codex's managed app-server daemon
current (KeepCodexDaemonCurrent restarts it with `codex app-server daemon
restart` when no session is attached). On macOS a process is the TCC
"responsible process" of whoever started it, so the daemon that restart
leaves running answered to magpie. Every codex run in a terminal attaches
to that daemon, which works in the run's folder, so ~/Desktop was asked
for under magpie's name.
proc.CombinedOutputOwn runs a command through posix_spawn with
responsibility_spawnattrs_setdisclaim (looked up with dlsym, as it has no
header), so the command and what it leaves running answer for themselves.
Only stdio is passed on, stdin is /dev/null, signals are reset, and the
context's end kills it as CommandContext would. restartCodexDaemon uses it.
Elsewhere, and in a build without cgo (the CLI), it is cmd.CombinedOutput.
Run (darwin/arm64, Go 1.26.8, at f51ab771f + this):
- go test -count=1 ./internal/proc/: ok (TestCombinedOutputOwnAnswersForItself,
TestCombinedOutputOwnRuns, TestCombinedOutputOwnContext)
- go test -count=1 ./internal/provider/: ok with
-skip TestUnreadLoginsWriteErrorsKeepCredentials; that test crashes with
"close of synctest channel from outside bubble" in filememo.Forget on
main too, which is #3632 (open, a patch is under review there)
- gofmt -l clean; go vet for darwin, linux and windows on proc and provider;
CGO_ENABLED=0 -tags nogui build, the GUI build, linux nogui and windows
builds
Broken by hand:
- the disclaim call turned off: TestCombinedOutputOwnAnswersForItself red
("the sleep answers to 2201, this process to 2201")
- restartCodexDaemon back on cmd.CombinedOutput:
TestRestartedCodexDaemonIsNotMagpies red ("the daemon answers to 2201,
magpie to 2201")
Not tried: a real TCC prompt (the tests check the responsible pid macOS
reports, which is what the prompt names; it can't be shown in a sandbox).
The CLI build, without cgo, still starts the daemon as its own child; it
is the GUI that keeps the daemon current for most users.
iebb on Discord (10-27): his account has Claude Mythos 5.1, magpie
doesn't list it. models.dev took the gated Mythos 5.1 out of
anthropic's provider list (models.dev #11327) and kept only its lab
file, models/anthropic/claude-mythos-5-1.toml (#11328).
Cause. magpie read only models.dev's api.json (providers -> models).
The Claude subscription's list was exactly catalog.Provider("anthropic"),
so Mythos 5.1 left it with that PR. And a vendor list that still
returns it (an Anthropic key's /v1/models) got no window, reply limit,
name or thinking for it, since nothing read the lab catalog.
Fix.
- catalog: Sync also keeps models.dev's lab catalog (models.json) as
labs.json beside the cache, through temp+rename; a failed fetch
keeps the last one, and a cache without it is Stale once a process.
A model only a lab lists votes into the same tables as a listed one
(ContextOf, OutputOf, NameOf, Thinks, SeesImages); a model a
provider lists keeps what providers say. A thinking lab-only model
with no levels takes those of the newest of its family a provider
gives (labKinEfforts: Mythos 5.1 takes Mythos 5's). catalog.Describe
builds a Model from an id for lists that name ids alone.
- provider: the Claude account's list is models.dev's anthropic list
plus what Anthropic told the account's Claude Code beyond it, read
from .claude.json's additionalModelOptionsCache / modelAccessCache /
additionalModelCostsCache (Claude Code's own sign-in and each saved
account's directory). Account.Lists honours modelAccessCache's
entitled per account, ListPrice falls back to Anthropic's price
from additionalModelCostsCache, and the agent's own Claude Code
picker (claudeOwn) offers the signed-in account's extras. WSL keeps
the catalog list. magpie still asks Anthropic nothing with a Claude
sign-in; nothing is sent differently, no Claude Code mimicry change.
- docs/subsystems/providers-accounts.md: two rows, the lab catalog
and a Claude account's models.
Testdata: models.dev's api.json and models.json as served on 10-27,
cut to the anthropic and azure providers' Claude models and the
anthropic lab. Tests never reach the network.
Run:
- TestLabOnlyModelIsKnown, TestLabsLeaveListedModels, TestSyncKeepsLabs,
TestClaudeAccountListsGatedModels, TestAnthropicKeyGatedModelDescribed:
pass.
- go test -count=1 -timeout 45m ./internal/catalog/ ./internal/provider/
./internal/agent/ ./internal/gateway/ at 2e165fe9d + this change:
catalog, agent (362s), gateway (557s) ok; provider crashed in
TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
channel from outside bubble" in filememo.Forget). It crashes the
same alone on a fresh origin/main 19dc5b925 and is #3632, open.
- rebased onto origin/main 2afacd7d1 (this commit's parent): catalog
and provider again with -skip TestUnreadLoginsWriteErrorsKeepCredentials,
both ok. agent and gateway were not run again after the rebase.
- gofmt -l internal/: nothing. go vet for darwin, linux and windows on
catalog, provider, agent, gateway at the rebased head: ok.
- Real use: magpie built from this tree (linux, nogui) in a golang:1.26.8
container with a sandbox HOME, so the Mac's Keychain and ~/.claude are
never read. `magpie sync` fetched models.dev's real catalogs today
(api.json's anthropic has no claude-mythos-5-1; labs.json has it).
With a fake Claude sign-in and a .claude.json whose bootstrap caches
name claude-mythos-5-1, `magpie models` lists claude/claude-mythos-5-1
"Mythos 5.1" low/medium/high/xhigh; `magpie model spec` gives 1M,
128k, vision on; `magpie model price` gives $25/$125, cache read
$2.5, write $31.25 / $50 (1h). A custom Anthropic-protocol provider
against a fake /v1/models returning claude-mythos-5-1 lists
fakeanth/claude-mythos-5-1 "Claude Mythos 5.1" with 1M / 128k /
low..xhigh.
Broken by hand, each red:
- lab reading off in loadGen: every lab assertion in the catalog tests
and the provider tests (no window, no levels, the API-key entry's
context 0).
- syncLabs off: TestSyncKeepsLabs.
- labKinEfforts off: the efforts assertions.
- the Claude list back to catalog.Provider("anthropic"): "Claude
account's list has no Mythos 5.1".
- claudeLists / claudeCodePrice off: the entitlement and price
assertions.
Not tried:
- a real account with Mythos 5.1: none here. The .claude.json keys and
shapes were read from Claude Code 2.1.311's own binary, not a real
account's file.
- a custom Anthropic-protocol provider without catalog=anthropic gets
no price for a lab-only model (labs carry none).
- the plugin host's mdev() (host.js) reads api.json only; Gemini CLI's
own picker stays catalog-only; a saved Claude account whose Claude
Code never ran has no .claude.json, so its gated models show once it
has run there.
zhaocai_83020 on Discord asked how to make several WorkBuddy accounts
spend the credits that expire soonest first. Smart, the default routing,
already took a window's runsOutAt (plugin 0.1.14, cdredfox on X) as its
renewal, but only when it came before the window's reset. Since plugin
0.1.35 (windy on Discord) a WorkBuddy free account's Credits window
resets at the month's end, the same moment on every account (cycleOf,
packages/workbuddy usage.test.mjs CN_FREE: 10-31 23:59:59 +08), so given
credits lapsing after that end ranked alike and kept the accounts'
listed order: the account whose credits were lost first wasn't spent
first.
Allowance.Lapse is the soonest RunsOut in the future of a window that
counts the model, carried to routes.Seat.Lapse. Smart goes by it, to the
hour, only when the renewals tie: the one lapsing first goes first, one
telling none after those that do, the same hour keeps the listed order.
The share-used tiers and the renewal still decide before it. It is read
from the window's structure (RunsOut), not the provider's name; only the
WorkBuddy plugin sends runsOutAt today. Weekly pace and the other
routings are unchanged, as before. The gateway-strategy plugin seat
(middleware/points.go) doesn't carry it, as it carries no Free, Credits
or speed either.
Docs: reference.md (How magpie picks an account), gateway-routing.md,
site docs start.html en/zh/ja (not deployed by this commit).
Run at 2e165fe9d + this change; rebased onto 50606d8c0, which changes only internal/sessions:
go test -tags nogui -timeout 45m ./internal/routes/ ./internal/gateway/ ok
go test -tags nogui -timeout 45m ./internal/provider/ -skip
TestUnreadLoginsWriteErrorsKeepCredentials ok
(that test crashes the package with "close of synctest channel from
outside bubble" in filememo.Forget, untouched here: #3632, open,
with patches under review there)
go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
./internal/routes/ ./internal/provider/ ./internal/gateway/ ok
gofmt -l on the changed files clean
New TestSmartSpendsCreditsLapsingFirstWhenRenewingTogether: with
strategies.go put back to origin/main by hand it fails "lapsing first
goes first: ab"; green with the change. The windows are the plugin's
for a real China-site free account (reset at the month's end over 31
days, given credits lapsing on their own day).
Not tried: a real move of requests over several real WorkBuddy free
accounts (no such accounts on this machine), and a GUI run (no GUI
change).
Codex calling a Claude model through magpie (mysterious_dove_96933 on
Discord): a reply's reasoning items carried only the summary, so Claude's
thinking signature and a redacted_thinking block's data were gone. On
the next request of a tool loop magpie sent Anthropic the turn as
[tool_use] alone, with thinking on, which Anthropic documents as a 400
("final assistant message must start with a thinking block"), and the
model lost its reasoning across calls either way.
Now the Anthropic decoders name a signature as Claude's (KSig with
sealAnthropic, Part.SignedBy). The Responses encoder and renderResponses
give each thinking block a reasoning item whose encrypted_content is
"magpie-claude1:" and the block's JSON in base64 (internal/claudeseal):
its summary beside it, an empty summary for a block signed with no
text, and redacted_thinking as an item of its own. parseResponses reads
it back into the block as Claude wrote it, in order, so anthropicBody
sends it as before for an Anthropic client. A Gemini thought's
signature isn't named and isn't sealed.
The envelope never reaches a Responses API: withoutClaudeSeals in
passthrough and forwardOnce (the item keeps its summary, one with none
goes), codexInputAs leaves such an item out for Codex's own models, and
codexUpstreamOn takes it out before the ChatGPT backend. OpenAI's own
encrypted_content is untouched. sessions.PortCodexRollouts writes such
an item as its summary, so a thread resumed against OpenAI itself isn't
refused. redact.MaskJSON already keeps a reasoning item's seal whole
(no change); TestMaskJSONKeepsClaudeBlocks holds that.
Run, at 5e3dd1d52 plus this change:
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/sessions/
./internal/redact/ ./internal/claudeseal/: sessions, redact,
claudeseal ok; gateway ok but for TestResponsesStreamToolThenHiddenThinking
(#1786), whose hidden cases wanted no reasoning item, the loss this
fixes. They now want one item carrying the sealed block with an empty
summary, and its guarantee (a whole stream, no panic) is unchanged;
re-run green.
- gofmt -l clean; go vet (darwin) on the touched packages, GOOS=linux
go vet -tags nogui ./internal/..., GOOS=windows go vet on the touched
packages: clean.
- TestCodexToolLoopGivesClaudeItsThinkingBack (a fake Anthropic: signed
thinking, redacted_thinking, a text-less signed block, tool_use; a
Codex-shaped request with store false and the encrypted_content
include; then the follow-up) fails on 5e3dd1d52: "stream=true:
Anthropic was sent 1 assistant blocks, want 4". Passes now, streamed
and not.
- Real: a sandbox HOME with only OpenRouter's key (Anthropic endpoint,
anthropic/claude-opus-5.5, served by Claude Platform on AWS), magpie
serve on its own port, a Codex-shaped two-turn tool loop at effort
high, streamed and not: turn 1 gave a reasoning item with
magpie-claude1: (3.1KB), turn 2 was 200 through /v1/responses →
/v1/messages and answered from the tool output.
Broken by hand:
- withoutClaudeSeals a no-op: TestClaudeBlocksNeverGoToAResponsesAPI
red, the relay sent magpie-claude1: items.
- codexInputAs not leaving them out: red, "ChatGPT backend would be
sent …".
- sealing any signature (no sealAnthropic check):
TestGeminiSignatureIsNotSealedAsClaudes red.
- portValue's reasoning branch off: TestPortLineDropsClaudeBlocks red.
Not tried: the 400 itself. Through OpenRouter, Opus 5.5 answered turn 2
with the envelope stripped too (the old shape), so this route shows
only the lost reasoning, not the refusal. Not tried on api.anthropic.com
directly, Bedrock or Vertex keys, or Claude's subscription (whose tool
loop stays inside Claude Code's run). Codex resuming a ported thread
against OpenAI with such items wasn't run.
jwaitq asked in #general (10-27) for NewMax (newmax.cc), an Electron app
built on the Claude Agent SDK. NewMax keeps its settings in
~/.newmax/newmax.db ($NEWMAX_USER_DATA_DIR wins), a SQLite table
settings(key, value) whose "app" row is JSON.stringify of every setting.
Connect adds one Anthropic-format provider, id magpie-gateway, with
magpie's gateway root (NewMax adds /v1/messages itself), its key and up to
20 models (NewMax's MAX_MODELS), appends it to providerOrder and, when
the user had kept NewMax's default, picks it. The row is edited by
splicing raw JSON in one immediate transaction, so every other byte the
user has stays as written. Disconnect removes the entry and its order id,
puts providerId/model back to "default" when they were magpie's, and
deletes the row when magpie made it. NewMax holds settings in memory and
writes the whole row on any change, so magpie refuses to write while
NewMax runs (macOS/Linux, matched on the program, not on a folder named
newmax) and says why in every language.
Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
./internal/agentenv ./internal/appdir ./internal/sessions at this head
(rebased on 5e3dd1d52): ok
- gofmt -l clean; go vet darwin, linux (nogui) and windows on the touched
packages
- GUI i18n-keys and agent-notice-lang, Chromium and WebKit: 15/15 each
Broken by hand, each red: user entry's name/off overwritten
(TestNewMaxProvider), running check removed (TestNewMaxLeavesAlone), row
kept after off (TestNewMaxMakesItsRow), pick left on magpie
(TestNewMaxProvider), no model cap (TestNewMaxModelCap), the first
process pattern that matched a shell in a newmax folder
(TestNewMaxProcess).
Real use: NewMax 1.1.22 (macOS dmg) in a sandbox HOME and
NEWMAX_USER_DATA_DIR, with this magpie on a sandbox port. Connect was
refused while NewMax ran; after quitting it wrote the row; on relaunch
NewMax's picker listed and picked magpie's models, its ClaudeProxy sent
to magpie's /v1/messages, and "Reply with exactly: pong" came back
"pong" through magpie to a fake Anthropic upstream. NewMax's own 58KB
row afterwards (47 providers) kept magpie's entry as written; disconnect
then removed only that entry, its order id and the pick
(live/deepseek/deepseek-flash -> default), every other byte the same.
Not tried: NewMax on Linux or Windows (Windows has no running check, as
pgrep isn't there); a real vendor reply through NewMax (the sandbox used
a fake upstream).
cliff_26651 (Discord #general, 10-27): with magpie routing on, Codex
didn't list gpt-6.1-terra. OpenAI added it on 10-26 (openai/codex
126a0ee92 "Add GPT-6.1 Terra to model catalogs (#57293)", in
rust-v0.166.0-alpha.1; models.json: minimal_client_version 0.153.0,
context 500000 / max 872000, low..ultra). The ChatGPT backend's /models
serves it to a Pro account at client_version 0.159.0 through 0.166.0
alike (checked read-only), so magpie's version floor isn't it.
Cause: FetchNew fetches an account's list only when magpie has none, and
nothing fetched it again but Refresh. The owner's own ~/.cache/magpie
models/codex.json was fetched 2026-10-12 and still listed 7 models. Every
built-in account (Codex, ChatGPT API, Copilot, Gemini CLI, Antigravity,
Claude's static one) had the same gap; plugins already relist hourly
(KeepPluginsListed) and own providers by RefreshEvery.
KeepAccountsListed (account_relist.go), started by the gateway beside
KeepPluginsListed, looks 2 minutes after start and then hourly, and
fetches again each ready, not-switched-off built-in account's list that
is 45 minutes old, through the same Fetch as Refresh. A plugin's account
and one with no list yet (FetchNew's) are left alone. A failed fetch
keeps the list there was (each fetch saves only what it got). No static
catalog entry is needed: the window, efforts and image input come from
the backend's own list.
Run:
- TestAccountListFollowsTheVendor, TestKeepAccountsListedAsks: ok, also
-race -count=5 and TZ=UTC.
- Broken by hand: relistAccounts returning nil (the old behaviour) makes
both fail: "a list 46m0s old not asked for again: []" and "the loop
asked the vendor 0 times in 30s".
- Real: magpie serve (this tree) in a sandbox HOME with a copy of the
owner's ChatGPT Pro auth.json and the 10-12 codex.json: start kept 7
models; at +2m "codex: fetched its list again, 8 models", codex.json
now has gpt-6.1-terra (500000/872000) and /v1/models lists
codex/gpt-6.1-terra. The copied auth.json was unchanged; sandbox removed.
- go test -tags nogui ./internal/provider/: ok with
TestUnreadLoginsWriteErrorsKeepCredentials skipped; that test crashes
the package alone on origin/main too (synctest bubble in
filememo.Forget), #3632, open with patches.
- go test -tags nogui ./internal/gateway/: ok (588s).
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/provider and internal/gateway: ok.
Not tried: the full ./... suite (other sessions' suites were running,
load ~50); Copilot, Gemini and Antigravity accounts relisted for real
(same Fetch as Refresh, unchanged).
An agent a plugin adds is known only while the plugin is on. Turning
the plugin off or removing it (CLI `magpie plugin off/rm`, or the
Plugins page) left the agent's config on magpie, and `magpie <agent>
default` then said `unknown agent`, with nothing to put it back.
- provider.SetPluginOff (off) and provider.RemovePlugin first call
provider.PluginAgentGoing, set by internal/agent to UnwirePlugin: the
agent is disconnected as `magpie <agent> default` does (Disconnect),
while the plugin still loads. A plugin off already is read from its
module as it is; one whose module is gone puts back each file whose
stash names its spec. If that fails, the plugin is left as it was
and the error says why.
- The stash now records the plugin's spec and the file's format, so
`magpie <id> default` for the agent of a plugin deleted on disk puts
the file back from the stash alone (agent.RestoreGone; an older
stash's format comes from its file's name, agentplug.FormatOf). A
file that no longer holds magpie's gateway key is the user's and is
left alone; one that can't be read is unknown: nothing is written,
the stash is kept. With the plugin only switched off, `default` says
the agent is off magpie already instead of "unknown agent".
- Turning the plugin back on (or installing it again) does not rewire
the agent by itself: its config stays as the user had it. Connecting
it (its switch on the Agents page) puts back the model it was on,
through Disconnect's `.reconnect`. The CLI says so when it turns off
or removes a plugin whose agent was on magpie.
Run (this change on origin/main f3c4d7b7a, then rebased onto
0fb0bfda3, which changes only an internal/gateway test; provider and
cli run again at the pushed head):
- gofmt -l: none; go vet -tags nogui on darwin, linux, windows for
agent, agentplug, cli, provider, gui, plugin: ok.
- go test -tags nogui -timeout 45m -count=1 ./internal/agent
./internal/agentplug ./internal/cli ./internal/provider
./internal/plugin ./internal/gui: agent, agentplug, cli, plugin, gui
ok; provider crashes in TestUnreadLoginsWriteErrorsKeepCredentials
("close of synctest channel from outside bubble", filememo.Forget),
the same on origin/main 0fb0bfda3 run alone: #3632, open, not this
change. At the pushed head: cli ok; provider with -skip
TestUnreadLogins ok.
- Real use, sandbox HOME, magpie built from this tree, gateway on
127.0.0.1:3491, web on 3492: `magpie plugin add agent-kilo`
(@magpie-community/agent-kilo 0.1.0, not on npm, from the plugins
repo's dist branch), a kilo.jsonc with comments and a provider of its
own, `magpie kilo magpie/deepseek/deepseek-chat` (wired, provider
block added). Then, each time from wired: `magpie plugin off` -> cmp
byte-identical; `plugin on` -> still the user's; `plugin rm` ->
byte-identical; POST /api/plugins/off and /api/plugins/remove (the
Plugins page's calls) -> byte-identical; plugin dir deleted and
plugins.json emptied by hand, then `magpie kilo default` -> put back,
byte-identical. `magpie kilo default` with the plugin off says it is
off magpie already.
Broken by hand, each red, then restored:
- PluginAgentGoing left nil: the four off/remove tests fail.
- the SetPluginOff call removed: Off and ModuleGone tests fail; the
RemovePlugin call removed: Remove and RemovedWhileOff fail.
- Spec not stashed: ModuleGone fails. pluggedOff disabled:
RemovedWhileOff fails. FormatOf fallback removed: TestRestoreGoneAgent
fails. The gateway-key check removed: LeavesAFileOffMagpie fails.
- Unwire instead of Disconnect: the Off test fails (How "first", not
"again"). The off-plugin check in RestoreGone skipped: the Off test
fails. RestoreGone not called from the CLI: TestGoneAgentDefault
fails with `unknown agent "kilo"`.
Not tried: the Windows box; a real Kilo CLI reading the restored file;
the GUI suite (no Plugins page code changed: the page's calls reach the
same provider functions, tried above through the web API). Not changed:
an inline JSON object magpie wrote into comes back reformatted (same
values) on any plugin agent's Disconnect, `default` included: #3814.
Adding clean-code from sickn33/agentic-awesome-skills in the market
failed with "GitHub's list of sickn33/agentic-awesome-skills's files
wasn't understood: unexpected end of JSON input" (CaiusLuo; stablyai/
orca the same, ye4241). The repository's download is over 200 MB, so
its skills are fetched file by file from GitHub's list of its files
(#1941), and that list is 11.3 MB: apiGet cut every answer at 8 MB and
dropped the read's error, so JSON was handed a cut-off body.
From ye4241's patch on the issue (made on 75e769a9, applied as is):
apiGet takes the most its caller reads and reads one byte past it; a
200 over it is an error naming the cap, a read that breaks is a read
error, a rate limit is told from the status and headers before either,
and only answers up to 8 MB are kept for a 304. The file list's cap is
64 MB (maxTree), lastCommit keeps 8 MB.
That alone wasn't enough for the reporter's case: the 8,589 skills of
that repository come to 287 MB together, over maxFetch, so the install
would then fail as "too big to install". On top of the patch:
- fetchSkillFiles fetches only what the caller reads: the skills under
src.Path, and for the market only the folders named as the skill it
installs (InstallMarketSkill -> cachedProbeFor/probeSkills; such a
probe is kept under its own key so a whole probe never takes it).
When no folder has that name every skill under the path is fetched,
as before.
- with a path (a link to a folder, an update, a check for new skills
under newBase) the list asked for is that folder's own, git's
ref:path (treeUnder; a few KB instead of 11 MB, and small enough to
be kept for a 304). When it can't be had (404, a ref git can't read
that way, cut off) the whole list is read, which says for sure what
is there, so goneFrom never trusts a 404. A rate limit is said at once.
- the fetcher kept one fetch per repository and ref for every skill of
it. A fetch narrowed to one skill's folder is now kept to that folder
(fetcher.get): another skill of the same repository gets a fetch of
its own, where it was read as removed upstream (broken by hand below).
- a CC Switch skill being adopted looks in the whole repository, since
its Path is only the folder's name.
- a probe of a folder whose skills are all too big lists it empty and
names them, as before; the whole repository's still fails.
- GitHub's own truncated list is errTooBig, by path or not
(TestTruncatedListIsTooBig).
- apiGet's client waits 2 minutes, not 20s, for an answer over 8 MB.
docs/subsystems/library.md says how far a big repository is fetched.
Tests (no network; fake codeload, API and raw):
- TestMarketSkillFromAHugeRepository: an 11 MB list, a download over
the limit and skills over it together. The market installs one, raw
is asked only for its files, and UpdateSkills of two of its skills
updates both, each asking for its own folder's list.
- TestRepoTreeBigList, TestApiGetWholeAnswer: ye4241's.
- the fake trees in skilltree_test and skillnew_test answer git's
ref:path as GitHub does (checked against api.github.com: HEAD:skills/
clean-code lists that folder, HEAD:nonexist is 404).
Broken by hand, each red, then restored:
- apiGet back to the 8 MB cut with the error dropped: both
TestRepoTreeBigList and TestMarketSkillFromAHugeRepository fail with
"unexpected end of JSON input".
- no name narrowing: "the skills in vectorize-io/hindsight are too big
to install".
- the fetcher sharing a narrowed fetch: Gone:[hindsight-docs].
- no ref:path list: the update listed ["HEAD" "HEAD"].
Run at this tree (65ee8c65c plus this change):
- gofmt -l internal: clean
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./...: clean
- go test -count=1 -timeout 45m ./internal/library/: ok 131s
- real: a throwaway realnet test in a sandbox HOME, no GitHub token,
InstallMarketSkill("sickn33/agentic-awesome-skills", "clean-code"):
installed in 15s, SKILL.md 5,202 bytes, Path skills/clean-code;
UpdateSkill then took 0.6s through its folder's list. The same test
at origin/main 65ee8c65c: "unexpected end of JSON input".
Not tried: the full ./... suite (only internal/library changed, other
sessions' suites were running); Windows and Linux runs (vet only); the
GUI (no GUI text changed); stablyai/orca for real.
Co-authored-by: ye4241 <ye4241@users.noreply.github.com>
mimi001234 (Discord, #general): agy installed in a WSL distro never
showed on the Agents page. wslKinds had no agy, so the distro probe never
looked for it.
agy is now a WSL kind (bin agy, dir .gemini/antigravity-cli), with the
model field offered for a stopped distro too. agy takes magpie only from
how it is started, and no magpie runs inside the distro, so a magpie pick
writes an agy shell function into the distro's own profiles: .bashrc,
plus .zshrc or fish's config.fish when the login shell in the distro's
/etc/passwd is zsh or fish. The function reads settings.json's model at
run time. It adds --model only for a magpie model the user didn't name
themselves, and sets GOOGLE_GEMINI_BASE_URL to place.gw() (the NAT
address, never 127.0.0.1) and GEMINI_API_KEY to the distro's WSL key.
Default removes the block. Check flags a function whose address has
moved, and Sync rewrites it. update.ShellFunction gained ShellFunctionAt,
DropShellFunctionAt and ShellFunctionInAt for profiles given by path
(fnProfile is now ShellProfile). This machine's own agy function is
unchanged. The restart notice is translated (de, zh, zh-TW, ja).
agent-wiring.md and reference.md are updated.
Run at c272f3799 + this change, then at this head (rebased on
65ee8c65c, which touched only gateway and plugin): the whole of
internal/agent and internal/update again, ok, and go build ok.
- go test -tags nogui -timeout 45m ./internal/agent/... ./internal/update/...
./internal/cli/...: update and cli ok. agent was red only on
TestEveryNoticeIsTranslated (the new notice wasn't in i18n.js); after
adding it, TestEveryNoticeIsTranslated and TestWSLAgy* are ok.
- go test -tags nogui ./internal/gui: ok.
- GUI, chromium and webkit: i18n-keys, agent-notice-lang and
wsl-agents-setting all pass.
- gofmt -l on the changed files; go vet ./...; GOOS=linux go vet -tags
nogui ./...; GOOS=windows go vet ./...; go build for darwin, linux
(nogui) and windows: all clean.
- The bash and zsh functions are sourced in the test with a fake agy. The
fish function was run in docker alpine:3.20 with fish.
Broken by hand, each red:
- bin "agyx" in the wsl kind: TestWSLAgyFound and TestWSLAgyStopped fail.
- 127.0.0.1 instead of at.gw(): TestWSLAgyPick and TestWSLAgyFunctionRuns
fail.
- default not dropping the function: TestWSLAgyPick fails on .bashrc.
Not tried: real WSL. The Windows box (10.0.0.132) didn't answer ssh.
Fish wasn't tried inside a real distro.
orion-nebula-dev's routing log: GLM-5.3-Flash-Trial and GLM-5.3-Trial,
whose Start Plan trial had ended, were refused by the ZCode plugin with
400 "ZCode has no active limited quota for GLM-5.3-Trial". The word
"quota" made it failQuota, and restAfterMarked rested the account
("zcode@zcode"), so the subscription's GLM-5.3 and GLM-5.3-Flash were
paused with it.
zcodeTrialRefused narrows that rest to the trial entry (restID) when the
candidate is a zcode plugin account, the model ends in -Trial, and the
refusal is the plugin's own words naming that model:
- 400 "ZCode has no active limited quota for <model>" (the trial ended);
- 429 "ZCode's limited quota for <bucket> is exhausted or temporarily
unavailable", where the bucket is the entry less -Trial (its bucket
spent). skygunner's patch covered the 400 only and kept this 429 as an
account rest; it is the trial bucket's, given by the plugin before
anything is sent, so it rests the entry too.
Another model named, a model without -Trial, the ended words on a 429,
the account's own quota (400 or 429) or key (401), and the same words
from another vendor still rest the account.
The plugin is not changed: zcode 0.1.31 already leaves ended trials out
of its model list and its two refusals are exact, and open plugins PRs
#395 and #421 hold zcode's next version. A member the user kept in a
group is still asked, refused locally, and asked again a minute on (a
guessed quota rest); the Routing page strikes such a member as
"skipped", which the gateway doesn't do: filed as #3805.
Ported from skygunner's e04a1b994 (branch
fix/r25-expired-model-not-account-fault): the test plugin's
FAKE_ZCODE_TRIAL and FAKE_NO_FREE fixture is his; the matcher, the 429
case and the test were rewritten. Reported by orion-nebula-dev.
Run:
- TestZCodeTrialRefusalRestsTheTrialAlone: 12 cases, the reporter's
literal plugin bodies. Each posts to a group of the trial then another
provider, checks the try's rest key, then posts to a group of the
account's GLM-5.3 then another provider: served by the account when
only the trial rests, by the other provider when the account does.
- Broken by hand: the routing.go hook off -> the four trial cases red
("refusal rested \"zcode@api key\", want \"zcode@api key/GLM-5.3-Trial\"");
the 429 branch off -> "trial spent" red; the zcode-only check off ->
"another vendor's words" red. Green again after each.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows; GOOS=linux go build -tags nogui ./...
- go test -timeout 45m -count=1 ./internal/gateway ./internal/plugin at
f34a9f8cf (this change on b7d5a97fe): both ok (436s, 87s).
Not tried: a real ZCode account with an ended Start Plan trial (none to
hand); the full ./... suite (other sessions' suites were running); the
Windows box.
Co-authored-by: vincent <vincent@users.noreply.github.com>
cybercaius (Discord) asked whether Codex's side calls (title, thread
description, composer prediction, memory consolidation, auto-review)
still go to the model the conversation was switched away from, and
whether the first of each after a switch follows it as the title does
since 81a73c1c0.
Titles, descriptions and predictions already followed: untied ones wait
in codexLeads.sideOf for the next turn when the last is stale, and tied
ones (a forked prediction) are asked on the thread's model. The
auto-review runs inside its turn, on that turn's model ("session") or on
codex-auto-review/the set model, so it follows at once.
Memories did not. Codex starts them with every turn that has the user's
input (codex-rs app-server start_memories_startup_task), concurrently
with that turn. Extraction is tied to the conversation's thread, so
codexSessionOf took that thread's last model at once: the one before the
switch. Consolidation, on its own thread, took the key's last model
without waiting. With magpie as Codex's provider, codexMemoryStandIn read
the last turn per agent and key, which the racing turn hadn't written.
Fix, at the two places a memory call is routed:
- codexLeads.sideOf takes beside: a call started with a turn waits for
the next turn even when tied (codexMemorySession); codexFollowTo uses
it for memories, and reads CodexSideSet first so a model set in
Codex's config never waits.
- rememberCodexTurn also records the turn in codexLeads, and
codexMemoryStandIn reads codexLeads.sideOf(beside) before its last-turn
record.
docs/subsystems/gateway-routing.md says so.
Tests (fake upstreams, a session switched from one relay to another):
TestCodexSideCallsBeforeTheFirstTurnFollowTheSwitch (title, description,
prediction, memory extraction, memory consolidation, each sent before
the first turn after the switch), TestCodexMemoryOfASwitchedConversation
FollowsTheSwitch (an ongoing conversation switched), and
TestCodexMemoryStandInFollowsTheSwitch (magpie as Codex's provider).
Run: go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., gofmt -l clean, go test -timeout 45m
./internal/gateway/... ok (424.7s), at the pushed head
rebased on 94a70f1a0.
Broken by hand: with the old codex_follow.go, codex_memory.go and
gateway.go, both memory subtests, the switched-conversation test and the
stand-in test fail (the old relay got 2 requests); title, description
and prediction pass on the old code, as they already followed. With
beside forced false for memories, the switched-conversation test fails.
With saw() dropped from rememberCodexTurn, the stand-in test fails.
Not tried: a real Codex app or account. The app's ambient_suggestions
calls are not routed by magpie (they go to ChatGPT) and are left alone.
A tied call that isn't started with a turn (a prediction on a known
thread) asked after a switch but before the new turn still takes the
thread's last model, by design: waiting there would add latency to every
prediction.
Reported by cybercaius on Discord.
fremontdango on Discord asked, after the request that sat as "routing…"
while it was masked, how long masking took. Now each request keeps it.
noteRedacting adds up the time from the first masking at once to the
last's end (redaction.spent); maskingMs gives it in ms, at least 1 when
there was any, never more than Own, magpie's own time before the request
went out (splitSent), since masking happens inside it. It goes on the
route (Route.Masking, /api/gateway/trace) and in the usage record
(Record.Masking, masking_ms; packedRow's int32 fits in its padding, so
TestRowsOfOneSessionShareAShape's 216 bytes are unchanged, and the
process-private snapshot carries it). It is a duration, no text.
The Routing page shows it as magpie's "Masking" part, first in where the
first try's time went (timeParts, renderSteps); the Usage page's detail
splits it out of "In magpie" (page.js). Both use the core "Masking"
string every language already has (脱敏, 脫敏, マスク, Maskierung).
Why masking can be slow, measured on this machine (go1.27, M-series):
the rules are linear, ~0.25 ms/KB. redact.MaskJSON over a Claude Code
shaped body: 283 KB 35 ms (secrets) / 63 ms (+ personal data); 511 KB
70 / 122 ms; a dense 402 KB with 7,821 hits 173 ms with personal data,
144 ms with the user's words too. Through the gateway (redactedHits,
secrets + personal, 402 KB dense) 145 ms the first time, 123 ms again;
noteMasked ~2.6 ms. Doubling the body doubles the time; nothing
quadratic or repeated per hit. So a request held "routing…" for 15 s or
more (unroutedShow) while masked is the local model (Settings → Privacy
→ Find with a local model, internal/pii): it reads each text it hasn't
seen (a new turn's tool results are the misses), one model turn at a
time, so requests queue behind each other (#3682: 480 KB took 90 s on an
RX 470/580). No change to masking's speed here; the phase and the time
now say which it was.
Run at this head, on origin/main 9ae791221 (Go, M-series macOS):
- go test -timeout 45m ./internal/gateway ./internal/gui ./internal/redact
./internal/usage: ok (gateway 425s, gui 99s); ./internal/masking and
./internal/pii ok at the pre-rebase head 3a4a13d04
- gofmt -l internal: clean; go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...: clean; go build: ok
- go test -race -count=3 TestMaskingIsAPhaseWithItsTime,
TestNoMaskingNoMaskingTime: ok
- GUI, chromium and webkit: routing-masking (every language) 10/10,
usage-ledger-detail 6/6, i18n-keys and routing-levels green. The whole
routing-*, panel-routing*, usage-ledger* and i18n-keys set: 1,824
tests, 96 red at load ~47, in 15 files. The first run's i18n-keys red
was this change's (a Go comment quoting the core word), fixed in the
commit before. The other 14 files, rerun two at a time at this head
and at origin/main 9ae791221: the same files red on both (89 here, 86
there; routing-rule-remove alone 5 red here, 7 on main). Each has an
issue: #2115, #3410, #3411, #1905, #3593, #3408, #3096, #3094, #3001,
#3104, #3786.
Broken by hand, each red: spent not added (route and record Masking 0),
no t.Masking on the route, no Masking in the usage record, the snapshot's
put/take of Masking (TestRowsOfOneSessionShareAShape), timeParts without
Masking or renderSteps without the first try's masking
(routing-masking), the Usage page without the Masking line
(usage-ledger-detail, 3 red).
Not tried: a real local model (Settings → Privacy → Find with a local
model) on the reporter's Windows box or any GPU, so a long masking was
only held by a fake masker; the Codex backend's usage record has no
Masking yet; the Windows test box wasn't used.
Reported by fremontdango on Discord.
fremontdango on Discord: a Claude Code request to deepseek/deepseek-flash
sat on the Routing page as "routing…" for a long while that it was
actually being masked (Settings → Privacy). The placeholder route shows a
held request after 15s with nothing to say what holds it.
noteRedacting (redact_phase.go) wraps every masking, at the one place
each route masks through: redactedHits and maskTextHits in redact.go
(chat, Codex backend, search, images, video, System One, embeddings,
audio, count_tokens). It keeps noteMasking's exemption from the unrouted
limits, sets the request's phase to "redact" (notePhase, on
/v1/magpie/concurrency) and puts Route.Phase "redact" on the route that
shows it, its own or the unrouted placeholder, until the last masking at
once ends. A route that is done never carries it. It holds no text.
The Routing page says "masking…" for such a row, in the list and the
panel row, in every language (plugins/routing/i18n.js: 脱敏中…, 脫敏中…,
マスク中…, maskiert…).
Run, in a copy of this commit's tree:
- go test -race -count=2 -run 'TestMaskingIsAPhase|TestNoMaskingNoPhase|Unrouted' ./internal/gateway: ok
- routing-masking.test.cjs, chromium and webkit, en zh zh-TW ja de: 10/10
- gofmt -l, go vet ./internal/gateway: clean
The full suite is in the next commit's body, at the pushed head.
Broken by hand, each red: noteRedacting without notePhase (phase ""),
redact.go back to noteMasking (phase and route ""), showLocked without
the phase; waitWord back to "routing…" (5/5 GUI red per engine).
Not tried: a real local masking model (the Windows box, its GPU); a
masking that starts after a route is already shown (showRedacting at
the start) has no test that fails without it.
agy takes magpie's gateway, key (GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL)
and --model only from how it is started, so a user on magpie had to copy
the launch command at every start (bestony on Discord). Now:
- magpie agy run [args…] execs the real agy with the env and --model when
agy's settings.json is on magpie's model (a --model/-model the user
gives wins), and runs agy untouched otherwise. On Windows agy is a child
through proc and its exit code is passed through. It refuses when "agy"
on PATH resolves to magpie itself. magpie agy env prints what run adds
(PowerShell's function reads it, since the desktop exe has no console).
- update.ShellFunction puts a function named agy in a marked block
(# >>> magpie agy >>> … # <<< magpie agy <<<) of each shell profile
cliShells finds: .zshrc (ZDOTDIR), the bash profile a terminal reads
(.bash_profile, or .bash_login/.profile on macOS when that is missing),
config.fish once its folder exists, and the PowerShell 7 / Windows
PowerShell profiles where the execution policy runs them. Only the block
is written, in place, temp-and-rename, CRLF and BOM kept; a profile that
can't be read is not written; only files inside the home are. The
function falls back to `command agy` when the magpie it names is gone.
- Set to a magpie model writes the block, stepping out takes it out (the
file comes back byte for byte), and Sync at start writes it for users
already wired.
- Notice, Launch tooltip and the connect panel say plain agy works in a
new terminal, with the command for a terminal open now. Strings in
i18n.js for zh, zh-TW, ja, de. docs/reference.md and
docs/subsystems/agent-wiring.md updated.
Run at this head (base a3d4f8c5c, origin/main just fetched):
- go test -tags nogui -count=1 -timeout 45m ./internal/agent/...
./internal/cli/... ./internal/update/... ./internal/gui/...
./internal/proc/... : all ok.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... : clean. gofmt -l on the changed files: none.
- GUI (node --test, chromium + webkit): agy-launch, cursor-local-launch,
agent-connect, agent-connect-no-models, agent-connect-all-hidden,
agent-connected-unfolded, connect-address-kept, connect-snippet-shell,
agent-notice-lang, agent-leave-magpie, agent-disconnect, copy-command,
i18n-keys, gui-de, gui-ja, gui-zh-tw: 0 fail. Not the whole GUI suite.
- Real try, sandbox HOME under the scratchpad, nogui build, fake agy on
PATH printing its args and the two env vars, env -i:
magpie provider add deepseek + magpie agy deepseek/deepseek-chat wrote
the block after the user's two .zshrc lines; `zsh -i -c 'agy -p hi'` got
--model magpie/deepseek/deepseek-chat, GEMINI_API_KEY=magpie-agy and
GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:38712; `agy --model x` kept x;
wiring again left .zshrc's mtime alone and added .bash_profile once it
existed, and `bash -l -i -c 'agy -p hi'` got the same; `magpie agy env x`
refused; magpie agy default took both blocks out, .zshrc equal to the
original, and plain agy ran with no env and no --model.
Broken by hand, each red, then restored:
- no fnInHome check: TestShellFunction, TestShellProfiles red.
- block appended instead of replaced in place: TestShellFunction red.
- unreadable profile treated as empty: TestShellFunction red.
- blank line before the block left on removal: TestShellFunction,
TestWithFnBlock red.
- --model always added: TestAgyRun red.
- Sync without agyShell: TestAgyShell red. Stepping out without
agyShell(false): TestAgyShell red.
- app.js typed row off, typed tooltip off: agy-launch 4 of 10 red each.
Not tried: PowerShell on Windows for real (vet only); WSL; a user's own
`alias agy` (an alias beats the function); a terminal already open needs
the copied command; macOS bash started non-login reads .bashrc, which
isn't written; a Documents folder redirected outside the profile isn't
written.
What changed
- fnm puts its Node on a terminal's PATH from the shell profile
(`fnm env | Invoke-Expression`), never in the registry, so magpie
started from the Start menu had no node: a Library MCP server run by
bare npx was "notfound", and one run by npx.cmd's full path (the
reporter's C:\Users\...\fnm\aliases\default\npx.cmd, alone or under
`cmd /c`) exited 1 with cmd's "'node' is not recognized", since the
package npx fetched runs node by name.
- Windows UserPath (no-op before) adds the folder fnm's default alias
names, after what PATH has. UserBinDirs (FindTool) gets each fnm
Node: the default alias first, then installations newest by number.
- fnm's Windows layout, checked against Schniz/fnm master (config.rs,
directories.rs, version.rs, fs.rs, commands/env.rs): root FNM_DIR,
else etcetera's Windows data_dir\fnm (home\AppData\Roaming, APPDATA),
else legacy ~\.fnm; versions in node-versions\<v>\installation with
node.exe/npx.cmd directly in it (no bin on Windows); aliases\default
a junction to an installation folder; the "system" alias points at
Z:\_fnm_\..., read as none. XDG vars on Windows only move fnm's
multishell links, not its versions. LOCALAPPDATA isn't used for them.
- The shared node-version helpers (nodeVersions, parseNodeVersion,
nodeVersionLess, isDir) and addPath moved from the !windows files to
nodever.go unchanged; fnmWin* there take home/APPDATA/FNM_DIR as
arguments so the tests run them on every OS.
- The Library check (checkStdioAt, this machine only) starts a bare
command PATH lacks from where proc.FindTool finds it and puts that
folder on the child's PATH (stdioProgram, withPath), as the owner's
plan on the issue said. Docs: agent-wiring.md, library.md.
Run
- macOS: go test -count=1 ./internal/proc/ ./internal/library/ ok
(TestNoCommandBypassesProc and the other proc guards included);
gofmt -l clean; go vet GOOS=windows/darwin for proc, library, cli,
daemon; GOOS=linux vet proc, library and (-tags nogui) cli, daemon;
GOOS=windows test binaries for proc and library build.
- Windows box (Win 11 x64), cross-compiled amd64 test binaries:
TestUserPathFnmNode (real junction via mklink /J, npx.cmd that runs
node by name) red on origin/main 4a1cd7765's code ("PATH after
UserPath = [C:\windows\System32], want fnm's default alias"), green
here; TestFnmWin* green.
- Real fnm 1.39.0 + Node v24.22.1 installed into a sandbox
(USERPROFILE/APPDATA under C:\Users\yeton\fnm-2685, no FNM_DIR,
registry PATH without node). A throwaway probe calling UserPath then
library.CheckServer on chrome-devtools-mcp@latest:
4a1cd7765: npx -> notfound; ...\aliases\default\npx.cmd -> exited 1;
cmd /c ...npx.cmd -> exited 1 (the reporter's case).
This commit: all three ok, 32 tools.
- Broken by hand: stdioProgram without FindTool ->
TestStdioProgramFindsWhatPathLacks red; fnmWinBins without the
default alias -> TestFnmWinBins red; Windows UserPath as before ->
TestUserPathFnmNode red (above).
- Windows full proc/library binaries: TestNoCommandBypassesProc,
TestGoneAgentListedToTakeOut, TestCheckMixedServerEachSide,
TestCheckKeepsToolNames and TestRTKNoHookIssuesAreEachAgents fail
the same with 4a1cd7765's binaries run the same way; the guard and
two of them read the source tree, which a binary run outside a
checkout doesn't have; the other two are in #1827.
Not tried
- The desktop GUI on Windows with the reporter's fnm (the probe runs
the same UserPath and CheckServer calls the app does).
- magpie serve/web/tui on Windows don't call UserPath (as on macOS), so
there an absolute npx.cmd still lacks node on PATH; a bare npx is
covered by the check's FindTool.
- Agents magpie starts get the new PATH only from the GUI/daemon.
Refs #2685
Co-authored-by: Edward4226 <234070868+Edward4226@users.noreply.github.com>
yogurt36 on Discord asked for Hide accounts per account wherever people
take a screenshot: the menu bar panel's usage as well as the window's
providers, with one logic and one interaction. d3191a51c gave the
window's provider rows and Usage cards an eye and left the panel always
masked. Now each panel Usage card has the same eye beside its name
(hideAccounts.eye in a .pq-who wrapper, so the name still ellipsizes and
the eye keeps its place), going through the same shown set that hits()
skips, with the same look: hidden with Hide accounts off, quiet until
the card is hovered or the eye has focus, in sight while it shows its
account. A click shows that account, its name and address together
(kin), on its card and in the card's tooltip; the others stay masked.
How long: until the panel is put away. The panel's page stays loaded
while hidden, so its visibilitychange (the one that already drops
panelPeek when the panel is put away) calls hideAccounts.closed(), which
now does nothing when nothing is shown. Memory only, never stored.
Shared or not: not shared. The window and the panel are separate pages
with separate sets, and that is kept on purpose: one shown in the window
for a screen share stays masked in the panel and the other way round,
so a screenshot of either shows only what was shown there, right in
front of the user. A shown account leaking into the other surface
would be the surprise a privacy switch can't afford.
Run (macOS, playwright 1.62.0, at d4699c00a; rebased on origin/main
1885c607e, which touched i18n.js, routing/client.js and providers.go
only, and the lines below marked "after rebase" were run again there):
- account-eye.test.cjs: 15/15 in chromium and 15/15 in webkit, en zh
zh-TW ja de; the new panel test at 360px and 440px (no select, no
stripe, no sideways scroll, the eye inside its card, a click scrolls
nothing, the window still masks an account shown in the panel and
the panel one shown in the window). After rebase: both engines again.
- Red on the old code (app.js/app.css from d4699c00a): the new panel
test fails ("the panel's card has an eye").
- Broken by hand, each red, then restored: no closed() in the panel's
visibilitychange; no .pq-card:hover rule; the shown check in hits().
- 35 GUI files that open the panel with its cards or masking
(account-alias, account-mask*, mask-*, masking-records, window-mask,
provider-unmasked, panel-*, quota-*, tray-*, codex-*, usage-fold,
click-scroll, i18n-keys and others), both engines: 550/552. The two
reds are usage-fold's "the view didn't scroll" (184 !== 180) in
chromium en and zh; they fail the same, 3 runs of 3, with d4699c00a's
own app.js and app.css: #2163, untouched here.
- go test ./internal/gui: ok (TestCoreScriptBudget included; app.js
1,317,850 bytes, no budget raised). After rebase: ok.
- gofmt -l clean; go vet ./internal/gui on darwin, GOOS=linux -tags
nogui and GOOS=windows: ok.
No new strings: the eye reuses "Show this account" / "Hide this
account", already in zh, zh-TW, ja and de.
Not run: the whole GUI suite and go test ./... (another session may be
running them). Not tried: the real tray panel being put away in the
Wails app on macOS, Windows (WebView2 is hidden through chromium.Hide)
and Linux; the visibilitychange it relies on was dispatched by hand.
Antigravity answers some agents' system prompts with a fake 429 "Resource
has been exhausted", whatever quota is left. Jodiezzzzzz on X (10-27): a
Codex thread begun on GPT-5.x and switched to an Antigravity model got 429
again and again. zgoodz on X: "antigravity在Hermes里一样429". v0.1.1625
told the Codex case as a 400 with "start a new chat", which isn't zero
setup.
What Google matches, each tried on a real Antigravity account on 10-27
(in the system instruction, any case):
- "x-anthropic-billing-header:" (Claude Code)
- "built on Anthropic's Claude Agent SDK" ("running within the Claude
Agent SDK" goes through)
- "You are Codex, an agent based on GPT-5" / "..., a coding agent based
on GPT-5"
- new: "Hermes Agent, an intelligent AI assistant created by Nous
Research", Hermes' earlier default SOUL.md, kept by anyone who edited
their SOUL.md. Hermes' current default ("You are Hermes Agent, built by
Nous Research") goes through.
Each goes through with a zero-width space after its first letter.
"You are Hermes Agent, an intelligent..." still fails, so the
break goes inside the matched phrase itself.
Now codeAssistBody puts that zero-width space into each matched line
(antigravityCloak), in the system instruction only, and only for an
Antigravity account. Gemini CLI's account on the same envelope, and
every other provider and protocol, get the prompt as the agent wrote
it. The text added names nothing; it is one U+200B per line.
`magpie provider set antigravity prompt=as-written` (PromptAsWritten,
kept through Save/withPicks and the GUI's save) turns it off. Then the
v0.1.1625/#2156 fallback stands: a 400 with a hint (now one for Hermes
too, in the Routing page's five languages) and Antigravity skipped for
6h in a group.
Default-on, as the community antigravity-cloak middleware's README
says, changes what Google is sent so a request it means to refuse goes
through. That may be against Antigravity's terms. The owner asked for
it ("破解过 antigravity 提示词让其可以在别的 agent 中使用"), and it is
scoped to Antigravity accounts with an off switch.
Run at this tree (rebased on origin/main):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/
./internal/cli/ ./internal/gui/: gateway, cli and gui ok; provider
died in TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
channel from outside bubble" in filememo.Forget), #3632, red on main
since 091153bf; with -skip of that test, provider ok.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok. go build: ok.
- GUI (node --test, Playwright 1.62, chromium and webkit):
routing-ag-turned-away, i18n-keys, gui-ja, gui-de, gui-zh-tw,
routing-js, panel-routing: 45 pass, 0 fail.
- Broken by hand: with the cloak skipped, TestAntigravityAnswersHermes
AndCodexByDefault and TestOnlyAntigravityIsSentThePromptBrokenUp go
red; without withPicks' line, "prompt=as-written isn't kept".
- Real account, sandbox HOME with only the Antigravity login copied,
this build on 127.0.0.1:3496:
- real Hermes Agent (AIAgent, sandbox SOUL.md = the old persona plus
one line): "OK", 200. With prompt=as-written: 400 with the Hermes
hint. Back on default: 200.
- real Codex 0.162.1: a thread begun on gpt-5.5 (against a local
fake Responses server), then `codex exec resume <id> -m
antigravity/gemini-3-flash` through this build: "OK". With
prompt=as-written: 400 with the Codex hint.
- a synthetic switched Codex Responses thread, with and without
web_search: 200.
- opencode, droid, kimi, pi, gemini-cli, qwen, crush, goose, amp and
openclaw identity sentences: never refused, as written.
Not tried: Claude models on Antigravity (the sandbox account's Claude
quota is spent, so the Claude Code lines were checked on Gemini 3
Flash only); other agents' whole prompts, only their identity lines;
the Windows box; the whole GUI suite.
The plugins repo's antigravity-cloak 0.1.2 adds the Hermes line for
magpies before this one.
A provider set codex=as-sent (#1758) is meant to get Codex's turn as
Codex sent it, its model name alone swapped. But Codex offers web_search
on every turn, and route() translated any request offering it to a model
that doesn't search by itself (searchedForIt) before passthrough's
as-sent branch was ever reached: the developer messages merged into
instructions, apply_patch sent as a function, web_search left out,
max_output_tokens 500000 added. So as-sent never applied to a real
Codex turn, and maralica's relay, which checks requests are Codex's own,
turned them away.
route() now leaves a Responses request relayed when it goes to an
as-sent provider from Codex (codexAsSent, the same test passthrough's
branch uses, now one helper): its web_search goes to the relay as sent.
A provider at the default is translated and searched for as before.
Not changed: spawnAgentModels still widens spawn_agent's description on
an as-sent turn; filed as #3793 (whether as-sent should skip it too).
Test: TestCodexAsSentWebSearch posts the captured Codex 0.162.0 turn
(testdata/workdir/codex-0.162.0.json: developer messages, web_search;
its spawn_agent tool dropped, #3793) to a fake Responses relay: at the
default the relay gets the translation (no web_search, max_output_tokens);
set as-sent, the body is byte-identical to Codex's but for the model id.
Docs: gateway-routing.md's as-sent paragraph.
Broken by hand: the codexAsSent guard in route() off: the test red
("differs from Codex's at byte 2 of 29291": client_metadata first, the
translation). Restored, green.
Run at this commit (worktree, go1.26.8): go test internal/gateway
(whole package, -timeout 45m) ok (464s, rebased on origin/main 6afbe3f30). gofmt -l clean; go vet
gateway+provider darwin/linux/windows clean; builds as before.
Not run: the full ./... suite (machine load). Not tried: maralica's real
relay, or a real Codex against an as-sent relay.
maralica's custom Responses relay answered 403, and Codex was told only
"<provider>: 403 Forbidden": apiError dropped any body starting with "<"
and said nothing of an empty one, so a Cloudflare block page, a proxy's
nginx page and a firewall's empty refusal all read the same.
apiError now says a web page by its <title> (provider.WebPage: markup
and entities taken out, whitespace folded, 120 runes at most), and an
empty body, when the fallback is an HTTP status ("403 Forbidden" or
"Forbidden", statusLine), as refused with no details, often a firewall
or proxy in front of the API (NoDetails). An empty body under any other
fallback stays bare: sniff's response.failed with no error still reads
"upstream stream failed" (TestNativeStreamFailureAccounting). Every
caller of APIError (passthrough, translated tries, routing, search,
decide, the built-in clients) says the same. edgeBlocked now also knows
Cloudflare's block pages ("Sorry, you have been blocked", "used
Cloudflare to restrict access", plain "error code: 1005-1012/1020"), and
APIError puts the page's title before BlockedHint. JSON errors read as
their message, as before; other markup (XML) still says nothing.
Siblings: planquota's vendorSaid and the gateway's HTTP error sites for
drawing, embeddings, video and WorkBuddy's config said a bare status or
dumped raw HTML; they use provider.Unsaid (empty or page) now, through
errorSaid in draw.go, and vendorMessage names a page by its title.
notAnAPIReply's webPage and codexSaidNothing kept their own title regex;
both read provider.PageTitle now.
Routing effect: a 4xx Cloudflare block page now counts as EdgeBlocked,
so retryable() lets a 400/405 one fail over as Alibaba's does (a 403 was
retryable already).
Tests: TestAPIErrorUnsaid (Cloudflare WAF page, plain-text 1020, nginx
page with markup and an entity in its title, a 200-rune title cut,
empty and whitespace bodies under "403 Forbidden", "Forbidden" and
"502", nil under a non-status fallback left bare, JSON unchanged,
vendorSaid);
TestRelayRefusalSaysWhatItWas (a custom Responses provider answering 403
with each through /v1/responses; message has no markup);
TestAPIErrorShapes updated for the page case.
Broken by hand: the page branch and the NoDetails line in apiError off:
TestAPIErrorShapes and TestAPIErrorUnsaid red ("403 Forbidden"), and
TestRelayRefusalSaysWhatItWas red in cloudflare, page and empty
("Relay: 403 Forbidden"). Restored, green.
Earlier, the Cloudflare words out of edgeBlocked turned TestAPIErrorUnsaid
red too.
Run (worktree, go1.26.8, rebased on origin/main 6afbe3f30): at this
commit, TestAPIError*, TestRelayRefusalSaysWhatItWas,
TestNativeStreamFailureAccounting, TestEdgeBlocked* and the draw,
embeddings and video tests ok; at the pushed head (this plus the
as-sent commit, which touches neither file nor test) go test
internal/gateway, whole package, -timeout 45m: ok (464s); internal/provider whole package
crashes in TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
channel from outside bubble"), alone too, the open red on main #3632, not
touched here; the rest with it skipped: ok (99s). gofmt -l clean; go vet
gateway+provider darwin/linux/windows clean; go build . darwin and
GOOS=windows, GOOS=windows ./internal/..., GOOS=linux gateway+provider
(GOOS=linux of the app stops in wails' cgo files, as on main).
Not run: the full ./... suite (machine load ~30-60, other sessions'
suites). Not tried: maralica's real relay.
roomy leaves out a member whose model's context window the request is
longer than, and the trace dropped it from the order with no word of
it: on the Routing page its row went away, and the reason was only an
absence. Now the trace lists it in the route's left with Weighed.window
set to the window it lacked. Its row stays, faded as a seat held out
is, and says "request longer than its 200K window · passed over"; the
why list says it is left out because the request is longer than its
context window, and is asked only once every one with room is out of
its allowance (en, zh, zh-TW, ja, de). When the last resort does ask
it, its row moves from left to the order with window cleared, as
askUnlisted and unhold move theirs.
MYCF711's patch (pr/small-seats) added a Route.Small list and a row
map fix. This takes their finding but not the shape: left already
carries seats not asked (unlisted, capped, out of credits), so a new
flag on Weighed reaches the page, the session copies and the last
resort without a second list, and the row map bug they fixed doesn't
exist on main. Limit: roomy fills smallW only when the order has one
row per candidate (pl.order parallel to the candidates); a member left
out otherwise still shows only by its absence, as before.
Run: go test ./internal/gateway -run
'Roomy|TooSmall|Small|Window|Trace|Left|Unhold|AutoReset' ok;
go test -timeout 45m ./internal/gateway/...
./internal/provider/... at fcf2a5271 plus this change: gateway ok
(426s); provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials
(synctest close outside bubble, #3632) and with it skipped is ok. gofmt -l clean; GOOS=linux go vet -tags nogui and
GOOS=windows go vet of ./internal/gateway clean. go test
./internal/gui -run 'CoreScriptBudget|I18n|Strings|Plugin' ok.
tests/routing-small-seat.test.cjs (new), chromium and webkit,
en/zh/zh-TW/ja/de at 1100px and 420px: 11/11 each. The routing, panel-routing and
i18n GUI files, both engines, concurrency 3, load 40-280 from other
sessions: 1468 tests, 1410 pass, 58 fail. The reds are in
routing-pause (#3410), routing-rule-effort (#3411), intent-entry
(#3408), keys-fold (#1612, #2658), live-patch (#3637), rule-remove
(#3094, #3096) and the unfiled ones in #3786, plus seven more files
(agent-hue-not-red, columns, order-unknown, rule-remove, levels,
ctx-fold, many-keys). Those seven alone, one at a time: 68/81 here,
69/81 on origin/main d56c14e95, with only rule-remove red on both
(13 and 12). None of the red fixtures builds a left: list.
Again at the pushed head, on f92db4cdd: gofmt, linux/windows vet,
the gateway -run set above and the gui Go tests ok; routing-small-seat,
routing-free-seat, routing-held-member and i18n-keys 68/68.
Broken by hand: TestMemberTooSmallIsNotAsked red with smallW not
added to Left, and TestMemberTooSmallIsTheLastResort red with Left not
pruned after the last resort; routing-small-seat 0/11 on the client
without this change.
Not tried: a real request past a real 200K member's window in the
GUI; the trace was built by the gateway tests and the page by fixture.
Co-authored-by: MYCF711 <MYCF711@users.noreply.github.com>
issennknight (macOS 13) tried v0.1.1621 (a6d7e02c7): the page still stood
still and shook back under the wheel right after switching the Usage
page's tabs (Overview/Requests/Sessions/Context), and after an agent's row
on the Agents page was opened and then closed.
Cause, the same class a6d7e02c7 left open: under a click's 4s hold, a
scroll put back counts toward the reader's run only when the page was not
redrawn since the hold last held it (redrawn(h), against h.lay). h.lay
measured the first three held parts with NaN for one gone from the page,
and NaN never equals NaN, so a click that draws what it clicked again (the
Usage tabs are rebuilt by renderUsageTab, the agents' list by
renderAgents) read as "redrawn" at every scroll for the whole hold. A held
part stuck to the view's edge (Settings' tabs, sticky below SIDE_AT) read
the same: its place in the page changes with every scroll. Every scroll
in those 4s was put back, as the old gate did.
Fix, at the one choke point (laid/redrawn): h.lay keeps the first three
held parts still in the page that scroll with it (no sticky or fixed
ancestor inside the view), with the nodes themselves. A part gone since is
a redraw once; hold() then lays the page again and the next scroll counts
as at rest. The view's height is checked as before. Every click on every
page goes through the same hold, so this covers every tab bar, list or
card drawn again under a click, not only the two reported.
Tests:
- New view-wheel-after-redraw.test.cjs, a wheel the page never hears
(capture listener stopping it, as view-wheel-unheard): each Usage tab
clicked in turn, an agent's row opened and then closed, and a Settings
tab clicked with the page scrolled under the sticky tabs; after each
click ten wheels down and ten up must move the page. en, zh, zh-TW, ja,
de, 420 and 1000 wide (Settings at 420 only, where its tabs are sticky).
On origin/main's assets (MAGPIE_AFTER_REDRAW_ASSETS): 25 of 25 red in
Chromium and in WebKit, "ten wheels of 30px right after the click
scroll the page: from 0 to 0". With the change: 25 of 25 green in both.
- Same tree, both engines: click-scroll 11/11, i18n-keys 4/4,
view-wheel-after-click 13/13, view-wheel-unheard 3/3,
view-trackpad-coast 3/3, agent-expand-steady 2/2, held-animations 2/2,
routing-days-fit 6/6, routing-failed-open 4/4, stays-strict 15/15,
update-auto 5/5. Box at load 40-140.
- go test -tags nogui -run 'Budget|Builtin' ./internal/gui ok
(TestCoreScriptBudget; budget not raised).
At the pushed head (rebased on 6e9820a3a..d56c14e95, 31da93ccd touched
app.js): view-wheel-after-redraw 25/25, click-scroll 11/11, i18n-keys
4/4, view-wheel-after-click 13/13 in both engines; the Go budget tests
ok (app.js 1,317,342 bytes, budget not raised). The other files above
ran at the base e1709ab42.
Broken by hand: origin/main's laid/redrawn (above, all red); the sticky
check alone removed (scrolls() returning true): the five Settings
subtests go red in Chromium, the Usage and agent ones stay green.
Not tried: real macOS 13 / WebKit 16.6 and a real trackpad; the whole GUI
suite and the Go suite were not run.
zoecats on Discord: a request to one provider (not a group) got a local
relay's short 429 straight back in Claude Code once the few same-one
retries were spent. A group would have held the agent and asked again.
A plain provider now takes the group's replan path (patience.go: replan,
pauseAlive, the held writer) once passing's same-one retries are spent:
its accounts take turns as members do, each pause never shorter than the
Retry-After, and a streaming agent gets keepalives past keepHeldAfter.
- Zero-config: unset, it waits singlePatience, PatienceDefault (60s),
counted from when the agent would have had the error.
- The user's value wins: Provider.Patience, the same values as a group's
Patience, set with `magpie provider set <id> patience=2m|off|default`
(at most 4m). The provider editor has no row for it (no new UI), and its
save keeps it. A group the provider is in keeps the group's own.
- Not retried: a Retry-After past the budget, quota/credit/plan limits,
401/403, refusals, response protection, didNotStream, and an agent
that has gone (499, try marked Gone).
- The try is traced with Again alone, so the Routing page tells it as
"tried again in …".
- codexReset (ChatGPT's 503 for a large request) is left out of the
plain-provider replan, so Codex still gets its 503 with advice.
- Codex's own one-account relay (codexUpstreamOn) does not join. It is
relayed outside the candidate loop, and its backend 429 is always the
plan's usage limit (codexBusy never retries one), so the short rate
limit this waits out doesn't arise there. Its overloads keep
lastRetries and then fallbacks.
longestPause became a var so tests can scale it. Tests updated for the
new count (1 + retries + replanRounds when it never clears):
- TestLastOneLeftIsTriedAgain
- TestRateLimitIsWaitedOut
- TestQueuedStreamFailureIsTheStreamsError
- TestOverflowTheVendorDidntSay
New tests, through the server with a fake upstream and injected
durations, waiting on trace state, not a duration:
- TestSingleProviderWaitsOutAShortRateLimit (stream and whole: 200,
keepalive before the answer, asked twice)
- TestSingleProviderPassesALongLimitThrough (an hour, quota, 401)
- TestSingleProviderAgentGoneInTheWait
- TestSingleProviderOwnPatienceWins (off, shorter and longer than the
default)
- TestPatiencePair (cli)
- TestProviderSaveKeepsPatience (gui)
Broken by hand, each red, then restored:
- singlePatience fallback 0 for a plain provider: WaitsOut stream and
whole got 429, and AgentGone never paused.
- replan's budget check off: PassesALongLimitThrough/an_hour, "magpie
waits to ask again".
- pauseAlive's ctx.Done case removed: AgentGone, "route done false
status 0".
- The gateway ignoring Provider.Patience: OwnPatienceWins off, shorter
and longer all red.
- The GUI save not keeping Patience: TestProviderSaveKeepsPatience,
"patience 0 … want -1 kept".
Run in this tree, before the rebase:
- go test ./internal/gateway ./internal/cli ./internal/gui: ok.
- ./internal/provider: ok with -skip TestUnreadLogins. That test crashes
with "close of synctest channel from outside bubble", the known #3632,
in filememo and not touched here.
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./...: all 0.
- go build for darwin, linux (nogui) and windows: ok.
Run again after rebasing on origin/main 39526c069 (17 commits, 22 files
in gateway/provider/cli): gofmt, go build, go vet on the four
packages, the replan, retry, overflow and Codex-reset tests, and every
new test: all ok. The whole gateway package was not run again there.
Not run:
- The full ./... suite: machine load ~150, other sessions' suites
running.
- A real vendor's 429.
- The GUI suite: no GUI file changed.
gateway-routing's masking paragraph, the pii package comment, and the
site's masking page in en, zh and ja name AstrLink Guard, the default,
and Privacy Filter, and say what the picker beside the switch does.
Run again after rebasing the stack onto f2aa7fe34 (the backend commit now
carries #3682's chunk-at-a-time find, and serve_test.go calls pf.missing):
gofmt clean; go build; GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./... (amd64) and arm64 for internal/pii clean; go test -race
internal/pii/... ok; go test internal/pii/..., masking, redact, settings,
source, gwmw ok; gateway -run 'Mask|Redact|Privacy|PII|Unmasked' ok; GUI
privacy-model, i18n-keys, account-mask, mask-actions 74/74 (both engines).
internal/gui: one -count=1 run red with its log lost, two green; -count=2
red on TestDesktopSubagentModelNotice, which fails the same on origin/main
f2aa7fe34 from its second run on (#3787, Claude Desktop, not touched here).
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):
- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
$PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
magpie writes [providers.magpie] (base_url, client_type, api_key),
one [[models]] entry per magpie model (context_window, vision,
max_tokens, [models.pricing] in usd_per_mtok) and default_model in
Penguin's own inline spelling. Penguin's server reads the file again
when its mtime changes, so no restart; a default naming no entry is
refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
Disconnect restores the user's own default_model (or none), drops a
magpie vision model, and removes the file when magpie made it.
Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
penguin update --yes for the tarball, except on Windows where
update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
value (with child tables) by blocks, or removes them; blank lines
between replaced entries go with them, and an unchanged result isn't
written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
and docs/subsystems/agent-wiring.md.
Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
./internal/agentenv ./internal/appdir ./internal/usage: all ok but
TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
magpie serve and a fake upstream: penguin run -m "Say PONG" answered
"PONG from fake" through magpie (usage agent "penguin",
/v1/responses -> /v1/chat/completions); switching the model in magpie
took effect with no Penguin restart; a no-op sync kept bytes and
mtime; magpie penguin default restored the user's custom/my-own and
left no magpie line; with no prior file it was created 0600 and
removed on disconnect. The fixture is the file Penguin itself wrote.
- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
TestSync', internal/edit, internal/agentenv and the internal/gui
guards ok; gofmt clean.
Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).
Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
joeliu96872540 on X: when one model is reachable through several API
channels, they want an option that sends each request to whichever has
been answering fastest, because they compare channel speeds by hand
today. Speed first (`fast`; `fastest` and `speed` also work) is a new
routing beside Free first. It applies to a provider's keys and accounts
(provider editor › Routing) and to a group of one model on several
providers (Routing page › group › Routing).
How it decides. When a streamed answer ends, gateway/speed.go records two
numbers for that account or key and model (restID): the time to first
token and the output tokens per second, as usage.DecodeOf computes them
for the Requests page. Each is a decayed average with a 20m half-life.
After an hour with no answer the record goes stale, and the store holds
at most 4096 records. This is O(1) at the answer choke point, beside
servedCandidate. For a pool routed by BySpeed, weighRouted reads one map
entry per candidate, and only for that pool. The usage history is never
read on a request.
routes.Fastest ranks each awake seat by its estimated time to a
200-token reply: TTFT + 200/TPS. A seat that reported no TPS gets the
median TPS of the others. Seats within 10% of the fastest in their band
keep their listed order, so near-ties don't swap on every request.
Seats with no recent measurement go after the measured ones. One request
in five, counted per pool, goes first to an unmeasured seat, rotating
among them, so each gets measured again. Resting seats go behind the
awake ones, and used-up seats behind those. Rests and failover are the
same as for every other routing.
The request trace gets lateTtft and lateTps, and the row-story sentence
says "answered m fastest lately: first token in 0.8s, 60 tokens a
second". It has a variant for a probe turn and one for when no seat has
been measured yet. i18n covers zh, zh-TW, ja and de. Also updated: the
CLI (`magpie group|provider set <id> routing=fast`, plus a new
`routing=` pair on provider set that refuses manual), the TUI name, the
rotation plugin's Sub, docs/subsystems/gateway-routing.md,
plugin-runtime.md, docs/reference.md and site start.html (en, zh, ja).
There is no new layout: it is one more item in the existing pickers.
app.js stays under its budget with no raise.
Tests:
- routes/fastest_test.go:
- ordering: fastest first, slow writer loses, alike keep order,
resting and used-up, median pace, none measured;
- the probe turn at 5, 10, 15 and 20, rotating between seats;
- a resting seat never gets a probe turn.
- gateway/speed_test.go:
- decay, staleness and per-model records, with an injected clock;
- a group of slowv and fastv routed fast: after the speeds are
measured and seeded, the request goes to fastv with lateTtft set;
- the same group routed in order still goes to slowv.
- cli: parseRouting and the provider routing= pair.
- GUI routing-speed-first.test.cjs: the row story for measured,
no-pace, probe and none, in en, zh, zh-TW, ja and de, in chromium and
webkit: 40/40.
Broken by hand:
- Fastest returning the listed order: the routes tests and the gateway
group test go red.
- noteTrySpeed removed: "the streamed answer wasn't measured".
- The client.js case renamed: routing-speed-first 0/20 in chromium.
Run at b5a5caff2 (base 5b4dec58e):
- `go test ./... -count=1 -timeout 45m`, alone on the machine, at load
130-230. Every package is ok except:
- internal/provider: TestUnreadLoginsWriteErrorsKeepCredentials
crashes with "close of synctest channel from outside bubble"
(#3632, open);
- internal/gui: TestMainWindowCorners and
TestTrayCellClickReleasedPanel are killed at their deadline under
load (#1936, #2645).
- gofmt -l is empty. go vet is ok on darwin, on GOOS=linux with -tags
nogui, and on GOOS=windows for ./internal/....
- GUI files the change reaches, both engines, every language they test,
all ok: i18n-keys, gui-de, gui-ja, gui-zh-tw, routing-save,
routing-save-keeps-the-row, builtins, panel-routing,
panel-routing-pick, panel-routing-providers, panel-routing-hidden,
routing-key-windows, key-weight, key-weight-fit, group-member-weight,
routing-weight-chip, account-arrange and routing-speed-first (40/40).
- routing-group-strategy was 4/18: the menu now has 9 items and the test
still counted 8. Fixed in this commit; rerun, it is 18/18.
- routing-save-blank (a webkit click timeout) and routing-columns (zh
"side by side") each failed one subtest at load ~200. Rerun alone,
they are 4/4 each. Both are already filed (#1924, #1612).
Rebased on 8f023b511, where upstream changed gateway.go, app.js, client.js,
the routing plugin's i18n.js and gateway-routing.md; the rebase was clean.
At this head I reran gofmt, go build ./... and go vet (darwin, linux
nogui, windows) on routes, gateway and cli, and go test for routes, cli,
provider and gateway (the routing and speed tests) and for gui -run
Budget: all ok. The GUI files i18n-keys (4/4), routing-speed-first
(40/40) and routing-group-strategy (18/18) also passed.
Not tried:
- A real run against several channels of one model. Speeds come from
real answers, so the first minutes after a start are in listed order
plus probes.
- A non-streamed reply is not measured, a sub-millisecond TTFT is not
counted, and a restart forgets every speed.
- The Windows runtime: only go vet ran for it.
From Codex, every call to antigravity/claude-opus-5-5 failed with
"exceeded retry limit, last status: 429" while dsh worked on the same
account. The call was an agent_created_thread, and the vendor said
"Resource has been exhausted (e.g. check quota)".
Cause: a Codex thread begun on a GPT-5.x model keeps "You are Codex, an
agent based on GPT-5..." as its first developer message after /model,
resume -m or a fork, and magpie lifts it into systemInstruction.
Antigravity answers that line with a fake 429, whatever quota is left,
as it does Claude Code's (#666). Codex also sends a web_search tool every
turn, so for an Antigravity model magpie serves search itself (translate
-> searchReply -> askTranslated), and that path passed the bare 429 back:
no hint, no 400, so Codex retried to its limit.
- antigravityTurnsCodexAway: the two Codex GPT-5 opening lines count as
a turned-away prompt; antigravityHint picks the Codex hint for them.
- antigravityRound wraps the search path's ask, so its 429 and an
in-stream refusal get the same 400, hint and no rest as translate's.
- antigravityForeseen returns the hint, so a group skips Antigravity for
the next 6h saying which prompt.
- The Routing page shows the new hint (routing/client.js HINTS) in en,
zh, zh-TW, ja and de.
- Rest: none. The refusal is about the prompt, not the account (Fail
"prompt"); a second account answers the same.
Plugins: middleware-antigravity-cloak 0.1.1 (plugins a52d1b3) breaks
the two Codex lines with U+200B. Its body says "npm had 0.1.0": wrong,
the package is not on npm; dist had 0.1.0 and now has 0.1.1 (6fd1438).
No mover applies.
Real account (owner's Antigravity, sandbox HOME copy, gateway built from
this branch) and real Codex 0.162.1:
- codex exec resume <a gpt-5.5 thread> -m antigravity/gemini-3-flash:
before, 429 retried to "exceeded retry limit"; after, one request and a
400 with the Codex hint; route try (429, prompt), no rest.
- A new Codex chat on the same model: 200.
- The two lines with U+200B after the first letter: 200; whole: 400.
Broken by hand:
- antigravityTurnsCodexAway returning false: the Codex tests go red
(Codex got 429; the group's skip doesn't say why).
- The antigravityRound wrap removed: the search=true subtests go red
("Codex got 429").
Run:
- go test -count=1 -timeout 45m ./internal/gateway/: ok (476s, at
865df2472; main's next three commits touch only GUI files).
- go test -count=1 -timeout 45m ./internal/gui/: ok (230s, at the pushed tree on a6d7e02c7).
- gofmt -l: clean; go vet ./internal/gateway/ for darwin, linux, windows.
- GUI, chromium and webkit: routing-ag-turned-away, i18n-keys, gui-ja,
gui-de, gui-zh-tw, routing-wb-refused, routing-blocked 41/41; at the
pushed tree routing-ag-turned-away, i18n-keys, routing-steps-cap and routing-js 34/34.
- Rebased on b9ab17231 (routing client.js): routing-ag-turned-away,
i18n-keys, routing-free-seat 45/46, the red webkit zh-TW `.rt-day`
click timeout at load 163 (#3781's class); routing-ag-turned-away
alone 20/20 after. go test -run 'Budget|I18n|Hint|Routing' on
internal/gui and internal/gateway: ok.
- Rebased again on 68ee4117a (gateway: gemini_schema, unrouted,
masking wait): gofmt, vet x3, and go test -run
'Antigravity|CodeAssist|Search|Gemini|Unrouted|Masking|Translate|Continu'
./internal/gateway/ ok; the whole package was not run again at this
tree.
- Under load 89-150: TestTrayCellClickReleasedPanel killed at 20s
(#2645), routing-js webkit zh (#3774), panel-routing and
routing-zcode-blocked webkit zh click timeouts (#3781). All pass alone.
Not tried: Claude Opus itself (the sandbox account's free-tier Claude
quota was spent while probing, so gemini-3-flash stood in; the prompt
check is model-blind); the cloak installed in a running magpie; the
Windows box; the full GUI suite.
kthink on Discord: dsh with cua-driver's MCP tools on Command Code's
google/gemini-3.8-flash (the commandcode plugin), every request 400
INVALID_REQUEST from Vertex: "`mcp__cua-driver__drag` functionDeclaration
`parameters.target` schema didn't specify the schema type field."
cua-driver's drag schema before cua's #4888 has target as an anyOf of an
untyped oneOf and null, and scope a const with no type. Command Code's
gateway turns JSON Schema into Vertex's Schema object, whose type is
required, and an untyped node stays untyped.
geminiToolTypes (forwardOnce, so plugin requests too) is keyed on the
model id (last '/' segment starts with "gemini"), not the provider:
each untyped schema under tools' function.parameters / parameters /
input_schema gets the type its enum/const, keywords or branches say,
null left out; {} or a description alone is a string, a tool root an
object. Mixed-type unions, unresolved $ref/unions and anything under
not/if are left as they came. Written in place after the brace, so the
rest of the body is unchanged. withTypes no longer writes a trailing
comma into an empty {} (it produced invalid JSON there).
Google's own Gemini API / Code Assist (parametersJsonSchema) and
Antigravity (plainSchema) bodies have no such tools and are not walked.
Run at this tree, rebased on origin/main 8f023b511 (tests and vet run again there; GOMODCACHE/GOCACHE pinned):
- go test ./internal/gateway/ -run 'Gemini|Kimi|Grok|OneOf|PlainSchema|Tool|LoopGuard|Doc' -count=1: ok
- gofmt -l internal/gateway/: clean
- go vet ./internal/gateway/ (darwin), GOOS=linux go vet -tags nogui,
GOOS=windows go vet: ok; go build ./... for darwin, linux (nogui), windows: ok
- Not run: the full ./... suite (machine load ~200, other sessions' suites).
Broken by hand:
- geminiToolTypes call commented out of forwardOnce:
TestGeminiToolTypesCuaDriverDrag red on chat, messages and responses.
- emptyObjectAt check replaced by true: TestGeminiToolTypes red, invalid JSON.
Tests: TestGeminiToolTypesCuaDriverDrag uses cua-driver's literal old drag
schema (testdata/cua_driver_drag_untyped.json) through the server on
/v1/chat/completions, /v1/messages and /v1/responses; a GPT model on the
same provider gets the tools byte for byte. TestGeminiToolTypes covers the
type rules, and that claude/gpt/gemma/kimi ids get the body bytes.Equal.
Not tried: a real Command Code account or a real Vertex request; the
schema's acceptance by Vertex is from its documented Schema object and
cua's own Vertex lint (cua-driver-testkit vertex.rs), not a live call.
A text over 12 KB was sent to pf-serve whole. On a weak GPU one such
text could take longer than classifyTimeout, so the request failed and
nothing was kept, and every other request waited behind it.
Now find.go cuts a long text into pieces of at most 12 KB (pieceSize).
Each piece overlaps the one before by up to 1 KB, cut after a line's
end where there is one, else after a space, else at a rune's start.
- Each piece is cached on its own, so a request stopped part way and
sent again asks only about the pieces not done yet.
- Spans are shifted to the text's offsets and merged: overlapping
spans become one with the longer one's label, and same-label spans
that touch are joined.
- pf-serve gets one chunk per call. The turn is given up between
chunks, so a short request waiting for the model goes next instead
of after the whole long one.
Run:
- go test -count=1 ./internal/pii/: ok.
- gofmt -l and GOOS=linux/windows go vet ./internal/pii/: clean.
- go test -count=1 -timeout 45m ./internal/pii/... ./internal/gateway/...
at f8b58fb48 (this change on origin/main 865df2472): pii ok 31s,
gateway ok 571s. GOOS=linux/windows go vet of every package without
Wails (88), and GOOS=windows go vet ./...: clean.
- Real model (pf-serve v2 Metal, q8 model from ~/.cache, M4 Pro) on a
96 KB generated text with names, emails, phones and keys, sent whole
and in its 9 pieces: 2208 spans either way, 2206 the same. 2 were
found only whole and 2 only in pieces, none at a cut (model context,
not the split). Pieces took 1.23s against 2.06s whole.
Broken by hand:
- No yield between pieces: TestShortRequestGoesBetweenPieces red.
- No cache put per piece: TestLongTextKeepsPiecesWhenStopped red.
- merge as a no-op: TestMergeAcrossPieces and
TestLongTextFoundAcrossPieces red.
- pieceOverlap = 0: TestLongTextFoundAcrossPieces red (the name cut
in two was not found).
Not tried: a real weak GPU (Vulkan) with a long text, and span quality
on a real PII corpus. The comparison above uses generated text.