Commit Graph
3 Commits
Author SHA1 Message Date
yetone b7a2e73761 agent: connecting an app that gets magpie's models as its provider, with none listed for it, says why instead of reporting success (Lumens on Discord)
Lumens (v0.1.1233) connected WorkBuddy from the Agents page. The toast
said it was connected, but the toggle flipped straight back and
WorkBuddy had no magpie models. For agents that take magpie itself as
the provider (WorkBuddy, WorkBuddy AI, ZCode, Pencil, T3 Code, Copilot
JetBrains), Agent.connect() went down the "magpie" branch and called
Apply without checking whether any model was listed for the agent. With
none listed (no provider or subscription yet, or "only picked" with
every pick gone), Apply wrote nothing, connect still answered 200, and
the next read found nothing wired.

The fix applies, then, if the agent still doesn't read as wired, returns
the same NoModelsError or AllHiddenError the field-less path already
used. The GUI already maps both to no_models and all_hidden, in all five
languages. The check comes after Apply because Cursor Private Inference
is wired through its environment with no models at all, and
TestCursorLocalConnects keeps that connecting. The noModelLeft helper is
shared with the existing field-less path.

Tests:
- TestConnectMagpieAsProviderWithNoModelLeft (agent): WorkBuddy with no
  provider gives NoModelsError. With its only picked provider switched
  off it gives AllHiddenError and stays unwired. Switched back on, it
  connects and is wired.
- TestAgentConnectNoModelsMagpieAsProvider (gui): POST
  /api/agents/connect/workbuddy with nothing in magpie gives 400
  no_models. The old code gave 200.
Both fail on the old code.

Run:
- gofmt -l is clean.
- go vet passes on darwin, on GOOS=linux -tags nogui and on GOOS=windows,
  for internal/agent and internal/gui.
- go test -tags nogui passes for ./internal/agent and ./internal/gui under
  a sandbox HOME (load ~250 from sibling sessions).
- An earlier full ./... run: gateway, library and provider passed on a
  rerun with a longer -timeout. Their first run hit the 10m timeout under
  load, with no assertion failures.

Not tried: the real WorkBuddy app, and Lumens' own settings, which
haven't been seen. Left for its own change: workbuddyWired counts only
vendor "magpie" entries, while buddyWrite also treats an entry under
magpie's key that WorkBuddy re-saved as vendor "Custom" as magpie's.
2026-10-14 20:01:06 +08:00
ChampionTina c1e354245d agent, gui: connecting an agent whose model list holds none of magpie's models says so, in the reader's language (#1989, znuaibot)
znuaibot's case: OpenCode shown only its one picked model, whose provider
was switched off. connect() found no field to set, and since the catalog
still held models (shown 0, hidden 7) it said only "OpenCode can't be
connected to magpie", which sent the user looking at the agent rather
than at the model list that emptied it.

znuaibot's patch (74160e1f) told the case apart in connect(). Changed on
review: the plain English error would have reached the GUI untranslated
(NoModelsError beside it is said by code), so the case is a typed
AllHiddenError, fail() answers it with code all_hidden, and the GUI says
it in en/zh/zh-TW/ja/de, pointing at the agent's Model list → Pick (the
names the Agents page uses).

Run: TestConnectWithEveryModelTakenOut (agent) reproduces the case with
a provider switched off under OpenCode's picked list: on the old connect
it FAILs with "OpenCode can't be connected to magpie"; passes now, and
connects once the provider is on again. TestAgentConnectAllHidden (gui)
checks the code. agent-connect-no-models.test.cjs now runs both codes in
Chromium and WebKit, en/zh/ja/de: 16/16 pass, and with app.js's
all_hidden line removed the 8 all_hidden cases FAIL. gui-de, gui-ja,
gui-zh-tw, i18n-keys: pass. Full internal/agent and internal/gui: see
the push record on #1989.
2026-10-14 05:43:48 +08:00
yetone 528d6c12dc agent, gui: Codex left on model_provider = "magpie" with no [model_providers.magpie] loads its config again, and connecting with nothing in magpie says what to do, in the reader's language (Tystem on Discord) — the Codex app said "无法加载 config.toml … Model provider magpie not found", magpie showed Codex as not connected on "deepseek-flash", and its switch answered only "Codex can't be connected to magpie", in English. Codex looks model_provider up in [model_providers.*] as it loads config.toml (codex-rs: "Model provider {id} not found"), so the key without the table keeps it from loading any config, a new thread too, not just an old one. magpie never writes one without the other: it takes model_provider out whenever it steps out as the provider (disconnect, Unwire, a model of Codex's own, Join) and keeps the table so the threads started on magpie still open. That is unchanged, and TestCodexSteppingOutLeavesNoHalfState now covers it. Another tool or a hand edit had taken the table away. Sync, at magpie's start and whenever the catalog changes, now writes the table back whenever the config names magpie as its provider, at the top or in a profile, and has no table, whether Codex is connected or not. Check reports that state too. A config magpie can't parse is still only reported, never written to. A Connect that finds none of magpie's models because no provider or subscription has been added answers agent.NoModelsError, "Add a provider or subscription in magpie first, then connect Codex". /api answers it with code no_models and the agent's name, which app.js says through t() (en/zh/ja/de). docs/reference.md no longer says the table goes with a native model. TestCodexProviderWithoutTable (top and profile: Check says so, Sync writes the table) and TestConnectWithNoModels in internal/agent, TestAgentConnectNoModels in internal/gui, and agent-connect-no-models.test.cjs (WebKit, en/zh/ja/de: the toast in the reader's language, the switch back off, no scroll, no native dialog) are new and fail without the change; the latter's en case passes either way, as the server's message is English. Chromium wouldn't launch on this machine for this test or the existing agent-connect.test.cjs. TestCodexSyncAddsBaseURLToProvider now expects the table added to a hand-made provider that had none. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. In the first full run, internal/gui's TestProvidersAnswerWhileListsComeIn and internal/proc's TestUserPath failed under load; both passed alone and in the second full run. 2026-10-05 21:09:13 +08:00