Commit Graph
1064 Commits
Author SHA1 Message Date
yetone 8564238065 remote magpie: a model is asked on the API the remote asks it on best (OoopsHh on X)
With another magpie as the provider, Pi's models.json had only codex/*
on openai-responses; an OpenAI key's openai/* and a routing group's
auto/* went on openai-completions, and effort max was turned away there
while Responses takes it.

Cause: the remote's /v1/models gives native_endpoints, every API the
model goes on as it is, in its provider's speaking order (Chat first),
and nothing for a routing group. Here Provider.Native took the first one
the remote magpie provider speaks: Chat, for every model but a ChatGPT
sign-in's (listed on /v1/responses alone). The remote's own choice
(Native: ResponsesFirst or the Base URL's API; a group's GroupAPI) was
lost on the wire.

Now the remote's list (X-Magpie-Drawers) says magpie_prefers, the path
it asks the model on best (provider.PreferredEndpoint). The local magpie
keeps it as catalog.Model.Prefers and Native takes it first for a remote
magpie (RemotePrefers), so every agent wired one API per model (Pi, omp,
droid, dsh, grok, hermes, liveagent through catalog.Model.APIs) asks it
there, and the gateway's usable translates another API's request to it
once instead of to Chat. A user's own API set on the model still wins;
a remote from before says nothing and stays as it was.

Not changed: a Chat request a client sends itself for such a model is
still relayed as Chat to the remote, which decides as it does for its
own clients.

Run (mote, at this tree):
- TestRemoteMagpiePrefersResponses (gateway: two magpies on one
  gateway, a fake vendor that turns away reasoning_effort max on Chat)
  and TestPiAsksARemoteMagpiesModelWhereItPrefers (agent): green; both
  red with the RemotePrefers check in Native and usable turned off
  (openai/* and group/auto on chat, Pi's api nil, a Messages request
  relayed as Chat).
- Two real magpie serve processes in sandbox HOMEs, a fake vendor, an
  OpenAI key there with its Base URL given as Responses, a group auto
  and the first magpie as the second's Remote magpie: Pi's models.json
  has office/openai/gpt-6.2-astra and office/group/auto on
  openai-responses with max, and /v1/responses effort max reaches the
  vendor's /v1/responses for both. The same script at the base commit
  wrote both with no api (the provider's openai-completions).
- At base 9bf5848c1: go test ./internal/catalog ./internal/provider
  ./internal/agent ./internal/cli: ok. ./internal/gateway: two reds,
  neither this change's. TestKeptBodyIsOnlyItsCallers is fixed on main
  by e2e8ea253 and passes at this head. TestOpenCodeGoOwnFreeModel-
  GetsNothingOfOpenCodes is red the same on origin/main 975799a06, 3 of
  3 (#7117). gofmt -l: nothing. go vet, GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: ok.
- At this head, rebased on 975799a06: the tests above, plus the TestPi,
  TestRemoteMagpie, Native, Prefers, Unique and TestKeptBody runs of
  gateway, agent, catalog and provider: ok.

Not tried: the whole gateway package at this head, the full ./... suite (mote stayed at load 30+ with other
sessions' runs, mica's disk is full), a real OpenAI key, and the
vendor's own Chat refusal of max, which a fake stands in for. Pi
itself was not run; its models.json was read.
2026-11-19 17:28:26 +08:00
yetone 72f7c1f41a agents: Nowledge Mem's own AI runs on magpie (xiaomaomiloulou on X)
Nowledge Mem asks for "选择一个 AI" on its first page and in Settings >
AI, and Mem 0.10 has a provider type of magpie's own. Picking a magpie
model for the new agent nowledge-mem now sets it up from magpie:

- Mem keeps its providers in remote_llm.json with each key encrypted, so
  the file is only read. Changes go through its backend (nmem-server,
  127.0.0.1:14242, $NMEM_API_URL when it names this computer), as its
  Settings and `nmem config provider` do: POST /remote-llm/config saves
  provider "magpie" at the gateway's /v1 with agentKey("nowledge-mem")
  and the model, which makes it active and turns the AI on.
- Mem puts temperature, max_tokens and timeout back to its defaults
  when a save leaves them out, so every save sends the provider's own.
- What Mem had is stashed once: the active provider, whether the AI was
  on, and a "magpie" provider the user made, which keeps its key and
  gets its model, base and parameters back. Stepping out activates the
  provider Mem had (unless one was picked in Mem since), removes
  magpie's provider and turns the AI off again if it was off.
- Mem has to run to change it (errMemDown); a sync moves the base only
  when the gateway's port moved. Detected by its config folder or the
  installed app (co.nowledge.mem.desktop). Icon from its icon.icns.

Run (mote):
- go test -count=1 -run 'NowledgeMem|TestEveryAgent|TestListOnly|TestSync|Desktop'
  ./internal/agent ./internal/library ./internal/agentenv ok; -run Icon
  ./internal/gui ok.
- GUI: icon-one-tone, icon-tile, routing-client-icons, i18n-keys in
  Chromium and WebKit, 58 of 59; the red is icon-tile's dim-color, red
  on origin/main since 2649d5d72 (#6759), not this icon.
- Real Nowledge Mem 0.10.121 (free tier) in a sandbox HOME on mote, its
  nmem-server on its own port behind a logging proxy, and a sandbox
  magpie (go build of this tree) with a fake OpenAI vendor:
  `magpie nowledge-mem fakeoa/fake-model` made magpie Mem's active
  provider at the sandbox gateway; Mem's own `nmem config provider test`
  answered "Connection OK — magpie/fakeoa/fake-model", the vendor got
  the request, and `magpie usage` counted it under Nowledge Mem.
  `magpie nowledge-mem default` put openai_compatible/u2 back as active,
  removed magpie's provider, and Mem's test passed on it again.
- That run found NMEM_API_URL dropped as "not an absolute path";
  NotPaths has it now (the AGY sibling is the commit before).

- On 681f2ee7f, then rebased onto 6af38c0ee (internal/gui providers
  only, none of these packages): gofmt -l clean; go vet, GOOS=linux
  and GOOS=windows go vet of ./internal/agent ./internal/agentenv
  ./internal/library ok; the tests above again ok.
- Not run: the full go test ./... suite. mote had another session's full
  suite running and mica's disk is full (323 MB free); it runs on mote
  once that one ends, and a red gets its own issue and fix.

Broken by hand: without the check that magpie's provider is still the
active one, TestNowledgeMemKeepsALaterPick is red; without re-sending
temperature, or sending a key over the user's own magpie provider,
TestNowledgeMemKeepsTheUsersMagpie is red; with NMEM_API_URL out of
NotPaths, TestNowledgeMemOnlyOnThisComputer is red.

Not tried: Mem's window itself (the run used its API and CLI), magpie's
GUI connect row clicked, Windows and Linux (config folder per OS is
from Mem's source, not a real install), a paid Mem plan.
2026-11-19 15:44:48 +08:00
yetone ddc78405cf gateway: a magpie's /v1/models offers Ultrafast where its accounts do
OoopsHh on X: a magpie in Docker could pick Ultrafast on a model, but
another magpie that has it as its Remote magpie provider was offered
Fast alone on that model. The remote's list takes its service tiers from
provider.CodexTiers through codexcat.Entries, and CodexTiers only ever
added "priority". Ultrafast came only from Codex's own catalog, which a
magpie with no Codex beside it (Docker) does not have, and the codexcat
branches for Fast and OwnTier models dropped any tier m.Tiers added.

- CodexTiersWith adds "ultrafast" after Fast where provider.UltraOn says
  the key or account offers it (an OpenAI key's Ultrafast models, a
  provider added by its address on OpenAI's Ultrafast models, a Codex
  account whose live list has it), and on a group where a member does.
  UltraModels is read at most once a list, and only after a model
  already shows Fast.
- codexcat keeps those tiers (withTiers) and names "ultrafast"
  "Ultrafast" when Codex's own catalog doesn't.
- The asking side already sends ultrafast to a Remote magpie
  (RemoteTiers), and the remote already asks a member without it for
  priority (tierMate). Both ends need this version: the remote to list
  it, the local one to read it.

A provider added by its address serving gpt-6.1-sol now lists
Ultrafast in /v1/models, /v1/codex/models and magpie-models.json, as its
editor's CanUltra already said; TestModelsListTiersForEveryClient,
TestRemoteMagpieOffersItsTiers and TestCodexCatalogTiersReachDisk
expect it.

Tests:
- TestRemoteMagpieOffersUltrafast: a relay's gpt-6.2-sol and a group of
  it list "priority ultrafast"; a Remote magpie provider reading that
  list has CanUltra on both, and an ultrafast ask through it reaches the
  vendor as ultrafast. Red on 7d5db0f29 (tiers "priority" alone, no
  CanUltra).
- TestOpenAIKeyUltrafast: an OpenAI key's /v1/models lists ultrafast on
  gpt-6-astra and not on gpt-6-sol, and its trace's order says Ultra
  on the pick (Weighed.Ultra, previous commit).
- tui, codexcat, provider and agent, and gateway's
  'Tier|Ultra|Remote|Fast|Codex' tests: ok on mote.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... and the three builds: ok on mica. gofmt -l clean.

Full suite (both commits; go test -count=1 -timeout 45m ./... on mica,
load ~30 on 12 cores): 99 packages ok. Reds, each filed and none in
code this touches:
- agent TestWSLAgentFolderIsALink (#7150, ~1 in 6 on main);
- dirent's five watch tests (#7031, a busy Mac);
- gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red
  on origin/main);
- gui TestGatewayModeListsNoOwnSessions (#7064);
- sessions timed out at 45m in TestWSLAntigravityLinkedHomeOnce under
  that load (#5451). Run alone with -timeout 90m: ok in 2925s on mica,
  ok in 62s on mote (origin/main 3869aee3b: ok in 54s on mote), so the
  time is mica's, not this change's.

The full suite ran on the base 3869aee3b. After a rebase onto ef997d186
(no files in common), at this head on mote: go build ./..., the three
go vets, tui, codexcat, provider, agent, gui's Budget/Group/Fast/Ultra
tests and gateway's Tier/Ultra/Remote/Fast/Codex tests ok;
group-member-fast, routing-ultra-row, routing-service-tier, gui-de,
gui-ja, gui-zh-tw and i18n-* 50 of 51 (gui-ja's "Gets copies" string,
#7144, on main).
2026-11-19 14:02:17 +08:00
yetone 3869aee3b0 sessions: agy's calls in T3 Code are on Usage → Requests
zzzkl on X: requests from Antigravity in T3 Code weren't on Usage →
Requests, while a plain agy's were.

T3 Code (pingdotgg/t3code, read at 00c6adbd) runs agy for each
Antigravity instance as an ACP server on the instance's own Google
sign-in: `agy acp --gemini-dir <profile> --app-data-dir antigravity-acp`
(antigravityAuthSupport.ts), the profile being
<T3 Code's folder>/userdata/providers/antigravity/<sha256 of the
instance id>, the folder $T3CODE_HOME or ~/.t3 (dev for its dev
server). Those requests go to Google, never through the gateway, and
magpie's agy reader looked only in ~/.gemini/antigravity-cli, so
nothing counted them. agy writes the same transcript_full.jsonl there
as in its own folder (agy 1.5.10 run that way in a sandbox against a
fake Gemini endpoint; the fixture is its bytes).

agyCallFiles now reads every T3 Code profile's antigravity-acp too, and
Found lists agy for those folders, so the read consent covers them.
T3 Code's folder is appdir.T3Code, shared with agent's t3Base.

Siblings: `agy acp` from any other ACP client with the defaults writes
to antigravity-cli, already read (agy acp --help). T3 Code's magpie
instances (Claude, Codex) go through the gateway and are counted there.

Run: TestAgyCallsInT3Code (default folder, T3CODE_HOME, ~/ form) red
on the old calls_agy.go/access.go with 0 calls, and with Found() =
[claude codex] when only access.go is old; green with the change.
gofmt -l clean; go vet (darwin, GOOS=linux, GOOS=windows) of appdir,
agent and sessions on mote. Full suite (go test -timeout 45m ./..., mica, at 0e3d09361 plus this):
every package ok but agent, dirent, gateway, gui, library and profile;
each red was run again at the base: TestWSLAgentFolderIsALink 2 of 12
red at the base too (filed #7150), the dirent watch tests and
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes red at the base
(#7031, #7117), TestGatewayModeListsNoOwnSessions (#7064) ok alone,
library and profile hung in testenv.warmAt (#5267) and ok alone.
After the rebase on 14b6b9555 (this commit's tree): appdir ok, agent ok
but TestWSLAgentFolderIsALink (#7150), sessions ok (2335s).
Rebased again onto 9768b384e (its three commits touch none of
sessions, agent or appdir): go build ./... and the TestAgy/T3 tests
of sessions and agent ok at this commit.
No GUI file is reached (no string, API or page change).

Not tried: a real T3 Code signed in to Google (the profile layout is
from T3's source, agy's files from a real agy acp); T3 Code in WSL;
a plain agy with its own GEMINI_HOME/--gemini-dir. The calls count as
agy (Antigravity CLI), not T3 Code, and the Sessions page doesn't list
these conversations (agy --conversation would look in agy's own folder).
T3's throwaway helper sessions delete their files, so their calls go too.
2026-11-19 11:18:11 +08:00
yetone 06428541ac agent: Dim's Magpie provider names each model with its provider, so two vendors' DeepSeek are told apart (T_t__biu on X)
T_t__biu on X: in Dim alpha, models of its built-in Magpie provider
can't be told apart by the magpie provider behind them; two vendors'
DeepSeek read the same.

Cause: Dim names a listed model by the display_name (or displayName,
name) of the endpoint's /v1/models (crates/dim-app-server
provider/remote.rs), shown in its Models page, `dima models` and the
picker's search. magpie's /v1/models gives display_name the name alone
(PlainName) to every client but Cindy and Claude Code's discovery.

- /v1/models asked with Dim's key gives display_name the name the
  agents' lists give the model (provider.LabelsFor("dim"): its
  provider's after it, as the Provider in model names setting says),
  as Cindy's already is.
- Dim takes names only when it lists the models again
  (provider.refresh). dim.json now keeps dimListed (a hash of the ids
  and names) of the last listing, and Sync, while Dim's daemon runs,
  lists the provider again when it changed: a provider renamed or
  added, the setting changed, and a Dim connected by v0.1.4497, which
  kept none, on its first Sync.
- A name the user gave a model in Dim (provider.models.edit) is a
  descriptor override, which Dim's refresh keeps. No other provider of
  Dim's is touched; disconnect is as before.

Run at this commit's tree (rebased on origin/main c4bae0724):
- Red on the old gateway.go/dim.go (a Listed field stubbed in):
  TestCindyDiscoveryNamesModelsApart/dim (Dim told "GLM-5.3-Flash"
  for all three providers) and TestDimListsAgainWhenNamesChange (no
  refresh on Sync). Green on the new code.
- Real Dim 0.1.0-alpha.24 (npm dimcode-alpha) in a sandbox HOME on
  mote, a sandbox `magpie serve` on 38741 with two custom providers
  (SiliconFlow, DeepSeek Official) each serving deepseek-v3: after
  `magpie dim sf/deepseek-v3`, `dima models magpie` and the daemon's
  provider.management list "DeepSeek V3 · SiliconFlow" and "DeepSeek
  V3 · DeepSeek Official". After renaming ds/deepseek-v3 to "My DS"
  in Dim (provider.models.edit) and `magpie provider set sf
  name="SiliconFlow CN"`, Dim lists "DeepSeek-V3 · SiliconFlow CN" and
  "My DS" (listed hash moved). `magpie dim default` turned the provider
  off, key cleared, 3425/v1.
- At 4938d8527 (on origin/main c4bae0724): gofmt -l clean; go vet -tags nogui
  internal/agent and internal/gateway, GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok (mote). go test -count=1 -timeout 45m:
  internal/agent ok (265.9s, mote); internal/gateway (mica) ok except
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, red on origin/main and
  filed and taken as #7117 (OpenCode Go/Zen, not Dim). The full ./... suite
  was not run.
- Rebased onto 4e24994a6 (gateway Memory access): gofmt, vet (darwin,
  linux, windows) of both packages and -run 'TestDim|TestCindyDiscovery|
  TestListModels|Memory' ok again at 65cd98fca's tree (mica).

Not tried: Dim's desktop app (CLI and daemon only); Windows and Linux
with a real Dim (the change is in the gateway's list and a refresh call
the Windows pipe already carries); upgrading a real v0.1.4497 connect
(the unit test clears the listing to stand for one).

Not changed: a model the gateway knows no limits of, which magpie gives
them at its pick (provider.models.edit), holds a Dim descriptor
override with the whole entry, its name as listed then (Dim's
merge_visible_edit); a later rename doesn't reach that one model until
it is reset in Dim. One picked under v0.1.4497 keeps its plain name so.
2026-11-19 02:47:38 +08:00
yetone d01e0a465a agent: Dim's built-in Magpie provider is filled in, so a plain dima runs on magpie (T_t__biu on X)
T_t__biu on X: Dim alpha has a provider named Magpie built in, and
magpie's one-click connect left it empty, relying on DIM_* variables a
shell function set for each run. Dim launched any other way (its app, a
terminal opened before, an IDE) was not on magpie.

Dim keeps providers in a database only its daemon writes, so magpie now
talks to the daemon the way Dim's own clients do (JSON-RPC 2.0 after a
hello of protocol 4, on <home>/rust/daemon.sock, or on Windows through
Dim's pipe bridge `dimcode-server app-server --connect-pipe`; read from
Dim's crates/dim-app-server and dim-client source). Picking a magpie
model:
- writes the gateway's /v1 (the port magpie is on), magpie's key and
  enabled onto the `magpie` provider only, each against the record's
  version (provider.update);
- refreshes it, gives a model its token limits when the gateway doesn't
  know them (provider.models.edit), and makes it Dim's pick
  (provider.select against the pick's version);
- records first, in magpie's own dim.json (temp+rename), what was there
  and the pick to give back.
A key or address the user set on that entry themselves is kept: magpie
writes nothing to the provider and only picks the model. Sync writes the
port and key again when they change. Disconnect (`magpie dim default`
or the switch) turns the entry off with the key cleared (Dim clears a
key only on a provider turned off), puts the address back, and puts
back the model Dim was on. No other provider is read or written. The
per-run env and shell function stay only as the fallback when Dim's
daemon can't be reached or started.

Run at this commit's tree (on origin/main d048939da, then rebased over
3 commits that touch neither internal/agent nor the docs here):
- go test -run TestDim ./internal/agent on mica: 8 ok. Red on the old
  dim.go (with a stub for the new test helpers): FillsItsMagpieProvider
  (key empty), MagpieProviderPort, MagpieProviderUsersOwn/key (not
  picked), SyncMovesToProvider.
- Real Dim 0.1.0-alpha.24 (npm dimcode-alpha) in a sandbox HOME on
  mote, with a sandbox `magpie serve` on 38725 and a fake upstream:
  the user's own deepseek provider set and picked first. `magpie dim
  up/m1` left deepseek at v3 untouched, set magpie to on, 38725/v1, a
  key, and picked magpie/up/m1; a plain `dima exec -p` with no DIM_*
  set answered PONG-FROM-UPSTREAM through the gateway. `magpie dim
  default` turned magpie off, no key, 3425/v1, pick back to
  deepseek/fake/known. With a key and address set on the Magpie entry
  by hand first, connect wrote nothing to it (wrote:false) and only
  picked; disconnect gave the pick back and left the entry as set.
- Windows (xiaomi-gpu, real Dim alpha.24 in a sandbox DIMCODE_HOME):
  dimConnect through the pipe bridge did the hello and read the magpie
  provider and selection (a throwaway probe test, not committed).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... on mote: clean.
- go test -tags nogui -count=1 -timeout 45m ./... on mote (suite.lock):
  every package ok (internal/agent 372 s) except 6 reds, each red the
  same on a clean origin/main d048939da copy and already filed:
  internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223); internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117),
  TestLaneLimitRoutes (#5150); internal/gui
  TestSettingsSaveKeepsWhatItDoesNotSend (#7127).

Not tried: a full connect/disconnect on Windows or Linux with a real
magpie serve (only the Windows pipe read); Dim's desktop app (the CLI
and daemon only); a UNC or symlinked DIMCODE_HOME on Windows.
2026-11-19 01:38:23 +08:00
yetone fcbc1a2d02 gateway: Claude Code's deferred tools are declared in full where a load would lose the cache
Seapawn1 on X: GPT in Claude Code loses its prompt cache with tool search
on. A tool ToolSearch loads joined the top-level tools on the next request
on every route but Anthropic's and a Responses upstream that loads in
place (LoadedInPlace, #2660). An OpenAI-style cache is a prefix with the
tools before the messages, so each load (2.1.327 defers WebFetch,
WebSearch, Monitor and the other built-ins too) read the whole
conversation again uncached. A sandboxed Claude Code 2.1.327 through a
fake upstream showed it: on Chat and on a Responses relay the tools
changed at req1 and req3; in place they held.

On such a route a Claude Code request carrying DeferredToolPlaceholder is
answered 400 invalid_request_error naming tools.defer_loading, locally.
The real Claude Code 2.1.327 answers that (after its beta-strip retries,
3 refused requests) by declaring every tool in full for the rest of that
conversation, --continue included; a new conversation, on a Claude model,
tries tool search again. The message doesn't name the beta header, which
Claude Code would remember everywhere. Only while the reminder names 50
deferred tools or fewer: an MCP router's hundreds keep tool search, and a
request whose reminder can't be read keeps it too. Anthropic routes and
in-place Responses upstreams are unchanged. The refusal is not a member's
fault (retryable/shapeRefused false), so a group doesn't fall over or
rest.

Not handled: a user who set ENABLE_TOOL_SEARCH themselves can't be told
apart on the wire; additional-tools=on keeps search on a relay that takes
the item.

Run:
- mica: go test -run 'TestDeferred|TestLoadedTools|TestKimiIsSent|TestToolSearch|TestDeferredToolBlocks' ./internal/gateway ok.
- Broken by hand (the check in translate made false): TestDeferredToolsTurnedAwayWhereTheyLoseTheCache and TestDeferredToolsKeptWhereLoadedInPlace red (status 200, upstream called).
- mica: GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/agent ok; gofmt -l clean.
- wsl-run (magpie-desktop): go test -timeout 45m ./internal/gateway ./internal/agent started before push; result with the full suite.
- Real Claude Code 2.1.327 in a sandbox HOME against a fake 400 naming defer_loading: retried with every tool declared, kept for the conversation and --continue, new conversation searched again.

Full suite: run after push.
2026-11-19 01:13:33 +08:00
yetone 2ab2f69132 agent: Codex's status line shows the account's quota or the relay's balance (opt-in)
lyj1115 on X asked for the current account's quota, or the relay key's
balance, under Codex's chat box, off by default. Codex's TUI draws its
footer from a status line provider from 0.171.0-alpha.12 on: a stdio
MCP server whose tool advertises a statusline entrypoint, picked in
[tui] status_line_provider behind [features] tui_extensions_statusline.
Codex reads it about once a second with the thread's id. Nothing is put
into the prompt or the model's reply.

- `magpie statusline --codex` is that server. Each read asks the local
  gateway for the thread's latest route and the kept quotas (no vendor
  read). It answers `→ provider/model` and that provider's account that
  answered last, with its windows or a key's balance. A gateway that is
  down gives a null tree, never an error, because an error stops Codex's
  reads. The tool's name and words name neither magpie nor a vendor,
  since the tool is listed to the model.
- A status line square on Codex's row (`magpie codex statusline on`)
  writes the flag, [mcp_servers.quota_line] (this magpie by full path,
  args statusline --codex, env_vars = ["MAGPIE_ADDR"]) and the
  provider. Every write is read back, and the file is restored on a
  mismatch. Off and Disconnect take out only magpie's keys, and the flag
  only when the stash says magpie wrote it.
- Nothing of the user's is written over. A provider of their own, a
  quota_line of theirs, the flag turned off or an unreadable file keeps
  the square away and refuses on.
- The switch is offered only when a Codex CLI here is 0.171.0-alpha.12
  or newer (0.170.0 reads the keys and draws nothing), and only on this
  computer, not in a WSL distro.
- In the GUI, the status line square's title takes the note of its
  field's on option, which Claude Code's field already sent with the
  same words TOGGLES kept, so Codex's says its own words in en, zh,
  zh-TW, ja and de. TOGGLES' copy of Claude's note went, and app.js
  stays under its budget (30 bytes of room) without a raise.

The Codex desktop app has no such footer. cockpit-tools reaches it
through a debug port, and magpie doesn't.

Run (WSL magpie-desktop, since mote's load was over 18):
- go vet -tags nogui ./...; GOOS=windows go vet of agent, cli, provider
  and gui; gofmt -l clean.
- go test -tags nogui of ./internal/cli and ./internal/provider: ok.
- ./internal/agent -run "CodexStatus|Statusline|StatusLine|TestCodex|
  TestWSLCodex": ok.
- ./internal/gui -run "CoreScript|Budget|I18n|Keys" and node --test of
  codex-statusline, claude-statusline and i18n-keys (both engines, every
  language, window and panel), with vet (and GOOS=linux and windows
  vet) of agent, cli, provider and gui, on mote at the rebased head
  (on 1bd1a08a3): all ok, 64 of 64 GUI cases.

Broken by hand:
- free() reduced to `readable`: TestCodexStatusLineLeavesTheUsers is red
  on their provider, their server and flag off.
- The field not appended: TestCodexStatusLineSwitch is red ("no
  statusline field").
- The first build checked `at.base == nil` after codexIn had set base.
  Every agent test went red, which is how that bug was found.

Real Codex, in a sandbox HOME on WSL with a fake gateway:
- 0.171.0-alpha.13, with `magpie codex statusline on` writing config.toml,
  draws `→ relay/glm-5  relay $4.20` under the prompt, and the server is
  read about once a second.
- Without env_vars, Codex starts the server without MAGPIE_ADDR: nothing
  was asked and nothing was drawn. That is why env_vars is written.
- On a second time leaves the file byte for byte. Off brings it back to
  what it was, apart from Codex's own NUX counter.
- 0.170.0 lists quota_line from the same file and runs fine.

Not tried: macOS and Windows Codex; a real gateway with real accounts
(the server was fed through MAGPIE_ADDR); whether an open Codex session
picks the footer up without a restart.

Full suite: run after push.
2026-11-19 00:44:40 +08:00
yetone 3438b7bd9c codex: a kept ChatGPT account that runs out is taken over on magpie's models, so the Codex app sends them (Yuzhou__Zhang on X)
Yuzhou__Zhang on X, after updating from Stable (v0.1.3960) to v0.1.4477:
once the ChatGPT account ran out, the Codex app (ChatGPT app) sent
nothing, on "Claude Opus 5.5 · routing group" too, whose Claude accounts
had room. The screenshot shows the app's own banner, "Codex 和工作使用额度
已用完 … 11月20日 16:25 重置", and Send greyed: no request reached magpie.

Cause. The Codex app greys Send for every model while its authMethod is
chatgpt and the account's rate limit says not allowed. magpie gets past
that by becoming Codex's provider while the account is held (codex.out,
#540). a5e3972a7 (v0.1.4224, davezfr on X) left the account the user
keeps Codex on (Switch account automatically off: KeepLogin, or a pick in
the account menu, KeepLoginAs) out of the takeover on every model, so the
app showed the account rather than "magpie". On a model of magpie's that
meant a grey Send till the account's reset, the takeover's whole purpose
undone. Keeping the sign-in says which account; whether magpie's models
wait for it is Always ChatGPT's to say.

Fix. agent/codex.go: out becomes outOn(model). The kept account is still
left beside its sign-in on one of Codex's own models (davezfr's case,
including the takeover's own-model stand-ins, codex.out_own /
codex.out_stand), and taken over on a model of magpie's as any held
account is: by Sync, by a pick (set checks the model picked), and kept
through later Syncs till the reset. Always ChatGPT still keeps it beside
the sign-in. Doc comment in provider/keep_login_as.go and
docs/subsystems/agent-wiring.md say so.

Users already affected: on the next catalog sync after updating, a held
kept account on a magpie model is taken over and the app-server restarted
(AppOut), so Send works without anything to do.

Tests:
- TestCodexKeptOnAHeldAccountSendsMagpiesModel (new): magpie's model
  picked with room, then the kept account held: taken over (magpie the
  provider, AppOut), stays through another Sync and a pick, back beside
  the sign-in at room, and Always ChatGPT keeps it beside. Red on
  origin/main's codex.go ("held, kept: magpie's model left on the held
  account").
- TestCodexKeptOnAHeldAccountShowsIt: now Codex's own model only (the
  magpie's-model half was the behaviour this reverses).
Broken by hand: without the out_own/out_stand check in outOn,
TestCodexKeptOnAHeldAccountShowsIt/Codex's_own_model is red (codex/gpt-a
kept on magpie).

Run (wsl-run in magpie-desktop; mote's load was over 18): go test -count=1 -timeout 45m ./internal/agent ok (642s); go vet ./internal/agent, GOOS=windows go vet, GOOS=linux go vet -tags nogui: ok; gofmt -l clean. Base: origin/main 454f9d023 (rebased onto f1e2ada0f before push, which touches none of these files).

Full suite: run after push.

Not tried: the real Codex app with a real held account.
2026-11-18 23:21:28 +08:00
yetone 589e4ba6da agent: OpenCode finds magpie's models itself; opencode.json no longer lists them
chawyehsu on X asked for dynamic model discovery, as
yuhp/opencode-models-discovery does. magpie wrote its whole catalog into
opencode.json's magpie provider. For an OpenCode that loads plugins of
today's shape (1.4.0 and later, 2.0.5 and later; openCodeDiscovers),
the provider now has no "models". magpie writes plugins/magpie-models.js
beside the file (opencode_models.js, marked by its first line). It fills
the provider's models as OpenCode starts, from the gateway's new
/v1/models?format=opencode (opencode2 for OpenCode 2;
gateway/opencode_models.go). That endpoint gives the same entries a sync
would have listed, in magpie's order, never cached, and only the
models of OpenCode's catalog the key asking may use (keyListed).

- OpenCode 1: through its config hook, which runs before it reads
  providers. The user's entries under magpie's provider are laid over
  magpie's, and an id magpie doesn't list stays.
- OpenCode 2: through ctx.model.transform. The config's own entries are
  laid on afterwards by OpenCode. Every entry says variants ([] for
  none), so OpenCode makes up none.
- Gateway not answering (3s timeout): the plugin lists the models magpie
  had when it last wrote it.

Existing users: the first sync on such an OpenCode takes magpie's list
out of the file (modelsLeft). Of each model, only what the user said
differently stays: their own variant, or a limit.output they typed. A
limit or cost they changed stays whole, since OpenCode 1.19.6 refuses
one without its context ("Missing key ...limit.context"). An id magpie
no longer lists goes that once (stash opencode-discover:<path>), as it
did on every sync before; one added after that is the user's and stays.
The user's other keys and providers are untouched. These keep the list
in the file as before: an OpenCode older than those versions, of no
known version, and the forks (mimocode, DevEco, Air). Going back to
such an OpenCode writes the list again and removes the plugin, and so
does taking magpie out. A file at the plugin's path without magpie's
first line is the user's and is never touched.

Run:
- mote-run go vet ./internal/agent ./internal/gateway, also with
  GOOS=linux and GOOS=windows: clean. gofmt -l: clean.
- mote-run go test ./internal/agent -run
  'OpenCode|OpenChamber|Air|DevEco|Mimo': ok (TestOpenCodePluginRuns runs
  the plugin in node against a stubbed gateway, up and down, v1 and v2).
- mote-run go test ./internal/gateway -run 'TestOpenCodeModelsList|Models': ok.
- Broken by hand, each red: no key filter (TestOpenCodeModelsList),
  openCodeDiscovers always false (Finds/ListMoves/DiscoversFrom), the
  delta keeping whole models (ListMoves), and the plugin letting magpie's
  fields win over the user's (PluginRuns).
- Three opencode_v2 tests that check the listed words now pin 2.0.4 and
  1.3.9, which still list.
- Real OpenCode on mote in a sandbox HOME, opencode-ai 1.19.6 and
  @opencode/cli 2.3.2. Config and plugin written by magpie's own code, a
  fake /v1/models serving one extra model:
  - `opencode models` lists the served model with the gateway up, and
    the cached list with it down. Both versions, Bearer key sent.
  - A file moved from 1.3.9/2.0.4 with a user limit.output and a user
    model: `opencode models magpie --verbose` (1.19.6) and
    `opencode api --standalone GET /api/model` (2.3.2) resolve magpie's
    models the same as the old full-list file did. Names, limits,
    variants and the user's edits are identical; 2.3.2 orders a model
    the file names first.
- Full suite: mote-run go test ./... -timeout 45m -count=1 on this change over base 1bfa8d5a1: 103 packages ok, no FAIL.
- Rebased on 7300be4d0 (main touched agents.go and gateway.go): go vet
  darwin/linux/windows of internal/agent and internal/gateway clean;
  go test ./internal/agent ok; ./internal/gateway red only in
  TestSearchQueueKeepsCodexAlive/comments and /cancel at load ~37, the
  idle-bar class of #7090 (commented), 5/5 ok alone at this head.
- Not changed: the forks mimocode, DevEco and Air keep the list; filed as #7055.
Not tried: a WSL distro's OpenCode, and OpenChamber's own UI over the
plugin-filled provider.
2026-11-18 19:47:19 +08:00
yetone bfddc9cfba routing: DimCode's requests read as DimCode, with its mark, by key too
Yayoi_no_yume on X, a Docker magpie (v0.1.4350): DimCode (dimcode.dev)
on another computer, calling with a gateway key named "Magpie", drew
the Routing page's client node as the cube and "Magpie", and the
request's story said "DimAgent asked for the routing group Step 5
Preview".

Two causes:
- DimCode was no client magpie knew, so usage.AgentOf named it by its
  product name: npm's dimagent 0.5.29 sends "DimAgent/<version>" to a
  provider set to send its identity (resolveDimOAuthIdentityHeaders)
  and "DimCode/<version>" otherwise (read from the published binary).
  A client "dimcode" (DimCode, UA dimagent/dimcode) now names it,
  apart from the Dim alpha magpie starts ("dima"/"dimcode-alpha" stay
  Dim's, by name first). Its icon is dim-color: dimcode.dev's favicon
  (dimagent-favicon.svg, "Official DimAgent mark") is the same artwork.
  Routes and ledger records kept before are named again through
  AgentOf (Route.routedAgain), so old "DimAgent" rows read as DimCode.
- A keyed request's node read the key's name alone (eadc6cdb9, for a
  script's key behind "Python-urllib"). An agent magpie knows now
  reads "agent · key", as Usage's ledger rows already do; a script's
  key keeps the key's name alone. The tooltip names the agent once.
  The tray panel's stage and rows share callerName and read the same.

The icon comes from the embedded assets, which the web (Docker) build
serves the same way; the GUI test checks the image loads.

Run on mote:
- go vet ./internal/agent, GOOS=linux -tags nogui and GOOS=windows:
  ok. go test -count=1 ./internal/agent ./internal/usage: ok (agent 463s, usage 124s)
- TestDimCodeByUserAgent is red with the dimcode entry taken out
  (AgentOf("DimAgent/0.5.29") = "DimAgent").
- GUI, chromium and webkit, every language, 1100 and 420:
  routing-agent-with-key.test.cjs (new), i18n-keys, i18n-en-no-cjk:
  30 of 30 pass. Earlier, on mica, with the same client.js: the 28 other
  files that read callerKey, .rt-src, .ps-name/.ps-ag or .pr-who pass
  but api-key-usage (#7083) and usage-ledger's return-to-live case
  (#5048), both red on origin/main 2416beed6 too.
  routing-agent-with-key is red on the old client.js ('Magpie' for
  'DimCode · Magpie').

Not tried: a real DimCode against a real Docker magpie; the
User-Agents come from the published binary and the reporter's log.
2026-11-18 18:03:16 +08:00
yetone 3e66d25d84 agent: OpenCode's limit keeps models.dev's context and input apart
Nepsama1337 on X: magpie 0.1.4414 wrote gpt-6.2-sol into OpenCode's
config as limit {context: 922000, output: 128000}. models.dev gives
{context: 1050000, input: 922000, output: 128000}. magpie's
catalog.Model.Context is the prompt window, so it prefers models.dev's
input, and the opencode shape wrote that number as context and
dropped input.

What OpenCode reads, checked in anomalyco/opencode on dev:
packages/schema/src/config/provider.ts and
packages/core/src/v1/config/provider.ts take limit {context, input,
output}. session/compaction.ts uses min(input, context) when both are
there. OpenCode 1's models.ts (8df09abb1) has input too, and its
compaction uses limit.input || context - output.

catalog keeps the whole window that models.dev pairs with each input
cap (WholeOf, voted the same way as the windows and looked up through
the same renames). The opencode shape now writes {context: whole,
input: prompt window, output} when the catalog gives a wider whole
window, and {context, output} as before otherwise. A user's own
context for a model (Contexts) has no pair, so it stays a plain
context. This shape serves OpenCode 1 and 2, MiMo Code, DevEco, Air
and OpenChamber. OpenCode 2's converter copies limit whole, so input
reaches it too.

Agents with one window field (Crush's context_window, droid, Cline and
the rest) get the prompt window, which is right for them. ZCode and
MiniMax Code also write {context, output}, but their schemas can't be
checked: #7060.

Run:
- TestOpenCodeLimitKeepsContextAndInput is red on the old agents.go
  (relay/gpt-6.2-sol: limit {"context":922000,"output":128000}) and
  green with the fix. It covers the paired model, a model with no
  input cap, a user's own context, and openCodeNative.
- go test -run 'TestOpenCode' ./internal/agent on mote: ok.
- Real OpenCode 1.19.5 on mote, sandbox HOME: `opencode models magpie
  --verbose` lists gpt-6.2-sol with limit {context 1050000, input
  922000, output 128000}.
- Full suite, go test -timeout 45m ./... on Linux (magpie-desktop, at
  48fffb60c plus this change; mote and mica were over their cores):
  every package ok except internal/usage's
  TestRequestStateKeptAcrossACatalogFetchedAgain, red on the old code
  too (#6572). The three GUI-linked packages need -tags gtk3 there:
  . and internal/cli ok; internal/gui's TestClipboardReadBack
  segfaults under WSLg (#7074), the rest ok.
- go vet ./... on Linux (-tags gtk3) and on Windows: ok. gofmt -l:
  clean.

After rebasing onto 1318864d1: internal/agent and internal/catalog ok on Linux.

Not tried: a real OpenCode 2 run (its schema was read from source),
ZCode and MiniMax Code (#7060), and the macOS full suite.
2026-11-18 16:51:14 +08:00
yetone 3ec89c5224 codex: the takeover's end waits for the chats on magpie the Codex app has open (milianxinqi on X)
milianxinqi on X, the Codex app: "Model provider mismatch. This chat uses
magpie, but your current provider is OpenAI. Switch to magpie to
continue." ("用的好好的,codex 突然就弹这个了"), with nothing disconnected.

Cause. With the ChatGPT account Codex is signed in to held (out of its
allowance and credits), magpie is Codex's provider (the codex.out
takeover, #540) and new chats start on magpie. When the account has room
again (its window's reset, a switch to another account, or the account
the user keeps Codex on, a5e3972a7), Sync ended the takeover at once:
model_provider out of config.toml, Codex back on OpenAI. The Codex app
keeps the app-server the takeover started (codexAppStep leaves it
running unless Restart the Codex app to follow is on, off by default,
#4550), with its chats loaded and each one's writer lock held, so
bringBack could move none of them and codexRetagOpenThreads never ran
(it runs only before magpie ends the app-server). Every send in an open
chat then met the mismatch, with no step of the user's.

Fix. outStays (agent/codex.go): the takeover's end in Sync, both the
out_own way back and #540's, waits while a Codex holds a chat on magpie
open or wrote to one in the last minute (codexHeldOnMagpie:
sessions.CodexThreadsBusyOnBut, T3 Code's own threads left out, as
codexRetagOpenThreads leaves them), and codexThreadsLater asks for the
Sync that ends it once they are let go; bringBack then moves them onto
OpenAI. Meanwhile magpie serves them on the account, which has room, and
the app on the takeover's app-server shows no account either way. Nothing
waits when the app-server is restarted for the change (Restart the Codex
app to follow on, provider.CodexRestartsApp) or the user turned the
takeover off (Always ChatGPT): that restart moves the open chats first.
The [model_providers.magpie] table already stays after a Disconnect, so
an old thread still opens; a deliberate Disconnect restarts the
app-server (byHand) and retags its chats.

Other paths looked at and left: Disconnect, Unwire, Join and Codex's
account switch go through the same bringBack/retag; RestoreOnQuit (off by
default) runs at quit only; the update restart hands the gateway over on
macOS and Linux and skips it. On Windows a restart runs RestoreOnQuit
when it is on: filed separately.

Tests:
- TestCodexTakeoverWaitsForTheOpenChat (new): takeover, a chat on magpie
  quiet but its lock held, account back: still magpie's provider, the
  chat on magpie, no Sync asked; lock let go: a Sync asked, which ends
  the takeover and moves the chat to openai.
- TestCodexTakeoverEndsAtOnceWhenTheAppFollows (new): with the app
  restarted for the change, nothing waits.
- TestCodexTakeoverThreadComesBackOnceQuiet (nb5p): now the takeover
  stays while the thread is written to, and ends at the later Sync.
Broken by hand: outStays' gate taken out of Sync: the new test and nb5p's
red ("Codex was put on OpenAI under it"), green with it.

Run (mica, mote over its load, at this tree on origin/main 48fffb60c):
- go test -count=1 -timeout 45m ./internal/agent ./internal/sessions
  ./internal/provider: ok (426s, 1917s, 237s).
- go vet of those on darwin, GOOS=windows, GOOS=linux: ok. gofmt -l clean.
- Rebased onto origin/main a2d402afe (provider and sessions changes
  elsewhere): go build ./..., go vet of the three, and the takeover,
  thread-move and retag tests of internal/agent and internal/sessions
  again: ok.

Not tried: the real Codex app through a real reset (needs an account
held then given room); a full ./... run (mica had another session's full
suite and GUI suite running).
2026-11-18 16:33:04 +08:00
yetone 28430c9b90 gui: magpie's own paths are written with ›
A path through magpie's own screens was written with › in some places
and → in others (11-17 scan, item 18). Every one the user reads is now
›: Settings › Network and sharing, Settings › Privacy, Library › MCP
servers, Providers › … › Use it anyway, Settings › Usage, in the GUI and
in the Go errors and notices that reach it, in every language. The GUI
matches errNotAsked by its prefix, so it still finds it.

Left as they are: gateway errors written for agents, AiHubMix's and
Claude Desktop's own menu paths (their apps' words), the image MCP tool
description (it goes to agents), and comments.

Own tests: chatgpt-usage-why, websearch-places, library-mcp-hub,
i18n-keys; Go: internal/library (TestPrivateRepoInstallsWithToken, red
on the first try because skills.go still had →), internal/plugin
(notplugin_test), internal/pii, internal/provider.

Run (mote, Chromium and WebKit, en zh zh-TW ja de):
- before the rebase, 23 GUI files: every one green except
  plugin-provider-options (my bug, fixed in this branch before the push)
  and settings-groups' "warm-ups and check-in in each service's provider
  editor", red the same way at fresh origin/main 98c487d09 (an extra
  "Spend extra usage" row; #6597, commented with the sha).
- rebased on origin/main 98c487d09: advanced-headings,
  plugin-provider-options, i18n-keys, routing-advanced, provider-prefs,
  settings-search, panel-profiles, builtins, chatgpt-usage-why,
  provider-concurrency, websearch-places, library-mcp-hub all green;
  go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS' ok;
  ./internal/library, pii, plugin, provider and access ok; go vet ok.
  No budget raised.

Again at the pushed head, rebased on origin/main 39c5040d7 and 07d19510f
(mote, Chromium and WebKit, every language): advanced-headings,
plugin-provider-options, i18n-keys, routing-advanced, provider-prefs,
settings-search, panel-profiles, builtins, chatgpt-usage-why,
provider-concurrency, websearch-places, library-mcp-hub, codex-client,
codex-client-editor and nav-timeout all green; go test ./internal/gui
-run 'TestCoreScriptBudget|TestI18n|TestCSS' ok; ./internal/library, pii,
plugin, provider, access, ghtoken, davsync and gwmw ok, and the gateway
and agent tests whose strings changed; gofmt -l empty; go vet,
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./internal/...
clean. (GOOS=linux go vet ./... without nogui stops in Wails' cgo-only
webview_window_linux.go, the same on origin/main 39c5040d7.)

Not tried: the real app window, and Linux/Windows runs (cross-OS go vet
only).
2026-11-18 14:32:44 +08:00
yetone 3b74aaf12c agent: Claude's auto-compact window is held to the 1000000 Claude Code takes
ZeroX2017 on X (0.1.4404): a compaction threshold of 1048576 typed for
Ollama Cloud's 1M DeepSeek went into ~/.claude/settings.json as it was.
Claude Code 2.1.316's settings schema (and Claude Desktop 2.7032's copy
of it in app.asar) takes autoCompactWindow as an int of 100000 to
1000000 and reads a larger one as none, so a new Claude App session ran
that model at the top-level 272K for every model.

Every auto-compact window magpie writes for Claude Code is now held to
1000000 (claudeCompactCap): the per-model modelSettings entries
(claudePlan), the top-level autoCompactWindow, and
CLAUDE_CODE_AUTO_COMPACT_WINDOW. An entry the hold makes equal to what
the model runs at anyway is left out. The threshold in magpie stays as
typed; Codex and Grok Build get it unheld; tune's card still reads the
top-level value back as Long conversations at the typed value
(claudeLongWindow compares against the held value). agent-wiring.md
says so.

Tests: TestClaudeCompactHeldToClaudeMax (Desktop entry, a second sync
rewrites nothing, magpie's threshold unchanged, the variable when
Claude Code is alone, Codex unheld), TestClaudePlanHeldToClaudeMax,
TestClaudeTopCompactHeldToClaudeMax (top-level + tune read-back).

Run:
- Full suite, go test ./... -timeout 45m -count=1 on mote at base
  afabb7f90: exit 0, 103 packages ok, no FAIL/panic/timeout in the
  kept log.
- Rebased on origin/main 07d19510f (11 commits, GUI and
  internal/library only, nothing in internal/agent): go test
  ./internal/agent ./internal/library -count=1 ok on mote;
  GOOS=linux and GOOS=windows go vet ./internal/agent ok; gofmt -l
  clean.
- Broken by hand: claudeCompactCap made a no-op, all three new tests
  red (entry 1048576, top-level 1048576).

Not tried: a real Claude App session with a 1048576 threshold; the
schema bounds were read from Claude Code 2.1.316 and Desktop 2.7032's
bundled source.
2026-11-18 14:32:09 +08:00
yetone e1e454398e agent, gateway: the web search path is Settings › Models › Web search
dsh's and DS Bot's "nothing to search with" notices, and the gateway's
"searcher picked in Settings" errors, sent people to Settings › Web
search. There is no such tab: Web search is a section of Settings ›
Models. The notices in every language, the gateway errors, the DS Bot
docs page (en, ja; zh says no path) and the subsystem docs now name the
real path. llms-full.txt, the search indexes and docs-index.sums are
rebuilt with `node docs-index.mjs`.

Run (mica, at this tree):
- go test ./internal/agent -run 'Dsh|Dsbot|Notice': ok
- go test ./internal/gateway -run Search: ok
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS|Search': ok
- site: node --test search.test.mjs: 6 pass
- GUI: i18n-keys.test.cjs: 4 pass

Not broken by hand: a text change, with no test that names the path.
Not tried: the real app window.
2026-11-18 12:28:47 +08:00
yetone fefe3f658c library: DS Bot gets MCP servers, skills and instructions in its own DSH home (#5897)
sunset on Discord: DS Bot (ds-bot) can be given a magpie model, but the
Library's MCP page offered no DS Bot. It had no target in targetOf and was
listed "not looked at (#5897)" in noLibrary.

DS Bot's desktop app runs its own DSH (0.2.2-rc.1 in DS Bot 0.3.8) with
DSH_HOME at its data folder (agent.dsbotHome; app/src/main.mjs) and boots
the profile ds-bot (app/src/profile.mjs) with dsh-base's bundles. Read
from github.com/Fei2411/DS-Bot and the npm packages at 0.2.2-rc.1:
- dsh-agent-instructions reads $DSH_HOME/AGENTS.md (then CLAUDE.md);
- dsh-skill-filesystem reads $DSH_HOME/skills and ~/.agents/skills, and
  a project's .agents/skills;
- dsh-mcp-client is in the app's installation (a dependency of
  @deepseek-ai/dsh in app/package-lock.json), so a patch list's insert
  row naming it loads, as in dsh; DS Bot's own bundle patch disables
  none of these.
So ds-bot gets dsh's target on its own home: AGENTS.md, skills, and
MCP rows in every profile's patch list (agent.DshPatchFiles, which globs
profiles/*/cordis.patch.yml, profiles/ds-bot's included). It reads
~/.agents/skills too (readsShared) and .agents/skills in a project.

#5624: when DSH_HOME names DS Bot's folder, the dsh agent's home is
DS Bot's. The Library's dsh target now steps back there
(agent.DshAppHome), so the two agents' rows are never written into one
patch list under two names. This doesn't fix #5624's model wiring.

Run (all at 3b47e8745 rebased on efcf8d9c0, on mica since mote was
over its cores):
- go test -timeout 45m -count=1 ./internal/library ./internal/agent: ok
- GOOS=linux and GOOS=windows go vet ./internal/library ./internal/agent: ok
- gofmt -l internal/library internal/agent: clean
At the first base (4f94b8a82, on mote): the same go test and vet ok,
and node --test internal/gui/tests library-mcp-*.test.cjs,
library-all and library-gone-agents in Chromium and WebKit: 330 of 330
pass. No GUI file changes here; the page lists agents from the API.

Broken by hand: renaming the ds-bot case turned TestDsbotLibraryTarget,
TestDshNotOnDsbotHome and TestEveryAgentInLibrary red; dropping the
DshAppHome check turned TestDshNotOnDsbotHome red.

Not tried: a real DS Bot app loading the server (no DS Bot install on
the test machines); Windows and Linux runs of the package.
2026-11-17 21:31:45 +08:00
yetone 8e1534f5f9 sessions: read LiveAgent's sessions (#6741)
Usage › Sessions and the Sessions page now list LiveAgent's sessions
with their title, time, model, tokens and cost, and show their
conversation.

- Where: K-brain keeps each session at
  <root>/sessions/<project>/<id>/session.jsonl (older ones right under
  sessions/). sessions/.runs and sessions/.deleted-history are skipped.
- Root: $LIVEAGENT_HOME, then $K_BRAIN_HOME, then
  ~/.liveagent/data-dir.json, then ~/.liveagent. The rule now lives in
  sessions.LiveAgentDirIn, and agent.liveAgentDir calls it, so it has
  one owner.
- Reading: K-brain rewrites the file whole, so it is parsed whole. The
  first line is session_meta (id, title, cwd, running totals).
- Tokens:
  - Each reply's own usage counts on the day it came back.
  - What the totals (model_usage, else usage_in/usage_cached/usage_out)
    hold beyond those replies, such as a compaction's call or a rewound
    reply, counts on the last message's day, together with sub_usage.
  - Cache reads and writes are taken out of prompt_tokens.
- Forks: a fork's copies of its source's messages (seq <= fork_seq) are
  the source's, and count in neither the fork's messages nor its totals.
- Subagents: a subagent's own session (task-<parent>-<task>, task_id
  set) is filed under its parent with its activity, but no tokens,
  because its spend is the parent's sub_usage already.
- Not added:
  - a Calls reader: the gateway's own record of LiveAgent's calls
    carries no session id, so it would count them twice;
  - resume and delete: LiveAgent has no resume command.
- Skills: SkillsManager read (skill://<name>/SKILL.md) and Read of a
  skill path are counted.

Run (mote, mote-run, at d67ccbd3c plus this change before the rebase):
- go test -count=1 -timeout 45m ./internal/sessions ./internal/agent
  ./internal/library ./internal/agentenv ./internal/gui: all ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: clean.
- TestEveryAgentSaysItsSkills has liveagent →
  TestLiveAgentSessions.

Again after the rebase on 3be322fe4 (mote): ./internal/sessions,
./internal/agent, ./internal/library ok; GOOS=linux -tags nogui and
GOOS=windows go vet ./... clean.

Broken by hand (mote), each red:
- Without parserFor's liveagent case: TestLiveAgentSessions (0 listed)
  and TestLiveAgentTranscript.
- Without subtracting a fork's copies: fork1 tokens 600/140/1000 for
  want 400/40.
- Without subtracting the replies already counted: abc123
  3500/550/2000 for want 2500/350/1000.

Fixtures: the issue's literal session_meta, with its placeholders
filled in (12786068 in, 12455808 cached, 103572 out →
330260/103572/12455808). The message, snapshot and compaction lines
follow K-brain's record types as its source writes them.

Not tried: no real LiveAgent install. The files were not written by
LiveAgent itself, and no real session was read. Imported sessions
(ImportHistory) are listed as they are. No GUI file changed, so no
GUI tests were run.
2026-11-17 20:56:30 +08:00
yetone d67ccbd3c7 agent: a provider named magpie at another machine's address is not this magpie's Alma wiring
Alex on Discord: any provider named magpie in Alma, one pointing at a
magpie on a VPS included, was taken as this magpie's own, and the Agents
page said "Alma no longer goes through magpie, its config was changed".
almaMagpie now takes a provider by the name magpie only when its base URL
is on this machine (onAnotherMachine, as ZCode's check does). One at
another machine's address is the user's own provider and left alone; the
second match, an OpenAI-shaped provider at this gateway, is unchanged.

Run (mote), at base f1a4de736; rebased onto 4f94b8a82, which changes two internal/agent files, and the Alma tests run again there: ok.
- go test -count=1 ./internal/agent/: ok (225.9s)
- GOOS=linux and GOOS=windows go vet ./internal/agent/: ok; gofmt -l clean.
Broken by hand: without the onAnotherMachine check,
TestAlmaMagpieOnAServer FAILs ("a magpie on a server taken for this one").
Not tried: a real Alma with a remote magpie provider; the test uses the
reporter's shape (id vps, name magpie, https URL, set as default).
2026-11-17 20:39:31 +08:00
yetone 4f94b8a829 grok: context_window is the model's window; Long conversations goes in auto_compact_threshold_percent (@xiancrong on X)
magpie wrote Long conversations' compaction threshold into each
[model."magpie/..."] table's context_window. Grok Build reads
context_window as the model's whole window and compacts at a percent of
it: auto_compact_threshold_percent in [model.<id>], else [session]'s,
else 85 (xai-org/grok-build 559751fd:
xai-grok-shell/src/util/config/resolve/compaction.rs,
DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT and
resolve_auto_compact_threshold_percent; GROK_AUTO_COMPACT_THRESHOLD_PERCENT
above all). So a 1M model held to 300K compacted at 255K and never had
its real window.

Now context_window is the catalog's whole window, and where magpie has
it compact (grokCompactAt, the old grokWindow rule: the model's or
provider's threshold, else settings.Working, none under Full window)
goes in as auto_compact_threshold_percent of the window written,
rounded down, at least 1 (grokPercent). None leaves Grok's own 85.
- A table an older magpie wrote with the threshold as its window, on
  record in grok:<path>:windows, gets the whole window back.
- A percent the user set in one of magpie's tables stays: what magpie
  gave is stashed in grok:<path>:percents, and one it has no record of
  giving is the user's (grokOwnPercent). A context_window set by hand
  still stays (grokOwnWindow).
- A [session] auto_compact_threshold_percent is the user's for every
  model, so magpie writes no per-model one over it.

Siblings: Codex (codexcat) already writes context_window and
auto_compact_token_limit apart, and Claude Code has
CLAUDE_CODE_MAX_CONTEXT_TOKENS beside CLAUDE_CODE_AUTO_COMPACT_WINDOW.
Grok App (grokapp.go) writes the model's own window. Only Grok Build
had the threshold in its window key.

Run:
- At cfca72eaf (this change on f9492fd8e), on mica (mote was over its
  cores): gofmt -l clean; go vet ./internal/agent ./internal/settings,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
  go test -count=1 -timeout 45m ./... ok, go-exit=0.
- At this head, rebased on f1a4de736 (internal/agent changed in
  6abea5f8e): gofmt, vet and go test ./internal/agent
  ./internal/settings ./internal/gui on mica: gofmt clean, vet ok, all three ok (agent 195s, settings 16s, gui 137s).
- Broken by hand: the new tests run against origin/main's grok.go (with
  a shim for grokHadIn) are red: TestGrokWindowIsTheModelsAndCompactsAtThePercent
  (pro 300000, want 1M), TestGrokKeepsTheUsersCompactPercent,
  TestGrokWindowFollowsLongConversations, TestGrokKeepsAWindowSetBeforeTheRecord.
- Real grok 1.0.67 in a sandbox HOME/GROK_HOME: `grok models` and
  `grok inspect` take a table with context_window = 1000000 and
  auto_compact_threshold_percent = 30 with no config warning (a
  misspelt key is reported as "unknown field", so the check sees it).

Not tried: a real Grok conversation running up to the threshold to
watch it compact at 300K.
2026-11-17 20:34:19 +08:00
yetone 6abea5f8e8 agent: Antigravity's app on Windows is found by its installer's registration (JJasonsun on Discord)
On Windows magpie's Agents page showed agy but not Antigravity's desktop
app, which macOS finds right after install. desktopApps["antigravity"]
knew only the macOS bundle, so on Windows the app was found only by
~/.gemini/antigravity/agyhub_summaries_proto.pb, which a fresh install
hasn't written (the Windows box's real 2.30.0 install has no
~/.gemini/antigravity at all).

Google's Antigravity-x64.exe (2.32.1, antigravity.google/download) is
electron-builder's per-user NSIS installer (app-64.7z, SpiderBanner,
package name antigravity). The real 2.30.0 install on xiaomi-gpu is
%LOCALAPPDATA%\Programs\antigravity\Antigravity.exe, registered under
HKCU\Software\121a0be4-63bd-531e-acf8-fc3924c7e984 (InstallLocation) and
its Uninstall entry (DisplayIcon ...\Antigravity.exe,0, DisplayVersion
2.30.0, no InstallLocation). The guid is the UUID v5 of
com.google.antigravity in electron-builder's namespace, as dsh's is. The
entry now has win and guid, so AppVersion reads the registered version
(the 2.15 gate still holds) and HasApp finds the default folder too.
Linux ships only a tarball to unpack anywhere, with no desktop entry of
its own, so Linux keeps the backend-file rule.

Run:
- Windows (xiaomi-gpu, real HKCU and 2.30.0 install, sandbox
  USERPROFILE/HOME/APPDATA/LOCALAPPDATA, PATH without agy): `magpie ls`
  from origin/main's desktopapp.go lists no Antigravity; from this tree
  it lists Antigravity.
- win-run go test -count=1 -timeout 45m ./internal/agent: every
  TestAntigravity* and the new test pass; 36 reds, 35 of them listed
  in #6068 (Windows CI only compiles tests), and
  TestEveryFieldLabelHasTUIZh (Hermes profile labels from outside the
  test home), filed as #6972. None touch desktop apps' detection.
- mote: go test -count=1 ./internal/agent ok; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
  gofmt -l clean.

Broken by hand: origin/main's desktopapp.go with the new test ->
TestAntigravityWindowsAppRegistered red ("guid \"\""; with that check
skipped, "AppVersion \"\"").

Not tried: the gateway wiring again on Windows in this change (031938ca9
ran 2.30.0's language server headless on this box and it resolved its
models from ~/.gemini/config/config.json's gateway); a chat turn from the
real GUI app; Linux; a full go test ./... (mote and mica are near full
disk and loaded).
2026-11-17 20:05:03 +08:00
yetone 7c3e68908f claude-desktop: a model past 200K and under 1M runs at its own window in the Code tab (RQuantum198888 on X)
A GPT set to "Each model's most · 872K" still showed 200K in Claude.
Claude Desktop 5.11492 starts its Code tab's Claude Code with
CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings file, and flag
settings come before the 872000 magpie writes to ~/.claude/settings.json.
ccae8e821 fixed this for 1M models through Desktop's 1M entry and called a
model between 200K and 1M "not fixable": Desktop offers no 1M entry for
one.

Claude Code takes a "[1m]" id for 1M over that variable (peo in aV,
2.1.326), and reads modelSettings.<id>.autoCompactWindow by the id
without "[1m]". So a model past 200K and under 1M that isn't Claude's is
now listed to Desktop by its "[1m]" id whatever DesktopLongest says
(desktopMidWindow), described by its own size ("872K context window",
not "1M"). claudePlan gives it an entry at its own window: the window
the user typed whole, else the working window, as before. A Claude
model keeps its id, since Claude Code knows its window. The gateway
already serves a "[1m]" id as the plain one. desktopPlan's work() treats
it as listed at 1M only when its window is 1M or more, so the full-1M
rule (henglu486729) doesn't apply to it.

Changed behaviour: a user's own modelSettings entry past such a model's
window ("auto") no longer holds CLAUDE_CODE_MAX_CONTEXT_TOKENS to that
window. The model's "[1m]" id doesn't read that variable, so holding it
did nothing for the model and held every other model back.

Run (on 074614077 plus this change; pushed on a9cd746da, whose
last two commits touch only README, site files and internal/bark):
- go test -timeout 45m ./... on mica: exit 0, 103 packages ok, no FAIL
  (log kept whole)
- GOOS=linux, GOOS=windows and darwin go vet ./internal/agent
  ./internal/gateway on mica: ok; gofmt -l: clean
- Broken by hand: desktopListed1M without desktopMidWindow turns
  TestClaudeDesktopLongestOnly (exo-free 872K plain), the new
  TestClaudeDesktopMidWindowRunsPast200K and TestClaudeDesktopContextWindow
  red; claudePlan without the new case turns TestClaudePlan's "[1m] under
  1M" (m:1000000) and TestClaudeDesktopMidWindowRunsPast200K red.
- Real Claude Code 2.1.326 binary against a local fake Messages server, in a
  sandbox HOME, with Desktop's flag settings
  (--settings '{"env":{"CLAUDE_CODE_MAX_CONTEXT_TOKENS":"200000"}}'):
  "/context" on anthropic/magpie-123 with 872000 in settings.json read
  "2.1k / 200k" (the report); on anthropic/magpie-123[1m] with
  modelSettings.anthropic/magpie-123.autoCompactWindow 872000 it read
  "2.2k / 872k", and "/ 272k" with the top-level 272000 alone.
  mythos-magpie-123[1m] runs at 1M the same way.

Not tried: a real Claude Desktop 5.11492 on magpie; the reporter's Desktop
build (no screenshot; the CLI path writes 872000 already, so the Code tab
is the likely surface). The GUI is unchanged. Not changed: a user's own
CLAUDE_CODE_MAX_CONTEXT_TOKENS in ~/.claude/settings.json, which magpie
keeps and the GUI doesn't name. Not broken by hand: work()'s 1M condition
(a 400K model untyped compacts at the working window, not its whole).
2026-11-17 18:27:14 +08:00
yetone c9e8422fa8 agent: a field label with no TUI Chinese fails internal/agent's tests
A new agent field's label with no entry in internal/tui's zh map left
TestEveryWordHasZh red on main twice (e9fcc6229 on 11-15 for
"permission mode", 618bfc1a9 on 11-17 for "subagent pool"), each by a
change that ran internal/agent but not internal/tui.
TestEveryFieldLabelHasTUIZh reads tui's i18n.go and keepAsIs (tui
imports agent) and fails in the package such a change runs. LESSONS and
the code standards' criterion 3 name it.

Run: on mote, go test ./internal/agent: ok (250s). The new test on
Linux (wsl-run) and Windows (win-run): ok. gofmt -l: clean.
Broken by hand: with "subagent pool" taken out of i18n.go, red ("kimi's
field \"subagent_pool\" (label \"subagent pool\") has no Chinese").
2026-11-17 15:09:29 +08:00
yetone 618bfc1a95 kimi: pick Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X)
XiaoLing_Arisa asked on X for Kimi Code's subagent pool (子代理池) on the
Agents page: which models its subagents may run on, and how hard they
think. Kimi Code 2.x keeps them in config.toml's [secondary_model]:
default_model (the legacy `model` stands for it), the pool
[secondary_model.models] ("alias" = "when to use it") and default_effort.

- internal/agent/kimi_secondary.go: three fields, subagent_model,
  subagent_pool and subagent_effort, written the way Kimi Code takes
  them. Its validator refuses a pool that lacks the default, a name with
  no [models."…"] table, and an effort a pool model can't take, so a
  default goes into the pool, a pool without the default gets its first,
  and only the levels every pool model takes are offered
  (kimiPoolLevels). A magpie model goes in only while [providers.magpie]
  is there. Keys are set in place; hints, other keys and comments stay.
  Before Sync or Unwire drops a magpie model table, its name leaves the
  section (kimiPruneSecondary). The default goes back to the user's own
  (stashed at kimi:<path>:secondary) or to the pool's first, and an empty
  section goes. The user's own pool of their own models is never touched.
  kimi-cli (legacy) has no such section. A stopped WSL distro shows none
  of the three, since each reads the config (#3896).
- GUI: the three fields form one Subagents line in the opened row: the
  model, then the effort (disabled until a model is set), then a
  multi-pick pool menu that stays open between ticks. The model's tick
  can't be removed. The picker's note says an unset model runs each
  subagent on the lead's model. The line is drawn by kimisub.js, which
  Details imports before its first slide so the sheet measures it.
- Size budgets +457 (reason in core_budget_test.go). Translations in
  zh, zh-TW, ja and de. kimisub.js is added to old-webkit's list of
  scripts loaded on demand. The Kimi bullet in agent-wiring.md is
  updated.

Run at this tree on mica (mica-run):
- go test -tags nogui -count=1 ./internal/agent ./internal/gui: ok,
  including TestKimiSubagentPool*, TestWSLColdPlaceOpensNothing and
  TestCoreScriptBudget. An earlier run of these packages found the cold
  read and the budget overrun; both are fixed here.
- go vet ./... on darwin, GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. go build: ok. gofmt -l .: empty.
- GUI: kimi-subagent-pool passes 20 of 20 (Chromium and WebKit, 5
  languages, 1100 and 560px). kimi-thinking passes. agent-details-ready,
  old-webkit and i18n-keys have 35 reds, and origin/main ff88ec264 has
  the same 35, all filed: #6373, #6369 (agent-details-ready), #6030,
  #5919 (old-webkit), #6877 (i18n-keys).
- Broken by hand: with Details not waiting for kimisub.js,
  kimi-subagent-pool goes 10 of 10 red in Chromium ("the Subagents line
  is there when Details first draws").
- Real Kimi Code 2.6.2 (npm) in a sandbox HOME with a fake SSE server:
  the pool and effort written here are read and used. A pool naming a
  model with no table is refused when a subagent starts. A bad effort is
  not refused at runtime, but magpie refuses it anyway, as the validator
  does.

Not run or tried:
- The full go test ./... and the full GUI suite: mica and mote were both
  past their load limits with other sessions' suites. Only the packages
  and GUI files above were run.
- A real Moonshot account. The subagent's "timed out" in the sandbox run
  came from the fake server.
2026-11-17 14:30:55 +08:00
yetone 255ccdd7ca omp: a Protocol row picks the API magpie's models are asked on (imty42 on X)
omp's models.yml had magpie's provider on openai-completions with no way
to change it: ompKept treated the provider's api as magpie's, so an api
typed there was written back on the next sync, and omp's row had no
protocol as Pi's has. An auto/* group whose members don't all take
Responses (provider.GroupAPI) could only be asked on Chat.

- omp's row gets the Protocol row Pi has (protocolField, now shared with
  Pi's piProtocolField): each model's own (unpicked, as before),
  openai-completions, openai-responses or anthropic-messages. omp takes
  each for the provider and a model (KnownApi in pi-catalog types.ts and
  the api enum of models-config-schema-bundle.ts, omp 18.9.1). The pick
  is kept per place and agent folder, so each profile has its own.
  `magpie omp protocol openai-responses` sets it from the CLI.
- ompOn puts the provider and every chat model on the pick: Chat and
  Responses with no api of their own and thinking mode effort; Messages
  at the gateway's root with budget, or anthropic-adaptive for a Claude
  that thinks only adaptively. Image models stay on openai-images.
- The provider's api typed into models.yml by hand now stays and shows
  as picked (ompAPIKept, the same api:<path>:wanted record as Pi's); a
  pick made after it replaces it.

Unchanged: unpicked, Responses-native models and groups whose members
all take Responses already went on openai-responses per model.

Run at this head (3d0cadfce, the same tree; only this message differs),
on mote:
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: rc 0. go build, linux
  nogui and windows builds: rc 0.
- go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME
  under suite.lock: rc 0, 103 packages ok, no FAIL.
- Broken by hand: without ompAPIKept, TestOmpProtocolPicked is red
  ("an api typed by hand: file openai-completions, field \"\"").
- Real omp 18.9.1 in a sandbox HOME against a stand-in server: with the
  provider on openai-responses a group model posted to /v1/responses;
  a model on anthropic-messages at the root posted to /v1/messages.

Not tried: the GUI suite (no GUI file changed; the Protocol row is the
generic one Pi's uses, shown for any agent with a protocol field), and
omp against the real gateway with a real auto group.
Not changed: a model's api typed by hand in omp's models.yml is still
magpie's (the model list is magpie's whole); site docs for omp.
2026-11-17 12:46:56 +08:00
yetone 90d7ea9331 agent: a new agent named nowhere in the Library fails internal/agent's tests
TestEveryAgentInLibrary (internal/library) went red on main for a new
agent four times: 399010bef and 68cb92e8e (11-10), 7e8214d60 (11-12),
and effdd1beb today after 00b2c11a6 (Open Code Review). A change that
adds an agent runs internal/agent, and the guard is in another package,
so each was found after the push.

TestEveryAgentNamedForTheLibrary reads internal/library's targets.go and
every_agent_test.go (library imports agent, so it reads the files) and
fails when an agent on this machine's list is in neither a targetOf case
nor noLibrary. The library test still checks a target has something in
it. Same shape as internal/gui's TestEveryRouteIsNamedForTheCLI.

LESSONS.md: the route/setting guard lesson now covers agents, seen a
third day. code-standards criterion 3 names both twins.

Run (mote, at effdd1beb + this change):
- go test -count=1 -timeout 45m ./internal/agent ./internal/library: ok
- broken by hand (open-code-review's noLibrary line removed): red,
  "open-code-review (Open Code Review) isn't named in internal/library";
  restored
- win-run and wsl-run, -run TestEveryAgentNamedForTheLibrary: ok
- gofmt -l: clean
Not run: the full ./... suite (test-only change in one package).
2026-11-17 11:47:18 +08:00
yetone 00b2c11a6b agent: Open Code Review (ocr) is an agent magpie sets up (@AlanWang1027713 on X)
Open Code Review (github.com/alibaba/open-code-review, npm
@alibaba-group/open-code-review) is a Go CLI, `ocr`, that reviews a diff
with a model. Its Claude Code, Codex, Cursor, Kimi Code and OpenCode
plugins and its skills all run that command, which reads
~/.opencodereview/config.json on every run.

Picking one of magpie's models on its row writes a custom provider
"magpie" there (protocol openai, the gateway's /v1, a key naming Open
Code Review, the model) and points provider at it. The user's own
provider and model are stashed and come back on Disconnect, which also
drops a custom_providers left empty. A model of the user's own can be
picked too (written the way `ocr config model` writes it). Check reports
a hand-edited url or key, or a removed entry. The `ocr` command counts
only under a folder named for Open Code Review, since other programs
share the name. WSL distros get the row too (cold distros not opened).
Its User-Agent, open-code-review/<version>, already counts as this agent.
CLI update via npm. Docs, READMEs, site and icon (OCR's own logo,
Apache-2.0).

Run (mica, at 593517bf0; origin/main has one unrelated usage commit since):
- go test ./internal/agent -run 'TestOCR|WSL|Wsl|TestOwnProviderNamedAsMagpies|TestHandWiredMagpieProviderSiblings|TestAgentOf|TestEveryAgentNamedByItsKey|TestMarkedLinesEveryAgent': ok
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- Broken by hand: url dropped from Check -> TestOCRWiring red; stash
  turned off -> red at the Disconnect restore. TestWSLColdPlaceOpensNothing
  went red before the row's options were given an asleep path.
- Real e2e in a sandbox HOME: npm-installed ocr v1.13.10 (7e5ce06c)
  darwin/arm64, magpie built from this tree, a fake OpenAI upstream that
  calls tools. `magpie agents` lists the row with the user's
  deepseek/deepseek-chat; `magpie open-code-review magpie/fake/m1` wrote
  the entry and kept the user's keys and settings; `ocr llm test`:
  connection ok, tool-call round trip verified; `ocr review` on a repo
  with a nil dereference: 2 findings "[bug · high]" through magpie
  (8 /v1/chat/completions calls, UA open-code-review/v1.13.10, model m1,
  its six review tools); `magpie usage` counts them under Open Code
  Review; `magpie open-code-review default` put deepseek/deepseek-chat
  back and removed custom_providers.
- Full suite: not run before this push (ship at once; mote was running
  another session's suite). It runs on mica right after, at this head.

Not tried: a real vendor model behind magpie; WSL and Windows/Linux
machines for real; the Claude Code / OpenCode plugin path itself (it runs
the same `ocr`); an ocr installed by the curl script outside a folder
named for it is found by ~/.opencodereview only.
2026-11-17 11:10:43 +08:00
yetone 593517bf00 codex: T3 Code's threads on magpie stay on magpie (xxxxpouqqs on X)
xxxxpouqqs on X: "t3code 每次重新会话都出现类似于 The 'codex-2/gpt-6.1-sol'
model is not supported when using Codex with a ChatGPT account".

Cause: T3 Code's magpie · Codex instance runs Codex in ~/.codex on
magpie with `-c model_provider="magpie"` alone, so config.toml names no
magpie. At the next Sync, bringBack took every thread on magpie for a
leftover and moved it to the provider config.toml names (openai), in
state_5.sqlite and in the rollout. Codex resumes a thread on the
provider it was started on, so reopening a T3 thread sent magpie's
model id to ChatGPT. codexRetagOpenThreads (the Codex app's app-server
restart) moved locked or loaded ones the same way.

Fix:
- t3CodexRunsIn(home, dir): T3's magpie-codex instance runs Codex in
  this home (no homePath, or one naming it; $T3CODE_HOME honoured; an
  unreadable settings file counts as yes).
- bringBack then moves only threads another client started; a thread
  whose originator is T3's stays on magpie (sessions.CodexThreadsBy
  reads originator and model; a failed read moves nothing).
- codexRetagOpenThreads keeps T3's threads the same way
  (RetagLoadedCodexThreadsBut).

Old threads: a T3-started thread an earlier magpie moved to the
current provider with a magpie model id (one with "/") is moved back to
magpie at the next Sync, for every user; a T3 thread started on OpenAI
with OpenAI's own model stays. Nothing to do but update.

Run (worktree at acc358f07 + this change, on mica; mote was over its
cores):
- go test ./internal/agent/ -run 'TestT3|TestCodexThreads|TestCodexTakeover': ok
- broken by hand (`if false && t3CodexRunsIn(...)` in bringBack):
  TestT3CodexThreadsStayOnMagpie red, T3 threads b1 and b3 on "openai"
  and the rollout moved; restored
- go vet darwin, GOOS=linux, GOOS=windows on agent and sessions: ok
- gofmt -l: clean
- go test ./... -timeout 45m: ok, every package (exit 0, 103 packages ok)
- Real use on mote, sandbox HOME, real T3 Code (t3 serve) + real Codex
  0.169 with a fake upstream: the old magpie moved 5 T3 threads to
  openai and the UI resume hit the ChatGPT endpoint with
  codex-2/gpt-6.1-sol ("not supported when using Codex with a ChatGPT
  account"). With this build the next Sync logged "5 thread(s) T3 Code
  started on magpie moved from openai to magpie", and the same thread's
  resume in T3's UI went to the gateway (gpt-6.1-sol, magpie's key).

Not tried: T3's desktop app (only t3 serve), Windows, a real vendor
upstream, an older Codex whose threads table has no originator column
(CodexThreadsBy fails and nothing moves).
2026-11-17 10:27:26 +08:00
yetone ce16633367 tune: a Codex card locked by config.toml's own compact limit hands it to magpie on a click (sufeng1894 on X)
sufeng1894 asked why Codex's compaction threshold can no longer be set by
hand. The card said config.toml's model_auto_compact_token_limit wins, and
the background row said features.async_compaction's
model_async_compact_threshold_percent wins: both locked, and nothing on
the card did anything about it.

Cause. Only the old tune card (9e665491e to f20118304, 10-10 to 10-28)
wrote model_auto_compact_token_limit, stashing the user's own raw value;
the 10-28 migration puts that raw value back, which then locks the card.
So the values on the screen are the user's, or the user's restored by
that migration. A magpie-written value could have lost its stash through
stash.json races (before 270b52573), an unparsable stash (before
58651568b), tuneMigrateCodex forgetting the stash even when its file
write failed, and codexAsyncSync stashing only after every write. The
last two are fixed here: the migration forgets only after the write
succeeds, and codexAsyncSync records its stash in a defer right after
reading the old state, advancing it per successful write.

Change. A locked card shows one button, "Let magpie set it" (zh 交给
magpie 设置, zh-TW, ja, de), only when the user clicks. POST
/api/tune/takeover (TuneTakeOver):
- the file's limit moves into Long conversations by tuneMigrateCodex's
  rule (a lower Long the user has is kept), the key is deleted from
  config.toml with every other key kept, and the file value is stashed
  (tune.codex.compact_file); Undo puts Long back and writes the key back,
  unless the user changed Long since;
- a background threshold of the user's (enabled = true) is adopted as
  magpie's background share with its own Undo, which turns the share off
  and gives back the percent and enabled as they were. enabled = false
  is not taken.
Nothing removes the user's value without that click.

Run:
- internal/agent, internal/gui, internal/cli, internal/tune at the pushed
  head (rebased on ca87ae9c5) on mica: ok. TestCoreScriptBudget raised
  by 189 (the button, its post and Undo background), reason in the file.
- Full Go suite -timeout 45m on mica at the pre-rebase head (2ba62f7f7
  base): every package ok except TestCoreScriptBudget, since fixed.
- Broken by hand, red: migrate forgetting first (TestTuneCodexMigrateKeepsStash),
  asyncGiveBack disabled (TestTuneCodexTakeOverAsync), longUndo in place
  of codexLongUndo (TestTuneCodexTakeOver), and the GUI button disabled
  (context-tune, 11 red).
- context-tune, compact-one-value, codex-async-compact, i18n-keys at the
  pushed head on mica, Chromium and WebKit, every language, 360 and 1100:
  the new test passes; reds are codex-async-compact's zh/zh-TW "kept the
  share out" (4, the same at ca87ae9c5) and i18n-keys' routing plugin
  word (#6877).
- win-run TestTune|TestCodexAsync in agent and gui: ok. wsl-run vet and
  those tests with -tags nogui: ok. GOOS=windows go vet and GOOS=linux
  go vet -tags nogui: ok. gofmt -l: clean.
- make test-ui on mote, pre-rebase head, through header-centre (about a
  third; the rest still running when pushed): reds in 29 files, none a
  tune file. The first 16 (account-arrange to context-cap) were run
  alone at this head and at origin/main ca87ae9c5 on mica: the same
  reds at both (base has 4 more, in agent-own-direct), the #5475 class.
  The next 13 (ctx-session-line to header-centre) were run the same way at the pushed head: 59 red at head, 60 at ca87ae9c5, the same tests (header-centre's halfway case red in one engine at each).

Not tried: a real Codex session after the takeover; codexAsyncSync's
defer has no test with a failing write.
2026-11-17 06:39:40 +08:00
yetone 8a017b5837 agent: a connect-only plugin whose connect returns only merged objects is connected (plugins#1230)
A connect-only agent plugin is refused with "connect returned no keys to
write" when connect returns nothing. The check counted connect's result
after merged() had taken the plugin's merge keys out of it, so a plugin
whose only keys are objects it lists under `merge` was refused although
those objects' members are exactly what gets written. Lorca's plugin
(plugins#1230) hit it once it dropped its one plain key, changed_at,
which it dropped because unwire left `{"changed_at": {}}` in the user's
credentials.json. Now the merged members count as keys to write.

Run (mote):
- go test -count=1 ./internal/agent ./internal/agentplug: ok.
- go vet ./internal/agent, with GOOS=windows and GOOS=linux: ok. gofmt -l:
  clean.
- A scratch test (not committed) loading plugins#1230's lorca.agent.js at
  883ea48: connect and unwire with no credentials.json leave "{}"; with
  {"anthropic":"k"} and with a file that has custom:gemini and a
  changed_at map, unwire gives the file back as it was.

Broken by hand: origin/main's plugged.go with the new
TestPluggedConnectOnlyMergedOnly: "connect returned no keys to write".

Not tried: the real Lorca app reading the file.
2026-11-17 02:13:18 +08:00
yetone ac4a4cf849 sessions: opening Sessions waits on no WSL listing it already has (shangyuan0818 on X)
shangyuan0818 (X, third round, after v0.1.4091 and v0.1.4255): on Windows,
Usage -> Sessions opened only after a fixed ~20s when sessions were long.
The long sessions were not the cause. Goroutine dumps of the reporter's
case on the Windows box showed four waits on WSL on the page's first asks:

- agent.Looks -> Clients -> All -> wslDistros: a blocking wslRefresh,
  `wsl -l -q` (10s timeout) once its list is a minute old, then
  `wsl -l --running -q` (10s) every time. A WSL that answers slowly but
  answers is never marked hung, so each open after a minute idle waited
  for both: about 18s, every time. ClientsIn drops WSL's agents anyway,
  so Clients now reads only this machine's (local()).
- gui agentsHere (the web-mode own-sessions gate) called agent.All the
  same way. It now calls agent.AllKnown: this machine's agents and WSL's
  as last listed (wslDistrosWithin(0)), never waiting on wsl.exe.
- sessions.wslFilesAs waited wslFirstWait (3s) afresh on each read while
  the first listing was pending, so list, stats and overview each waited
  3s in turn. The 3s is now counted once, from when the first listing
  started.
- provider.copilotCLILogin waited copilotWSLWait (2s) on every re-read
  of a distro's Copilot sign-in, every copilotWSLAge (20s), though it
  had an answer. A re-read now answers the last read at once; only the
  first read waits.

Timed on Windows 11 (xiaomi-gpu), sandbox HOME with a 90 MB Claude JSONL
and a 32 MB Codex rollout, a fake wsl.exe whose -l -q answers "Ubuntu"
after 8s and whose --running hangs; /api/sessions list+stats+overview
together, opened 20s after start, then 70s apart:

  b0674b9ec (old):  0.39s, 18.11s, 18.12s
  this commit:      0.38s,  0.07s,  0.07s

With wsl.exe hanging outright and Sessions opened right after start:
old 10.3-10.5s, new 3s (the designed first wait, now waited once). With
no WSL: 0.4s on both.

Tests, each red on the old code by hand:
- TestClientsAskNoWSL (agent): with Clients back on All(), red (waited
  past 5s on the hung wsl.exe); with AllKnown on wslDistros(), red.
- TestWSLFirstWaitIsWaitedOnce (sessions): four reads with the first
  listing hung; with the wait counted per read, red at 2.007s.
- TestCopilotWSLHangHoldsNoRequest (provider): a re-read on a hung WSL
  with copilotWSLWait 10s must answer within 2s; with the kept answer
  disabled, red at 2.002s.

Run at this tree:
- mote: go test -timeout 45m ./... at dac5095c3 (base b0674b9ec): exit 0, 102 packages ok, no FAIL. Rebased onto
  2ec8e6ad0 after it, which changes README files only.
- mica: go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... ok; gofmt -l clean.
- WSL (magpie-desktop): internal/agent, sessions, provider ok.
- Windows: internal/agent, sessions, provider, gui: 66 reds, 64 of them
  red at origin/main 2ec8e6ad0 too (#6068, #1827, #4115, #2808, #4446,
  #5957, #5343, #5344). The other two, TestHermesProfilesAreNotListedAsAgents
  and TestHermesProfilesFollowMagpieModel, call onMachine, not the code
  changed here, pass alone 3 of 3 on this tree, and follow other Hermes
  tests red at main in the package run (#1841: Windows tests share
  APPDATA).

Not tried: a real WSL distro that is slow (the fake wsl.exe stands in
for it), and the reporter's own machine.
2026-11-17 00:21:23 +08:00
yetone 5ba53b2392 agent: dsh and Pi ask a Gemini 3+ on Messages adaptively, so Xhigh reaches it as xhigh (#6778)
larryhaonlp: DSH's Xhigh on agy-cli/gemini-4-hydrogen through
magpie-anthropic reached agy-cli as high, and a compat
forceAdaptiveThinking: true added by hand in dsh went on restart.

Cause, from the installed sources (dsh 0.2.1-rc.2's and Pi 1.4.0's
pi-ai, anthropic-messages.js and simple-options.js): without
compat.forceAdaptiveThinking pi-ai asks a budget through
adjustMaxTokensForThinking, whose clampReasoning turns xhigh and max into
high (16384), and agy-cli's requestedEffort reads a budget of 16384 as
high. With the switch it sends thinking adaptive plus output_config.effort
from thinkingLevelMap, which agy-cli reads first. magpie wrote the switch
only for Claude that thinks only adaptively and GLM-5.2/5.3.

- gateway.AsksAdaptively is the one rule: adaptiveOnly, AdaptiveWithEffort
  or a Gemini 3 or later (geminiGeneration, the rule geminiLevelBody
  already turns a budget into adaptive + effort by). dsh's dshKindConfig
  and Pi's piModelOn (both cases) use it. Pi now also gets the switch for
  GLM-5.2/5.3, which it lacked (same clamp).
- omp is left on AdaptiveThinking, said in omp.go: its budget isn't
  clamped (ANTHROPIC_THINKING xhigh and max are 32768, read as xhigh), and
  its anthropic-adaptive mode turns thinking off by leaving thinking out at
  the lowest effort, which a model that can stop thinking takes as on.
- The user's own values: dshKeepCompat kept a hand-set switch magpie
  doesn't write, but magpie's own switch won over the user's. magpie
  writes its switches only as true (omitempty), so a false in the file is
  the user's, and now stays.
- The restart: dsh-settings' importLegacyDocument imports
  ~/.dsh/settings.yaml into the profile dsh starts on and renames it
  .imported; magpie writes settings.yaml again with routes that had no
  hand-set compat, so each start of dsh took it out of the profile.
  dshProfilesCompat carries the profiles' hand-set compat into
  settings.yaml's routes, by the same dshKeepCompat.

Existing users: KeepDshWired's sync (30s) and Pi's sync rewrite magpie's
routes, so forceAdaptiveThinking: true lands on a Gemini 3+ there with no
action; a false the user set stays. Pi's models.json provider block is
magpie's own and is written whole, as before.

Run (mote; sandbox HOME):
- go test -tags nogui ./internal/agent -run the new tests and the dsh,
  Pi and omp compat tests (TestDshMaxReachesOutputEffortModels,
  TestDshRefreshKeepsHandSetCompat, TestDshKeepCompatNotAcrossProtocols,
  Pi.*API, Omp): ok
- gofmt -l: clean
- Shipped before the whole ./internal/agent and ./internal/gateway run and
  vet (darwin, linux, windows) finished: it was still going on mote, over
  its cores, and mica's disk was full. A red there gets its own fix or
  issue.

Broken by hand:
- the new tests at origin/main 8608ce024: TestPiAgentsAskGeminiAdaptively
  red (dsh and Pi gemini-4-hydrogen, gemini-3.8-flash; Pi GLM-5.3) and
  TestDshHandSetCompatOutlivesGeminiRuleAndRestart red
- the explicit-false keep taken out: red (hydrogen's false put back on)
- dshProfilesCompat calls taken out: red (settings.yaml lacks the false)

Not tried: a real dsh or Pi run against agy-cli's gemini-4-hydrogen
(the effort agy-cli reads is taken from its requestedEffort source);
omp with a Gemini on Messages.
2026-11-16 21:40:30 +08:00
yetone ccae8e8211 claude-desktop: a 1M model runs at 1M in the Code tab again (fwxkogaia on X)
Claude Desktop 5.11492 (released 11-13) starts its Code tab's Claude Code
with CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings file whenever
the provider routes models itself, the gateway included (Fcn=2e5 and Lcn in
index.chunk-xV3fJhc7.js; 4.16336 had no such value). Flag settings come
before ~/.claude/settings.json, so the window magpie writes there no longer
reached the Code tab, and every model picked by its plain entry ran at 200K,
a 1M one too. No magpie change caused it: nothing in v0.1.4300..v0.1.4322
touched what Desktop is told about 1M.

Claude Code takes a "[1m]" id for 1M whatever that variable says (pT in
2.1.322). magpie's profile now gets Desktop's own "Use 1M wherever it's
available" (modelPrefer1mContext: true, 3p only, Desktop 1.28929+) once, on
a switch on and from Sync, as toolSearchEnabled is (desktopSeedPrefer1M):
Desktop then shows a model it offers a 1M entry for by that entry alone
(D5n: prefer1m on every supports1m entry) and hands Claude Code its [1m] id.
Desktop offers that entry only for a row whose max_input_tokens is 1M or
more, so nothing smaller changes. The user's own value, false too, or their
taking it away, stays theirs. Compaction is as before: the working window,
or the whole window under Full window.

Not fixable this way: a model between 200K and 1M (a 272K or 400K GPT)
still runs at Desktop's 200K; only a managed policy setting comes before
flag settings, and magpie writes none.

Run (mote, at this tree):
- go test ./internal/agent -run TestClaudeDesktop: ok
- TestClaudeDesktopPrefers1M red with desktopSeedPrefer1M returning nil
  ("switch on: modelPrefer1mContext <nil>"), green with it
- go vet ./internal/agent for darwin, linux, windows: ok; gofmt -l: clean
- go test -timeout 45m ./... at base 98955300a plus this diff: exit 0,
  101 packages ok, no FAIL (log kept whole)
Read, not run: Desktop 5.11492.5's app.asar (downloads.claude.ai zip) and
Claude Code 2.1.322's strings, for the 200K and the [1m] rule.
Not tried: a real Desktop 5.11492 on magpie in a sandbox; the Code tab's
/context with the new profile.
2026-11-16 20:25:25 +08:00
yetone e97271f027 agents: a client of a Remote magpie can connect new agents the remote has connected (KoiLx0 on X)
KoiLx0 runs one magpie as a client of another, through a gateway key, and
had to switch every agent on by hand on the client before it took the
remote's models. A Remote magpie's editor now has "Connect new agents to
this remote" (自动接入新 agent) under Advanced, off by default. It is kept
per computer in the stash (remote.<id>.connectAgents), not in
providers.json, so a synced or shared providers list doesn't turn it on
anywhere else. No server-side key permission.

With it on, the follow loop (FollowRemotePicks, every 5 minutes, and at
once when the switch is turned on) connects an agent installed here that
the remote has connected, on the remote's pick (connectFromRemote), and
records it as <agent>.remote.auto = on. An agent the user disconnected
here is never connected again:
- one with the Agents page's Disconnect mark, connected or not before;
- one recorded on that is no longer connected (taken out by hand in its
  file, or by any other route) is recorded off.
An agent magpie put back on quit (quit.restored) is left to RewireOnStart
and not taken for a disconnect. Connecting it by hand records on again.
The follow throttle's time is now under a mutex, since the save handler
resets it from another goroutine.

The switch shows in /api/providers as connectAgents and is saved as
connectAgents (a save that leaves it out keeps it; a provider that isn't
a Remote magpie is refused it). Advanced opens on its own while it is on.
docs/subsystems/providers-accounts.md says all of this.

app.js stays within its budget (TestCoreScriptBudget): the Remote
magpie's three ticks (MCP servers, skills and prompts, agents) and their
save are one loop, which the new switch costs less than it saves.

Run:
- mote, go test -tags nogui -count=1 -timeout 45m ./... with the first
  draft of app.js: every package ok but internal/gui, where only
  TestCoreScriptBudget failed (1087333 > 1086971). After the loop,
  rebased on origin/main 187d06724 (budget passes there alone), at this
  head: TestCoreScriptBudget, internal/gui, internal/agent and
  internal/cli ok.
- mica: TestRemoteConnectsNewAgents, TestConnectFollowsTheRemoteMagpiesPicks,
  TestProviderSaveConnectAgents ok.
- mote: go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go
  vet on internal/agent and internal/gui ok; gofmt -l clean.
- GUI, mica, both engines, at f261f7ba6 (before the loop and the rebase): remote-connect-agents.test.cjs (new: under
  Advanced and closed while off, sent as ticked, Advanced opens on it
  ticked, unticked sent so; en, zh, zh-TW, ja, de at 420px, no sideways
  scroll) passes, with i18n-keys, i18n-en-no-cjk and every file that
  reaches the provider editor's Advanced or a Remote magpie (64 files):
  1738 pass, 26 fail. The same files at origin/main 19794cc10: 1728 pass,
  24 fail, the same reds by name (editor-hints webkit #6156,
  account-arrange #6010, lan-join #6353, vertex-editor #4720,
  remote-magpie #5013, commented with this sha) except name-suffix-remote
  (#5147, red at base too on another language) and one count-free
  browser launch timeout; both files alone: 80 of 80 pass. At this
  head (rebased, with the loop): remote-connect-agents, library-mcp-on, provider-advanced-fold,
  i18n-keys, i18n-en-no-cjk pass; remote-magpie red as at base (#5013);
  editor-advanced-align red once in webkit, 1 of 4 alone (#6421, a
  Claude Code account's editor this change doesn't reach; it was red at
  base in the 64-file run).
- Real use on mica, sandbox HOMEs, this branch's binary: remote R
  (`magpie serve`, Claude Code on gpt-5.4-mini) and a fresh client C
  with Claude Code installed, not connected. Switch off: C's
  settings.json stayed {}. Switch on, C restarted: "agent: Claude Code
  connected as the remote magpie's", ANTHROPIC_DEFAULT_SONNET_MODEL
  office/openai/gpt-5.4-mini, recorded on. `magpie claude default`
  (disconnect) and C restarted: settings back to the user's, recorded
  off, not connected again.

Broken by hand, each red in TestRemoteConnectsNewAgents:
- connectFromRemote returning at once (the old code): "not connected on
  the remote's group/fast";
- without the on-then-unconnected record: "an agent the user
  disconnected by hand in its file was connected again";
- without the Disconnect mark check: "an agent marked disconnected,
  never recorded, was connected";
- without the quit.restored exception: "a quit-restored agent: wired
  false, recorded off".

Not tried: the switch turned on from the real app's window (the GUI test
fakes the API; the save handler is covered by TestProviderSaveConnectAgents
and real use wrote the stash key); agents other than Claude Code for real
(the code is the same ConnectHow for every agent with fields); Windows and
Linux runs.
2026-11-16 17:23:50 +08:00
yetone 19794cc10c serve: a headless magpie follows a Remote magpie's agent picks (KoiLx0 on X)
v0.1.4298 made a client magpie follow the models a Remote magpie's
agents are on (agent.FollowRemotePicks), but only the app's Library loop
(library.KeepLinked) ran it. `magpie serve` and `magpie serve --web`
followed the remote's model list and efforts (the long-poll in the
gateway) and never a pick changed on the remote. Both now run
agent.KeepFollowingRemote, which calls FollowRemotePicks every 30s; it
still asks the remote at most every 5 minutes, and only while a Remote
magpie is added.

Run at this head, on mica:
- go test -timeout 45m ./internal/agent/ ./internal/cli/: ok
- go vet; GOOS=linux go vet -tags nogui; GOOS=windows go vet: ok
- Real use: two sandbox magpies (R with a fake OpenAI upstream and a
  gateway key, C with R as remote-magpie "office"), both `magpie serve`.
  Claude Code connected on R to openai/gpt-5.5: C recorded
  claude.model.remote at start. R's Claude Code moved to
  openai/gpt-5.4-mini at 15:41; C's ~/.claude/settings.json followed
  at 15:45:49 (the 5-minute step). Efforts set on R (low,high) and a new
  upstream model reached C's /v1/models, Codex's magpie-models.json and
  Claude Code's model list within seconds to about a minute, before and
  after this change.

Not broken by hand: the loop is a ticker around FollowRemotePicks, whose
following is covered by remote_picks_test.go.

Not tried: Windows and Linux real boxes.
2026-11-16 15:46:21 +08:00
yetone 10ce59144f claude: a connected Claude Code starts straight into a session (KoiLx0 on X)
KoiLx0 on X: a Claude Code that magpie connected, on a computer where it
had never run, still opened on the theme picker and the sign-in choice.
Claude Code shows its first-run steps while its global config
(~/.claude.json, $CLAUDE_CONFIG_DIR/.claude.json, or a non-empty legacy
.config.json beside settings.json) lacks hasCompletedOnboarding, which
nothing wrote.

- Connecting Claude Code (and a Sync of one connected before) writes
  hasCompletedOnboarding: true into that file beside the user's other
  keys, and records that magpie wrote it (claude.onboarded in the stash,
  per place).
- Disconnecting takes out only the mark magpie wrote, and only while the
  file has no oauthAccount or lastOnboardingVersion of Claude Code's own.
- A file that already has the mark (the user's own first run) is never
  touched; one that can't be read or parsed is left alone (edit.SetJSON
  writes nothing), and the connect still succeeds.
- The Claude launch profile (claude#launch) is left out; it passes its
  own --settings.
- The per-folder trust prompt is Claude Code's and stays.

Run at this head (rebased on 56c988cb5), on mica:
- go test -timeout 45m ./internal/agent/ ./internal/cli/: ok (188.9s, 73.3s)
- go vet; GOOS=linux go vet -tags nogui; GOOS=windows go vet, both
  packages: ok (on mote). gofmt -l: clean.
- Real use: Claude Code 2.1.316 from npm, fresh sandbox HOME, connected
  by a sandbox magpie to a Remote magpie's model. Before: theme picker,
  then security notes, then the trust prompt. After: the trust prompt,
  then a session on "GPT-5.5 · OpenAI · Remote magpie · API Usage
  Billing".

Broken by hand: with the onboard() calls removed, 4 subtests of
TestClaudeConnectMarksFirstRunDone go red.

Not tried: WSL and Windows on a real box (the path comes from the same
place.join as settings.json there); a user signed in to Claude Code with
an account on a real machine (covered by the "own first run" subtest only).
2026-11-16 15:46:15 +08:00
yetone c4d64a70b2 agent: Codex's config holds only keys Codex knows, checked against its schema (#6828)
hatanokokoroyo (#6828) and Nietzsche_Li on X: Codex 0.169 warns on
every launch that `disable_response_storage` is ignored, and
`codex --strict-config` refuses to start, with magpie 0.1.4291.

The key isn't magpie's. `git log --all -S disable_response_storage`
finds it in no commit, and nothing in the tree writes it. Codex removed
it in openai/codex#3212 (0.30.0, 2025-09); magpie's Codex paths assume
0.133 or later, so none needs it. CC Switch wrote it in its Codex
presets until 4.0.28, which stops writing it and clears it on the next
switch (cc-switch#7524), and relays' setup pages still tell users to
add it. magpie's CC Switch import reads only the model provider. Since
magpie can't show it wrote the line, the user's line is left as it is.

So this adds the guard: testdata holds Codex rust-v0.169.0's own
config.schema.json (descriptions, defaults and enums stripped, 86KB),
and TestCodexConfigHoldsOnlyKeysCodexKnows walks it over the config
magpie writes, in place and as the magpie.config.toml profile, from an
empty config and from a CC Switch one, after setting a model, an
effort, subagents and memories and a sync. A key Codex has removed or
never had fails it. A user config holding the line keeps it, once, and
it is the only unknown key.

Run at this tree (mote): go test -run TestCodexConfigHoldsOnlyKeysCodexKnows
-v ./internal/agent PASS; go test ./internal/agent ok; go test . ok;
GOOS=linux and GOOS=windows go vet ./internal/agent ok; gofmt -l clean.
Broken by hand: codex.go writing disable_response_storage beside the
effort: the test went red naming the key; restored, green.
Not run: the whole suite (a test file and testdata only, in one
package).
2026-11-16 15:09:18 +08:00
yetone b9c385286b agent: the disconnect preview reads no sign-ins, so macOS never asks "Keychain Not Found"
jasonz3g on X (macOS, two Claude accounts): clicking Claude Code on the
Agents page made macOS ask "Keychain Not Found — A keychain cannot be
found to store …" (Cancel / Reset To Defaults), dozens of times.

The Agents page loads a disconnect preview each time an agent's box
shows: DisconnectPreview runs Disconnect on a copy, in a subprocess
whose HOME is a temporary folder. Claude Code's Disconnect builds the
model list (buildModels -> CatalogFor -> provider.All -> Accounts ->
rememberLogins -> liveLogin), which read the Claude sign-in with
`security find-generic-password`, and Cursor's too. On a Mac the
keychain is found through HOME, and the temporary one has none. With a
copy of real ~/.claude and ~/.config/magpie, the dry run ran security
three times under the temporary HOME, started Devin's CLI there, and
rewrote held/lapsed in the copy's logins.json.

previewEnv now sets MAGPIE_NO_ACCOUNTS=1, which every keychain read and
write, liveLogin and askClaudeStatus already honour. The dry run of
the same real copy then runs no security and no CLI, and the agent's
~/.claude files come out byte for byte the same as before (diff -r), so
the preview shows the same changes.

Run:
- TestDisconnectPreviewReadsNoSignIns (new), red on the old code
  (security find-generic-password -s Claude Code-credentials ... twice),
  green after; its second half checks the fixture does reach the
  keychain out of the dry run.
- go test ./internal/agent -count=1 -timeout 45m: ok on mica (macOS)
  and on WSL Ubuntu (magpie-desktop); GOOS=linux and GOOS=windows go
  vet ./internal/agent ok; gofmt -l clean.
- Real binary, dry run of `claude` on a copy of real ~/.claude and
  ~/.config/magpie with logging security/claude stubs: 3 security calls
  before, none after.

Not tried: the GUI dialog itself (no display over ssh); the
reporter's own accounts.
2026-11-16 14:45:15 +08:00
yetone b1dd96ab14 agents: a client of a Remote magpie starts its agents on the remote's models and follows them (KoiLx0 on X)
KoiLx0 runs several computers on one remote magpie and had to set every
agent's models again on each of them, and again whenever the remote
changed. Routing groups already reach a client (a group is a model of the
remote's list, TestRemoteMagpieNewGroupServedBesidePicks); the agents'
picks did not.

- The remote tells, per connected agent, each model field's catalog ref
  at GET /v1/magpie/agent-models (gateway.SharedAgentModels,
  agent.SharedModels). Guarded as the Library is: this computer, or a
  full-access key of a magpie shared on the network; a held key is
  refused (readonly_test), and another machine without a key gets 401
  (TestNetworkGatewayGuardsEveryRoute).
- An agent connected here starts on those picks where this magpie lists
  them as <remote id>/<ref> (How "remote", after "again" and "joined";
  the Agents page says "as on the remote magpie", in all five languages).
- A field taken from the remote, or found on its pick, is recorded in the
  stash and follows the remote's change every 5 minutes
  (FollowRemotePicks from library.KeepLinked). A model picked here is the
  user's: the record goes, and the field is left alone until it is on the
  remote's pick again. A pick this magpie doesn't list is skipped.
- app.js budget: no raise. The new line's 76 bytes come from same and
  alike sharing one string (CONN_WAS) and the native joined case
  returning plain instead of the same t() again.

Run at this head (rebased on c38753a7e, i18n-keys ok there; before that on b010fba05, whose budget raise left 2 bytes;
CONN_WAS's short name gives them):
- mote: go test -count=1 ./internal/agent ./internal/gui ./internal/library
  ./internal/provider: all ok.
- mica: go test ./internal/gateway (whole package, at the pre-rebase tree,
  ok 920s); at this head go build ./... and the gateway's guard, read-only
  and Library tests: ok.
- mica: GOOS=linux and GOOS=windows go vet of agent, provider, gateway,
  library: ok. gofmt -l: clean.
- mica at this head: go test ./internal/gui (budget ok), i18n-keys,
  agent-leave-magpie, agent-connect in chromium + webkit: ok.
- mica, chromium + webkit, before the last rebase: i18n-keys, i18n-en-no-cjk, agent-leave-magpie,
  agent-connect, agent-connect-no-models, agent-connected-unfolded: 0 fail.

Broken by hand: with connectRemote cut out of connect(),
TestConnectFollowsTheRemoteMagpiesPicks fails (connected on
aaa/claude-opus-5-5 (alike)); with the follow's "still the recorded value"
check made always true, it fails on the user's pick written over.

Not tried: two real computers; only a fake remote in the tests. Left for
#6824: a headless `magpie serve` client doesn't follow later changes
(the loop runs in the GUI), an empty field the remote fills later isn't
filled, and WSL / claude#name agent ids don't match across machines.
2026-11-16 14:18:47 +08:00
yetone 13e8002641 claude-desktop: two providers' Claude model read "Opus 5.5 · agy-cli", not the id's tail (onkashiko on X)
Claude Desktop names a row listed as magpie-<n>.anthropic.claude-opus-5-5
after its own catalog ("Opus 5.5"), whatever display_name says, so
agy-cli's and another provider's claude-opus-5-5 read alike and Desktop
5.11492 told them apart by the part of the ids that differs: "Opus 5.5
(…<n>.anthropic.claude-opu…)" (xVn/wVn in its app.asar). Only an
inferenceModels entry's labelOverride comes before the catalog's name,
and Desktop never suffixes such a label (keep in xVn).

magpie now writes the profile's inferenceModels, each row's display_name
as labelOverride, while two rows are named after one Claude model of
Desktop's catalog (desktopNamesClash), not only while a tier is picked.
The ids are unchanged. As with a tier's list, Desktop reads it at start
and its menu stays as listed until the next start; the Agents row's
Restart shows.

desktopNames' own fallback for two rows display_name still leaves alike
(one provider's models named alike) is now the model's id, "Z · D (z2)",
not the whole catalog id; two providers of one name keep the catalog id.
Claude Science takes the same names.

Run (mote, at origin/main 9dcec6751 + this):
- go test ./internal/gateway ./internal/agent ./internal/gui
  ./internal/provider -count=1 -timeout 45m: all ok.
- GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/agent: ok.
- gofmt -l: clean.
Rebased on 023a56373 (Windows install dialog only); at that head
go test ./internal/gateway ./internal/agent -run 'Desktop|Science': ok.
Broken by hand: with the list written only while a tier is picked (the old
rule), TestDesktopInferenceModelsCatalogNamesClash is red ("two Opus 5.5
rows, no list").
Not tried: a real Claude Desktop 5.11492 reading the list (the labelOverride
precedence and keep are read from its app.asar), and the reporter's setup.
2026-11-16 12:05:45 +08:00
yetone b26f16ee24 agent: Alma has one magpie provider, whichever side turned it on
realLemonawa on X: Alma has its own Magpie preset, and magpie's Alma
agent adds a provider of its own, so turning on both left two.

Alma's preset card claims the provider whose id is "magpie" (Alma
origin/main: forPredef / getProviderForPredefined, provPredefBody in
desktop-native settings_providers_detail.go). magpie's provider is now
made under that id (with the preset's icon), so Alma's card shows it set
up and offers no second one. When a provider has that id already (a
user's own elsewhere), magpie makes one as before and leaves it alone.

almaMagpie already took a Magpie set up in Alma first (same gateway
host) as magpie's, so the row showed connected and nothing was added.
What was wrong was switching off: almaSet("") DELETEd whichever
provider it had matched, the user's own preset included. Now a provider
magpie didn't make (name not "magpie") is kept: only the default model
and image refs that point at it are taken back, as before, and it is
turned off again only if it was off when magpie turned it on
(alma.wasoff in the stash). Sync no longer rewrites its model list after
the switch-off.

Tests: TestAlmaOneMagpie (internal/agent/alma_test.go), against the
fake Alma, whose POST now honours an id and answers a taken id with
Alma's 500 "UNIQUE constraint failed":
- set up in Alma first: connected, no second provider, switch-off sends
  no DELETE, the preset stays on, sync after off writes nothing
- turned off in Alma: enabled on connect, disabled again on switch-off
- none in Alma: created under id "magpie", removed on switch-off
- preset id taken by another host: left alone, a new one made

Red on the old alma.go: "the user's own Magpie was removed:
[PUT /api/settings DELETE /api/providers/magpie]". Broken by hand:
without the id, "none in Alma" fails ("not under the preset's id");
without the Sync skip, "sync after off wrote [PUT
/api/providers/magpie/models]".

Real Alma (alma-server from /Applications/Alma.app, sandbox HOME and
ALMA_DATA_DIR, port 23917, never the live one): the preset's own POST
body creates id "magpie"; a second POST with that id is refused
500 UNIQUE constraint failed; PUT {"enabled":false} turns it off; DELETE
204; magpie's POST body with id "magpie" and type openai is kept as
sent.

Run at this tree (rebased on origin/main 0ffb21f83), on mica:
go test -tags nogui -count=1 ./internal/agent ok (199s); go vet -tags
nogui ./internal/agent for darwin, linux and windows ok; gofmt -l clean.
The full suite is queued on mote behind another session's run and was
not waited for; a red there gets its own issue.

Not tried: magpie's agent end to end against a running Alma (the calls
were replayed with curl). A user who already has both (magpie's old
random-id provider and Alma's preset) keeps both: threads name
"<id>:<model>", so neither is merged or removed for them, and magpie's
old provider keeps its id.
2026-11-16 00:23:37 +08:00
yetone 99a54fa874 agent: agy's own /model pick no longer costs settings.json its model, and each thinking level is a model in agy (LolingVerse on X)
agy's /model writes its pick into settings.json ("model": "magpie/…")
even when started with --settings magpie-settings.json. The next Sync's
migrate took that for an older magpie's wiring and put back the old
stash: a stale model and "modelProvider": "gemini", or nothing, which
took the user's own model and provider out. That is the wrong restore
point the reporter saw. While magpie-settings.json is already on one of
magpie's models, such a pick is now moved into magpie's file (what agy
starts on next), and settings.json's model goes back to the one
connect.was kept when magpie was switched on, or out. The old stash is
no longer read for it.

agy 1.5.9 turns /effort away for every custom model, one with a
thinkingLevel too. A custom model's thinkingLevel takes low, medium or
high, and agy sends it as generationConfig.thinkingConfig.thinkingLevel,
which the gateway already asks over the row's effort (agyLevelAsked). A
model with two or more of those levels now has a custom model per
level, magpie/<ref>:<level>. The row's model field shows such a pick as
its model, so the switch stays on (agyLevelOf).

Run:
- TestAgyOwnPickKeepsSettings is red on the old agy.go. The levels part
  fails with "level low:". The pick part, with the levels cut out,
  fails with settings.json {"model":"stale","modelProvider":"gemini"}.
  It is green on the new code.
- go test -count=1 ./internal/agent ./internal/cli on mote: ok (agent 259s, cli 67s) at base 139a6be2b.
- GOOS=linux go vet ./internal/agent and GOOS=windows go vet of both packages (cli's Linux vet needs cgo for Wails on a Mac); gofmt -l is
  clean.
- Real agy 1.5.9 in a sandbox HOME against a fake Gemini endpoint:
  - /model lists magpie/openai/gpt-5.5:low/:medium/:high;
  - picking :high wrote settings.json "model" and sent
    thinkingLevel "HIGH" with model openai/gpt-5.5;
  - /effort still says "Effort isn't adjustable" for custom models.

Not tried: a real magpie gateway and account behind agy (the fake
endpoint stood in), and Windows or a WSL distro.

Not changed: the agent-agy plugin has the same two gaps
(magpie-community/plugins#1188). The switch turning itself off didn't
reproduce on the built-in or the plugin.
2026-11-15 23:19:21 +08:00
yetone 4a4424ea84 codex: the takeover note names the phone connection the Codex app loses, beside Keep on ChatGPT (Mugenrikka on X)
Mugenrikka on X: once the Codex quota was used up, Codex opened through
magpie stopped connecting to the phone and the account's profile could
no longer be opened.

Cause. This is the used-up takeover (#540, codex.out): with the active
ChatGPT account held, magpie becomes Codex's provider without
requires_openai_auth, so the app-server's getAuthStatus/account/read
answer no account (codex-rs app-server get_account builds the account
from the provider). ChatGPT.app 26.1029's main process then takes the
host as an "execution-storage" identity, not a "chatgpt" one (its
early-bootstrap: authMethod chatgpt/chatgptAuthTokens -> chatgpt;
authMethod null and requiresOpenaiAuth false -> execution-storage), and
"Connect your phone" (remote control) and the profile go with it. magpie
never touches auth.json; the sign-in is still there.

Nothing can keep both. With requires_openai_auth = true the app reads
the account again, but its composer gate then greys Send for every
model while the account's /wham/usage says not allowed (checked in
b3a57b3d8 against the 26.1029 bundle), which is what the takeover
exists to get past; lifting that would mean faking the account's usage,
which magpie doesn't do. The owner's call (247794c61) is that sending
comes first. The way to keep the phone and the profile is already there:
Keep on ChatGPT on the takeover note (the sign-in's Always ChatGPT), or
keeping Codex signed in to that account (a5e3972a7), at the cost of a
grey Send till the reset.

What was wrong in magpie: the takeover note listed what is off (chats,
projects, browser use, cloud tasks, account, usage, Log out) but not the
phone connection, so nothing told the user why the phone stopped or that
Keep on ChatGPT has it back. The note at the reset, which says what the
app lacks until its app-server restarts, didn't name it either.

Change: both notes name the phone connection, in en, zh, zh-TW, ja, de.
codex.go's openaiAuth comment and agent-wiring.md say what the app does.

Tests: codex-app-out.test.cjs checks the hover and the opened row name
the phone connection; codex-app-back.test.cjs checks the reset note does.
Red on the old assets (new tests, HEAD's app.js and i18n.js, mote):
120 of 144 fail, "the hover says what is off, browser use and the phone
connection too" and "the row opened names the phone connection".

Run on mote at this tree (base b0d634b85): node --test of
codex-app-*, i18n-*, gui-* (de, ja, zh-tw) and codex-signin-always,
Chromium and WebKit, every language, 980 and 440px: 271 of 271 pass.
gofmt -l internal/agent clean; go vet ./internal/agent ok; go test
-tags nogui ./internal/gui ok (TestCoreScriptBudget included). The Go
change is a comment only.

Not tried: a real used-up account in the Codex app with a paired phone
(none at hand); what the app does was read from ChatGPT.app 26.1029's
bundle and codex-rs's app-server, not watched happen.
2026-11-15 18:38:00 +08:00
yetone 2649d5d727 agents: Dim alpha (dima) is an agent, started on magpie's gateway (T_t__biu on X)
Dim alpha (arcships/dim, npm dimcode-alpha, command dima) gets a row on
the Agents page. Picking a magpie model there starts dima with the
variables Dim documents for any OpenAI-compatible endpoint
(docs/design/model-startup.md): DIM_BASE_URL (gateway /v1),
DIM_API_FORMAT=openai-compatible, DIM_API_KEY (magpie-dim), DIM_MODEL
and both DIM_MAX_*_TOKENS (the catalog's, else 128000/32000). They hold
for that run only; Dim's saved Providers, settings and database are not
written. The pick is in magpie's own dim.json; a dima function in the
user's shell profiles runs `magpie dim run`, and the row gives the
command for an open terminal. Picking Dim's own (or Disconnect) removes
both. Nothing signs in to, reads or proxies Dim's own account or the
DimAgent subscription (removed at its vendor's request, v0.1.471).

Run:
- mica, at this tree (rebased on 574b7b96f): gofmt -l clean; go vet (darwin), GOOS=linux
  -tags nogui and GOOS=windows go vet of internal/agent, cli, agentenv;
  go test -tags nogui -count=1 -timeout 45m ./... -> ok, 101 packages. An earlier run on mote
  was red in internal/library's TestEveryAgentInLibrary (dim had no
  Library place); dim is now in noLibrary as "not looked at (#5897)".
- Broken by hand: DIM_API_FORMAT=openai-chat turns TestDim and
  TestDimRun red; dropping shell(false) turns TestDim red (function
  kept in .zshrc).
- Real dima 0.1.0-alpha.24 on mote, sandbox HOME, sandbox magpie serve
  on 127.0.0.1:38600 with a fake OpenAI upstream: `magpie dim
  magpie/fakeup/echo-1` wrote dim.json and the .zshrc function; `zsh -ic
  'dima exec -p "reply with one word"'` answered through the gateway
  (upstream got POST /v1/chat/completions, model echo-1); usage.jsonl
  recorded agent "dim"; `magpie dim default` removed the file and the
  function, and dima ran as npm installed it. Dim's home was never
  written by magpie.

Not tried: a real model provider (only the fake upstream); Windows and
WSL runs (the shell function is this machine's home only, no WSL
distro support); a Library target (skills, MCP, instructions; #5897); Dim's interactive TUI beyond
exec -p and --version.
2026-11-15 17:16:57 +08:00
yetone 9cd5f36521 antigravity: retired, the built-in and its plugin both ask Google nothing; Antigravity is served by your own agy (agy-cli)
Google bans accounts it sees on Code Assist through Antigravity's own
client. magpie offered that route twice, the built-in and
@magpie-community/opencode-antigravity-auth, and anyone who picked
Antigravity in magpie took it by default (the owner, 11-15: 全部下线,改推
agy-cli).

- retiredBuiltins has antigravity. googleLogins lists no account of a
  subscription its plugin serves, so no list, usage read, quota read or
  request goes to Google with a built-in Antigravity account (the usage
  loop in subscription_usage.go had no gate of its own). The mover reads
  googleSavedLogins, so saved accounts still move.
- The mover's min is 0.2.0 (on the plugins dist index, b8bf5a57): that
  version sends nothing, answers every request 410 ModelDeprecated
  ("model has been retired", which modelRetired reads, so a group asks its
  next member) naming Antigravity (local agy CLI) and
  `magpie plugin add @magpie-community/opencode-agy-cli-auth`, and turns
  sign-in away. It left the plugins registry (003a38ff).
- Gemini CLI's route, on the same code, is unchanged.
- The built-in's code stays for now (shared with Gemini CLI); taking it
  out is #6723. Its 123 tests serve it again for their run through
  provider.AntigravityBuiltinForTest(), a counter BuiltinRetired reads.
- README (en, zh) and site docs subscriptions (en, zh, ja) point to
  Antigravity through the user's own agy CLI. AGENTS.md and
  provider-plugins.md say why and that neither route comes back.

What users lose: Antigravity with Google accounts signed in to magpie, and
rotating several of them. agy-cli serves the one account the user's agy is
signed in to, and needs agy installed.

Tests: TestRetiredAntigravityAsksGoogleNothing saves an Antigravity
account and checks googleLogins/googleAccountOf give nothing, the mover
still carries it, usage has no Antigravity card and the fake Google was
asked nothing, and Gemini's account still lists. Broken by hand (the
PluginServes gate removed from googleLogins): red,
"googleLogins(antigravity) = 1 accounts".

Run (mote/mica, at this change on origin/main 5bd41301b): gofmt -l clean;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... and go build ./... ok; go test ./internal/gateway/ (1245s),
./internal/agent/ (419s), ./internal/provider/ (253s) ok on mica;
after rebasing on origin/main f362d3b9a: go test ./internal/provider/
(160s) and ./internal/plugin/ (184s) ok on mica.
Earlier at this change minus the test opt-ins: sessions, usage, library,
gui ok (mica). internal/cli's TestEveryRouteHasACommandOrIsNamed is red at
5bd41301b itself (/api/warm-all, #6724), not from this change.
Not run: the full ./... suite (mote and mica each had another session's
full or GUI suite); the GUI suite (no app.js change); a real move of a
built-in Antigravity account onto 0.2.0.

Plugins side: magpie-community/plugins 003a38ff (antigravity 0.2.0) and
f9155256 (agy-cli 0.1.56, comments only).
2026-11-15 12:14:48 +08:00
yetone a5e3972a71 agent: the Codex account the user keeps Codex on is never taken over when held, so the app shows it, not "magpie" (davezfr on X)
davezfr on X, after v0.1.4216 (369ec0418): "still shows Magpie". Account
1 has used up both its plan allowance and its credits; picked in Codex's
sign-in it shows "magpie" in the Codex app, while account 2 (room) shows
itself. When it still had credits this didn't happen.

Cause. With quota and credits both gone the account is held (codexHeld:
rate_limit.allowed false, no credits), and the agent package's out()
then makes magpie Codex's provider (codex.out takeover, #540) without
requires_openai_auth. Codex's app-server answers account/read with no
account for such a provider, so the app shows the provider's name,
"magpie", in place of the account the user picked. 369ec0418 only
ended stale holds at their window's reset; a real hold still took the
account over. The takeover is magpie's default; the account the user
keeps Codex signed in to is the user's own value, which the default
overrode (code standards: magpie's default never overrides a value the
user set).

Fix.
- provider.CodexSignInKept: Codex is on the account the user keeps it
  on (keepsLogin: KeepLoginAs names the active account, or kept on the
  first with none named). False under switch-only, keeping off, or kept
  on another account than the active one.
- agent: out() is false for such an account (codexSignInKept, a var
  for tests), so Sync leaves Codex beside its ChatGPT sign-in, a pick of
  magpie's model doesn't take it over, and a takeover made before the
  keep ends. The app shows the account and greys Send till its reset,
  as it does without magpie. Not kept, a held account is taken over as
  before (Always ChatGPT still turns the takeover off for every account).
- docs/subsystems/agent-wiring.md says so.

Users already affected: once updated, the next catalog sync puts Codex
back beside the kept account's sign-in; the Codex app shows the account
after its app-server restarts (the Agents row's Restart, or Restart the
Codex app to follow), as for the takeover's end at a reset.

Tests:
- TestCodexKeptOnAHeldAccountShowsIt (agent): held and not kept: the
  takeover; kept: beside the sign-in, no AppOut, on magpie's model and
  on Codex's own joined model; let go: taken over again.
- TestCodexSignInKept (provider): the reporter's state, two accounts,
  account 1 held (week at 100%, not allowed, no credits) and kept via
  SetKeepLoginAs: CodexUsedUpKnown true and CodexSignInKept true; kept
  on account 2 while on 1, switch-only, keeping off: false.
Broken by hand: with `&& !codexSignInKept()` taken out of out(),
TestCodexKeptOnAHeldAccountShowsIt red (model_provider = "magpie"
written); with CodexSignInKept's match turned to false,
TestCodexSignInKept red ("CodexSignInKept false").

Run: full suite `go test -count=1 -timeout 45m ./...` on mote at this
change on ca64168d3: exit 0, 101 packages ok, no FAIL (log kept whole
in magpie-wt/codex-held-account-scratch/suite.log). After rebasing on
6e6a18eda (gateway only): internal/agent ok, internal/provider ok on
mote. gofmt -l clean; on mica go vet (darwin), GOOS=linux -tags nogui
and GOOS=windows go vet ./internal/agent ./internal/provider ok.

Not tried: the real Codex app with a real held account, and the
reporter's exact setting (if account 1 was picked by a plain switch
rather than kept, magpie moves Codex off the held account to account 2
at its next look, as before, and the takeover stands meanwhile).
2026-11-15 07:39:25 +08:00
yetone f1c9014cd9 wsl, masking: a hung WSL or a slow local model no longer holds requests
vsoullai on X (0.1.4190, Windows): the gateway froze. Each request waited
15s in turn on the local masking model, routing was held 30s and got a
504, and a stopped WSL distro's probe dragged everything down until
redactModel and WSL were turned off. #6167 (Codex held 30s then 504,
fixed by restarting WSL) and #4856 (masking timeouts, 504s) are the same.

WSL (internal/agent/wsl.go, wsl_links.go):
- wsl's lock was held through wsl.exe and through the stat of
  \\wsl.localhost\<distro>, which can't be cancelled. The GUI's look held
  it, and every request's Codex/Claude stand-in, wslUp, distroAt and
  Copilot's WSL folders queued behind it.
- A look (wslRefresh) now runs wsl.exe, the probes and the stat outside
  the lock. Looks take turns on wslRefreshMu, and the lock only guards
  reads and writes.
- wslRoot's stat is bounded (wslRootWait 5s); a distro whose / can't be
  opened fails its probe and is tried again later.
- What a request asks never waits on a look. "Which distros run" is
  asked single-flight in the background and waited for at most
  wslRunningWait (2s). A distro wsl.exe hasn't named as running counts
  as stopped, so nothing opens or wakes a distro on a guess.
- Copilot's WSL sign-in (internal/provider/copilot_cli.go) is read the
  same way: single-flight, waited for at most copilotWSLWait (2s), with
  the last answer kept. Before, its own mutex queued every request
  behind the first one's read.

Masking (internal/masking/masking.go):
- With redactModel on, each request waited up to strictWait (15s). In a
  burst the backlog grew and the requests waited one after another.
- Once a strict request runs out its wait with texts unread, the model
  is "behind". The next requests then wait only defaultWait (2s) until a
  request is read whole or a minute passes (behind, waitFor). The rules
  still mask everything the model hasn't read.

Docs: docs/subsystems/agent-wiring.md (WSL twins) and gateway-routing.md
(masking).

Run:
- New tests, on mote, -race -count=3: TestWSLHangHoldsNoRequest (wsl.exe
  --running, a distro's probe, the stat; each hang injected),
  TestWSLRootHangFailsProbe, TestCopilotWSLHangHoldsNoRequest and
  TestStrictModelBehindWaitsTheDefault, with the other WSL, Copilot WSL
  and masking tests. All ok.
- Broken by hand: the same tests on the old code (origin/main's files
  with only the new tests added). Each WSL hang case failed ("a Codex
  stand-in waited on a hung WSL past 2.2s", "the GUI's look didn't wait
  on the hung WSL"). The Copilot test failed ("13 requests waited on a
  hung WSL past 2.2s"). The masking test failed ("request 2 after the
  model fell behind waited 2.0s").
- Full suite on mica at f08597a58 (this change on b754cb095):
  `go test -timeout 45m ./...`, exit 0, 101 packages ok.
- Rebased on f03869520 (a gateway/provider change). At this head, on
  mica: go test -count=1 ./internal/agent ./internal/provider
  ./internal/masking ./internal/gateway all ok, go vet ./internal/... and
  GOOS=windows vet of those four ok, gofmt clean. The full suite ran at
  the base before it, not again at this head.
- Rebased again on c0cf352a8 (four commits: gateway, provider Codex
  hold, providers base URL, LESSONS). At this pushed head, on mica:
  go test -count=1 ./internal/provider ./internal/masking ok, the WSL and
  Copilot tests of internal/agent ok, go vet of agent, provider and
  gateway (darwin and GOOS=windows) ok.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok.
- Windows (xiaomi-gpu, win-run), internal/agent, internal/provider and
  internal/masking. masking: ok. agent and provider: 52 reds, all in the
  53 that origin/main f03869520 has on the same box (#6068, #1827,
  #5068, #5344, #5950; this run's list is on #6068). None touch WSL,
  Copilot's WSL or masking.

Not tried: a real hung WSL. On xiaomi-gpu, wsl -l -q and -l --running
answered in ~55ms, and a terminated distro's \\wsl.localhost path failed
in 131ms, so the hang was injected in the tests, not reproduced live.

(vsoullai on X, #6167, #4856)
2026-11-15 06:20:15 +08:00
yetone ec8125e680 agent: Kimi Code's thinking level is picked in Agents
@apple_test_src on X: every other agent has a reasoning-effort pick,
Kimi Code didn't. Kimi Code 2.x keeps its startup level in
config.toml's [thinking] table (read from @moonshot-ai/kimi-code 2.6.2's
source: ThinkingConfigSchema, persistModelSelection,
thinkingEffortFromConfig). The new "thinking" field writes it the way
Kimi's own /model does: off = enabled=false (effort kept), a level =
enabled=true + effort, Default removes both keys (and the table when
empty). Options come from the chosen model's support_efforts /
default_effort / capabilities, overrides first; "off" is left out for
an always_thinking model; unknown model or unreadable file gives
off/low/medium/high. A cold WSL place reads nothing (#3896). The legacy
Python kimi-cli gets on/off through its top-level default_thinking.

Run:
- Real Kimi Code 2.6.2 on mote, sandbox HOME and
  KIMI_CODE_HOME, fake chat server, config written by this field's Set:
  Default sent thinking {enabled, effort medium (model default)}, off
  sent {type: disabled}, low and max sent those efforts.
- mica-run at bba704222 (rebased on fdf42299e): go vet ./internal/agent native,
  GOOS=linux, GOOS=windows ok; go test -count=1 ./internal/agent
  ./internal/gui ok; gofmt clean.
- mica-run GUI: kimi-thinking (new), agy-effort, i18n-keys and the
  agent-field / codex-default-effort / effort files, Chromium + WebKit,
  en/zh/zh-TW/ja/de: 114/114 pass.
- Broken by hand: dropping override handling and leaving enabled behind
  on Default turned TestKimiThinkingField red. The first version opened a
  stopped distro's config and TestWSLColdPlaceOpensNothing went red; fixed.

Not run: the full go test ./... (mote and mica both had other sessions'
suites running), the legacy kimi-cli binary (its source only), a real
Moonshot account.
2026-11-15 03:12:36 +08:00
yetone df4578438e models: a model listed bare takes what models.dev says, audio too
Parlevent_ on X: Gemini served through magpie from Vertex AI was listed
as taking text and images only, never audio. Vertex AI's models, and a
relay's, come from a list that says nothing of what a model takes, so
the entry had no input kinds and every agent's fallback said
text+image (provider.Entry.Modalities' Images branch).

catalog.InputsOf is now what most of models.dev's providers list a
model with, by bare id, as SeesImages, ContextOf and the others are
voted. provider.InputsOf uses it when the model's own source said
nothing of input (InputModalities and ImageInput both nil); a source's
own word, a plugin's included, still stands, and the image kind still
follows Images (the user's override included). The GUI's model row and
every agent's list read it through the Entry. OpenCode is now told
audio, video and pdf where the model takes them (its modalities enum
holds all five), not text+image only.

So Vertex AI's gemini-3.5-flash is text, image, audio, video, pdf;
gpt-oss-120b-maas there is text; a relay's bare gemini-3.5-flash is the
same as Vertex AI's. A model models.dev doesn't know stays unknown.

Also: a video sent to a bare-listed model models.dev lists without
video is now refused at magpie ("does not support video input") as it
is for a model whose own list says so, where it went upstream before.

Run (mica, mica-run):
- the new tests: TestGeminiTakesAudioWhereverServed (provider),
  TestInputsOf (catalog), TestOpenCodeInputs (agent): green; red on
  e9fcc6229 with the old code (vx/gemini-3.5-flash takes [text image],
  OpenCode told [text image])
- go test -count=1 -timeout 45m ./... at e9fcc6229 + this change:
  98 ok; red in . (TestNoEagerPackageRegexps, chatpage.go: #6689),
  internal/cli (/api/providers/delete, fixed in 4c86b0ab4) and
  internal/gateway (TestKeySlotEveryRoute and LazyCat manifest, the
  /deepseek-chat routes, fixed in cd030691a), none in code this touches
- again at 677034e1a + both commits: internal/cli, gateway, catalog,
  provider, agent, gui ok; . red only on #6689
- go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok; gofmt -l clean

Not tried: a real Vertex AI account; Codex, Pi, dsh and omp still take
text and image only, as their configs have no other kinds.
2026-11-15 01:25:49 +08:00
yetone 04ca2afab2 netproxy: Auto reads a Linux desktop's proxy, GNOME's and KDE's (#4147)
On Linux, Auto read no system proxy at all (system_other.go answered
none), so with Clash Verge's system proxy on, magpie opened from the
desktop's menu, with no *_PROXY, went direct and Settings said "No
system proxy found". The user had to type the proxy into magpie and
take it out again when they turned the proxy off.

system_linux.go reads the desktop's own setting, where its apps and
Clash Verge (sysproxy-rs) put it:
- GNOME (and Cinnamon, MATE, Budgie): `gsettings list-recursively
  org.gnome.system.proxy`, mode 'manual' only; HTTPS over HTTP over
  SOCKS, ignore-hosts as the bypass list.
- KDE: ~/.config/kioslaverc (XDG_CONFIG_HOME), ProxyType=1 only, its
  "http://127.0.0.1 7897" address form, NoProxyFor unless reversed.
  Read first on a KDE session, else after GNOME's.
No gsettings, or no GNOME proxy schema, is none; a gsettings that fails
otherwise is a failed read, which keeps the last good one as on macOS.
PAC ('auto', ProxyType=2/3) is not read, as on macOS and Windows.

Codex's view is unchanged on Linux: its reqwest reads no desktop
setting there, so codexProxyFor takes no system proxy unless on macOS
or Windows (codexSystem), with test cases that fail without it.

Not a timezone or language guess (the X ask from jimlee0824v2): it is
wrong for anyone travelling, on a VPN or a TUN, and the system's proxy
is what says whether one is on.

Run:
- red on the old code: TestSystemReadsGnome, TestSystemReadsKDE and
  TestSystemWithoutDesktopProxy (3 of 3); the two Linux cases of
  TestCodexProxyFor with the old codex_proxy.go.
- real gsettings on Ubuntu 24.04 (WSL magpie-desktop) under
  dbus-run-session with a temp XDG_CONFIG_HOME set to manual
  127.0.0.1:7897: system() gave http://127.0.0.1:7897, bypass
  [localhost 127.0.0.0/8 ::1]. The distro's own setting not touched.
- mica-run: go test ./internal/netproxy ./internal/agent ok; go vet of
  both for darwin, GOOS=linux and GOOS=windows ok.
- wsl-run: go test -run 'Proxy|Gsettings|Kioslaverc|TestSystem|Codex'
  ./internal/netproxy ./internal/agent ok.
- win-run: go test ./internal/netproxy ok.
- gofmt -l clean.
Not tried: a real KDE session (fixture from sysproxy-rs' format), the
GUI on a Linux desktop.
2026-11-15 01:18:58 +08:00