workbuddy: with the provider left out of the names, a model's id is its name (elis_pina on X)

WorkBuddy's model list read "GLM-5.3:workbuddy/glm-5.3" with Provider in
model names Off. WorkBuddy (5.5.6 renderer, getModelDisplayName) shows
every custom model as "name:id" unless the name is empty or equal to
the id, and magpie wrote the catalog id (provider/model) as the id. So
the provider came back after the colon whatever the names said.

- agent (buddyIDs): for WorkBuddy and WorkBuddy AI under Off or Own,
  each magpie entry in models.json gets the name as its id too, so the
  list shows "GLM-5.3" alone. The catalog id stays when two models
  share a name, when the name is another model's id, when the entries
  point at a magpie on another machine or in WSL, and in On mode.
  A model turned off in WorkBuddy, its default effort and a reply limit
  typed in carry across the change of id: an old id is mapped back
  through every label form (Label, PlainName, the list's name).
- provider.AgentNamed: the catalog id of the one model an agent's list
  names so.
- gateway (namedFor): a request with WorkBuddy's or WorkBuddy AI's key
  for such a name goes to that model before any other resolution, so a
  bare id that another provider serves first is not asked instead. The
  reply keeps the name that was asked for. Other agents' keys are not
  mapped.

Siblings: CodeBuddy Code shares the writer and keeps catalog ids. Its
settings.json names the model by the catalog id (codebuddy.go), and its
CLI picker shows the name alone (no name:id template in its bundle).

What users meet: a change of mode, or of a model's name, changes the
id. WorkBuddy then picks another model for a session that had the old
one, as it does for any model that leaves its list.

Run:
- Unit tests: TestWorkBuddyNamesAreIDsWithoutProvider covers Off, Own,
  back to On, WorkBuddy AI and CodeBuddy. TestWorkBuddyAsksByName uses
  the real handler: a name equal to a bare id that a provider listed
  first serves (hidden from WorkBuddy) reaches the named model, and
  OpenCode's key for the same name does not.
- Broken by hand (on mica), each red:
  - buddyIDs always returning the catalog id: the test sees
    id deepseek/pro under Off.
  - namedFor's mapping skipped: the request went to provider "first".
  - The old-id mapping skipped: Own lost disabled.
- Sandbox HOME, built binary:
  - magpie provider add zai (fake upstream) and magpie workbuddy
    provider magpie wrote "zai/glm-5.3 | GLM-5.3 · Z.ai".
  - magpie model suffix workbuddy off rewrote the file to
    "GLM-5.3 | GLM-5.3".
  - magpie serve on a spare port, then a curl with magpie-workbuddy for
    "GLM-5.2" reached upstream as glm-5.2 (reply model GLM-5.2).
  - WorkBuddy 5.5.6's own CLI (app.asar.unpacked/cli/bin/codebuddy -p
    --model GLM-5.3), with HOME set to the sandbox, answered "pong", and
    upstream saw glm-5.3, streamed.
- Full suite on mote at this tree (go test -count=1 -timeout 45m ./...):
  every package ok (agent 369s, gateway 1062s, provider 230s,
  sessions 254s), log kept whole. The doc line in agent-wiring.md was
  added after the run; no test reads that file. gofmt -l is empty,
  and go vet ./... passes. On mica, GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., and the linux nogui and windows
  builds pass.
- That suite ran at base ac0b5c287. The change was then rebased onto
  5211fd3ba (usage currency; no file in common). At the pushed head,
  on mica: go build, go vet of agent, gateway and provider, and
  -run "WorkBuddy|CodeBuddy|AgentSuffix|Labels" in those three
  packages all pass.

Not tried: WorkBuddy's window itself (the name:id rule is read from
its renderer source, not seen on screen), and WorkBuddy AI's app.
This commit is contained in:
yetone
2026-11-13 22:49:39 +08:00
parent 5211fd3ba2
commit a97c8191bc
6 changed files with 356 additions and 12 deletions
+1
View File
@@ -97,6 +97,7 @@ something else shows up as drift.
- dsh (DeepSeek Harness) sets one API per llm-pi-ai route, so magpie writes a route per protocol (`dshKinds` in [`dsh.go`](../../internal/agent/dsh.go); 01huadalang on Discord): `magpie` (Chat Completions) for most models, `magpie-responses` (`openai-responses`) for a model served on Responses, `magpie-anthropic` (`anthropic-messages`, the gateway root, `forceAdaptiveThinking` where `AdaptiveThinking` or `AdaptiveWithEffort`, so Max reaches GLM-5.3 as max) for one served on Messages, by the model's `APIs` (`dshRouteOf`). A model's `APIs` is the one its provider serves it on best (`Provider.Native`, in `magpieModels`, [`route.go`](../../internal/agent/route.go)), and Pi, omp and droid read it the same way. For a custom provider with more than one URL that is the API its Base URL was given as (`BaseAPI`), after the vendor rules (an OpenAI model on OpenAI's API, a Claude where Messages is served): a relay set to Responses whose Chat URL Detect found beside it had its GPTs on dsh's Chat route (nb5p on Discord, `TestDshCustomResponsesProvider`). dsh's bundled pi-ai (`@earendil-works/pi-ai`, dsh 0.2.1-rc.2) takes `openai-responses` as a route's `api`. A routing group has `responses` when a member is best on Responses and every other member takes a Responses request as it is too, or translates every request anyway (`provider.GroupAPI`, #1594; zyh6036 on X: a group of subscriptions that all serve Responses, not all best there, was asked on Chat), so its tool-call arguments are relayed as they stream; any other group has none and stays on Chat, so a member only Chat reaches keeps being relayed, and a Messages-only group stays there too, as a Claude member's thinking is known by its own model. A route with no models is taken out. An api the user picked for a route in dsh's Models page is kept, and so are keys they added there. A model of a route whose api stands as `openai-responses` carries `compat.supportsStrictMode` (#3055): OpenAI's Responses API takes a function tool whose `strict` is left out as a strict-mode one, every property required, so a tool's optional parameters come back filled; pi-ai says `strict: false` on an ordinary tool only when the compat says so, by the api the route has, not by its name. The start (`agent-default-model`) names its model's route, and Sync moves a start on one of magpie's routes to the route its model is now on (`dshStartOnItsRoute`), its effort and marks kept. A start on a model by an id magpie lists it by no longer, a found group's `group/auto-<slug>` (now `auto/<model>`, `provider.PublicRef`) or a renamed provider's (`provider.RenamedRef`), moves onto the id its route lists, in every profile and the home layer: dsh finds the start by that id, and the desktop app showed no model picked while its patch list held every route (zyh6036 on X, `TestDshStartOnAFoundGroupsOldIdMovesOntoItsId`). `renameFoundGroups` moves only a value applied.json records, and the start dsh read was not one (none on the owner's install either), nor is a pick made in dsh. Check asks the route the start names to list its model. A dsh session resumed on a model that has since moved routes asks for the model to be picked again, since dsh finds a model by route and id.
- The names every agent's model list gets are `provider.Labels`' ([`modelprefs.go`](../../internal/provider/modelprefs.go)). With Provider in model names off (or own, for names the user gave), a name stands alone unless another model in the same list reads the same, when both keep their provider's after it. A routing group named as anything else in the list keeps "· routing group", and the model it shares the name with stays plain: the group found for a model served by two providers, one of them hidden from the agent, had the shown model read "GPT-6.1 Terra · MyGateway" beside its provider's plain "GPT-6.1 Sol" (nb5p on Discord; `TestPlainNames`, `TestSuffixMode`, `TestPlainOwnNamesGroups`).
- An agent can have its own Provider in model names, set in its Details on the Agents page or with `magpie model suffix <agent> on|own|off|every` (KillTry27355 on X). `settings.AgentSuffix` keeps it by the id the agent's lists are kept by (`Agent.ListsFor`, lower-cased, without `@wsl:` or `#profile`); with none the agent follows Settings'. Every list magpie writes or serves an agent goes through `provider.LabelsFor(agent, …)`, which reads that agent's mode (`suffixModeOf`); the gateway's `/v1/models` takes the agent from the request (`agentOf`). Setting it rewrites the agents' configs as Settings' does (`catalog.Touched`). (`TestAgentSuffix`, `TestAgentSuffixReachesItsFileAlone`, `TestModelsListFollowsAgentSuffix`, agent-suffix.test.cjs.)
- WorkBuddy and WorkBuddy AI show a custom model as `name:id` whenever the two differ (the renderer's `getModelDisplayName`, 5.5.6), so a catalog id put the provider back after every plain name ("GLM-5.3:workbuddy/glm-5.3", elis_pina on X). With their Provider in model names Off or Own, `buddyIDs` writes each model's name as its `id` too, unless two models share the name or it is another model's id, or the entries point at a magpie on another machine or in WSL (`place`), whose names this one cannot answer for. The gateway takes a name back to its model by the agent's key before any other resolution (`namedFor`, `provider.AgentNamed`), so a bare id another provider serves first is not asked instead. A disabled model and its default effort carry over when the id changes (`modelOf` maps every label form back). A change of mode or of a name changes the id, and WorkBuddy then picks another model for a session that had it. CodeBuddy Code keeps catalog ids: its settings.json names the model by them and its picker shows the name alone. (`TestWorkBuddyNamesAreIDsWithoutProvider`, `TestWorkBuddyAsksByName`.)
- dsh takes a model's listed `maxTokens` as every request's output and reserves it, with 65536 of headroom, out of `contextWindow` before deciding when to compact (compaction-basic's `resolveCompactSpec`: the smaller of 80% of the window and window − maxTokens − 65536). A vendor's reply limit near its window had dsh compact at 41248 of a 500000 group (#2823) or fail with no budget (524288/524288, LoKi on Discord; 131072/65536), so magpie lists it held to what leaves dsh half the window to compact in (window/2 − 65536), or to a quarter of the window where that is more (every window under 262144, as VS Code and Copilot in JetBrains hold it), on every route and in the older `llm-deepseek` entry (`dshMaxTokens`). A quarter alone cut DeepSeek's 393216 on its 1000000 window to 250000 (#3298); now it keeps all of it and dsh compacts at 541248, while 500000/393216 is held to 184464 and compacts at 250000. A Max output the user set stays as they set it (`outputOr`), even one that leaves dsh no budget. `TestDshOutputLeavesCompactionRoom`.
- dsh compacts on the session's latest model (compaction-basic with no `summarizationModel`), so a switch away from a model whose provider is out of its limit failed on the compaction (Musikrv77852 on X, #5395). dsh's opened row has a compaction model square (`compact_model`, `dshCompactField` in [`dsh.go`](../../internal/agent/dsh.go)), offered once dsh is on magpie's route: magpie's own `Live` setting (`settings.DshCompactModel`, `provider.SetDshCompactModel`), which the gateway reads on each request (`dshCompactTo`), so nothing is written into dsh's profiles. DS Bot's requests can't be told from dsh's, so it has no square of its own and its compactions follow the same setting (`TestDshCompactionModelField`, `dsh-compact-model.test.cjs`). With no compaction model set, a compaction on a model whose provider is out of its limit goes to the same model from another provider when one serves it (`dshCompactElsewhere` in the gateway, `dsh-compact-rested`; qtwaiter on X: a WorkBuddy rate limit refused a switch to Trae CN's model).
- Codex's compaction can be put on a model of its own (0neB1aze on X; its memories already could). Codex's opened row has a compaction model square (`compact_model` in [`codex.go`](../../internal/agent/codex.go)): magpie's `Live` setting (`settings.CodexCompactModel`, `provider.SetCodexCompactModel`), read by the gateway on each compaction (`codexCompactTo` in [`codex_compact_model.go`](../../internal/gateway/codex_compact_model.go), called from the Codex backend's `/responses` branch before `codexCompact`), so nothing is written into Codex's config. Only a compaction magpie makes is moved: it asks a model for a plain-text summary any model reads back. One a ChatGPT account seals (`nativeCompactionFor`) stays where it is, and so does one that would be put on such a model, since only the account that wrote the summary reads it (#1099); a model that is disabled, not served by its exact id or not the key's is left too, with a log line (`compactRefused`). Other agents' compactions are moved by a routing group's Compact rule (`provider.Rule.Compact`) (`TestCodexCompactOnItsOwnModel`, `TestCodexCompactToLeavesNative`).