Commit Graph
7 Commits
Author SHA1 Message Date
ggbdpq cdd470ce9f agent: opencode.json lists magpie's models in the order the user set
The models of magpie's provider in opencode.json were a
map[string]any, whose keys encoding/json marshals sorted: the order the
user dragged to on the Agents page reached magpieModels and died at the
last step, the file listing the models A to Z (#4575). A pure
re-ordering wasn't even written — syncJSONInOrder's sameOrder compared
two alphabetical lists and found them alike. The variants under each
model kept their order since #713 (orderedJSON); the models keep theirs
the same way now, and openCodeKept looks a model up in the ordered
block to put a variant of the user's on it.

Every config in OpenCode's shape moves with the one fix: OpenCode,
OpenChamber, Air, MiMo Code and DevEco Code (openCodeLike and the
openCodeKept calls in air.go and openchamber.go). Pi, Crush and Codex
list models in arrays and were never touched.

Run: TestOpenCodeModelsInOrder in internal/agent (written first) fails
on the unmodified code — the fresh block lands alphabetical and a
dragged order is never written — and passes with the fix. The
models-as-map assertions in TestInferredGroupImagesReachAgentCatalogs,
TestMiMoCodeCatalogNarrowedSeparately and
TestGroupModelsCarryTheirFirstMembersPrice read the ordered block now.
go test -tags nogui -count=1 ./internal/agent ok (150s) but for
TestMothX, which fails the same on unmodified main cac655c14 on this
machine (mothx_test.go:154) — pre-existing, not this fix's. gofmt
clean; go vet -tags nogui clean on darwin, linux and windows; go build
-tags nogui ./... ok on the three.

Generated-by: GLM-5.3-Flash (ZCode)

Broken by hand: with the agents.go hunks reverted,
TestOpenCodeModelsInOrder is red (written: [aaa/m1 relay/glm-4.6]).
Not changed: Cline's models.json is built from a map too (cline.go
clineModelsAt and clineKept). Filed as #4594.
2026-11-01 02:45:01 +08:00
yetone 81a24cf8fe groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.

What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
  public one). Every old form is still accepted as input forever:
  provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
  gateway (validateModel), keys, stats, affinity and usage, so both ids
  route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
  (allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
  exists, found groups are listed by their old id (AutoRefsOn) and
  auto/<x> means that provider's model. Documented in
  docs/subsystems/gateway-routing.md.

Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).

Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.

Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
  nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
  gateway, whose failures were the tests' expected ids (updated here)
  and two regressions now fixed (bare ids; desktop models hiding groups
  by prefix). Every failing test passes on rerun. Load average was
  ~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
  TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
  10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
  agent failed four tests that still expected the old ids
  (TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
  TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
  Reseat bug above. After the fix, go test -count=1 -timeout 120m
  ./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
  the routing files pass, except routing-bodies, routing-model-rest,
  routing-keys-fold and routing-request-metrics, which fail the same with
  33dbdcc52's JS.

Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.

Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
2026-10-20 00:18:51 +08:00
yetone 8d36b60c79 agent: OpenCode's magpie models leave out the legacy attachment flag that OpenCode 2 warns on at every load (#2209, tsugumi42)
OpenCode 2 reads the shared ~/.config/opencode/opencode.json and drops
the V1 model field `attachment` with a "configuration normalization
diagnostic ... omitted unsupported legacy setting" WARN per model on
every load. magpie wrote attachment: true on each image model. Nothing in
OpenCode 1.18.34 reads it for behaviour: image input comes from
`modalities`, which magpie still writes and OpenCode 2 normalizes
silently. A rewrite takes the models map whole, so an old attachment key
goes too.

`reasoning` stays: OpenCode 1 reads it for the effort variants (#725),
so OpenCode 2 still warns on it for models marked reasoning.

Run:
- TestOpenCode image-input tests seed an old attachment key and check it
  is gone; red without the fix ("still has attachment"), green with it.
- Real OpenCode 2.0.25 (`opencode models --standalone --print-logs
  --log-level warn`) in a sandbox HOME on the written config: WARN for
  attachment before, none after.
- OpenCode 1.18.34 source read: no reader of capabilities.attachment for
  behaviour.
- gofmt -l; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test ./... : all green except internal/provider, which hit the
  10-minute timeout at load ~274; alone with -timeout 25m it passed (341s).

Not tried: sending an image prompt through OpenCode 2.
2026-10-15 00:11:39 +08:00
yetone 0361189f9e test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass. 2026-10-01 23:15:07 +08:00
cyxer000 007a84964a agents: omp takes magpie's vision models for text-only (#327)
magpie's models.yml entries had no input or maxTokens, so omp fell back to a fuzzy-matched bundled model or text-only / 16384. Write input from the model's image answer (omitted when unknown) and maxTokens from its output limit; carry ImageInput through magpieModels.
2026-09-30 22:13:50 +08:00
yetone 73be42eca8 models: each agent can be shown only some of them — a provider or group gets a family (magpie provider set relay-x family=relay), and magpie visible zcode relay shows zcode only that family's models (or named providers and groups): in the files magpie writes for it and in what /v1/models answers it, told apart by its User-Agent; magpie models zcode lists what it is shown and what is kept from it, and magpie visible zcode all shows it everything again. A model kept from an agent is still served when asked for by name. Asked for on Discord 2026-09-26 16:02:29 +08:00
herrkaefer b5d47ca5e7 gateway: an image sent to a model that can't see is dealt with before it goes out, and one a tool returned no longer ends the chat (#56)
A model's image input is taken from models.dev and the provider's own list, and a group's from its members: only a model known to be text-only is refused an image — one whose support is unknown still gets it, and Codex, OpenCode and Pi are told which models take images. An image the user attaches for a text-only model answers 400 in the client's own format before the upstream is asked; an image earlier in the chat, or one a tool returned (Claude Code's Read, Codex's view_image, a Chat tool message), becomes a short text note, so a chat that met a picture carries on after a switch to a text-only model. Thanks @herrkaefer.
2026-09-25 15:39:56 +08:00