Commit Graph
2 Commits
Author SHA1 Message Date
yetone edff2f819a provider: levels kept of a model's own narrow only what is offered again (#92)
4a3e07f1c made provider.Efforts return the levels a user kept, so the
gateway fitted every request to them. That reversed #92 (47e12df41),
which was explicit that narrowing a model's levels changes only what is
shown and "the levels the vendor is asked at stay as they were": a user
who had trimmed a picker with `magpie model efforts` or Names & levels
would have had their agents' xhigh and max asks lowered unasked. Dani's
request (magpie model spec) needs levels to count only where magpie
knows none for the model.

- Efforts is back to what it was before 4a3e07f1c: the vendor's list's
  or models.dev's levels when known, else the ones the user declared
  (`magpie model spec --reasoning` on a custom provider's model), which
  a request is then fitted to. --reasoning off (reasonless) is as
  4a3e07f1c built it.
- TestModelEfforts' "the vendor is still asked at any level it has" is
  restored as it was.
- TestKeptLevelsBoundTheAsk becomes TestNarrowedVendorLevelsAskAsBefore:
  a models.dev-known model narrowed to low-high is offered low..high and
  still sends xhigh, max and low as asked.
- gateway-routing.md, reference.md, the settings.go comment and spec's
  usage say so: narrowing is display-only, declared levels are fitted.

Run at this tree (base 4a3e07f1c):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
  ./internal/cli ./internal/settings: ok (gateway 386s).
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Broken by hand, each red: 4a3e07f1c's Efforts (TestNarrowedVendor-
  LevelsAskAsBefore: xhigh and max went as high; TestModelEfforts:
  [low high]); declared levels ignored (TestModelSpecReachesTheGateway:
  xhigh sent as xhigh with low-high declared).
- Every other p.Efforts caller (gateway fit, decide, classify, automode,
  rules, side effort) is on the request path and is back to its
  behaviour before 4a3e07f1c.

Not run: the GUI suite (no GUI file changed; the GUI reads entry
Efforts, which still carry the kept levels) and a full go test ./....
2026-10-24 05:51:22 +08:00
yetone 4a3e07f1cf model: magpie model spec sets a model's window, output, vision and levels at once
Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models
(kenari/*:free) had no window, reply limit, vision or reasoning known,
and there was no one place to say them.

  magpie model spec <provider/model>                 what it has, and whose each value is
  magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto]
  magpie model spec '<provider>/*' --context <n> --output <n>
  magpie model spec <provider/model> --reset
  magpie model specs

It writes the stores magpie model context/output/images/efforts write
(providers.json contexts; settings.json modelOutputs, modelImages,
modelEfforts, modelReasonless), so every reader that went by those goes
by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's
/api/providers badges and chips, and the agents' model lists. Every
part is checked before anything is written; a refused command writes
nothing. Agents are told once.

Readers that bypassed the stores and now honour them:
- provider.Efforts returns the kept levels, so the gateway fits a
  request to them (fitEffort): xhigh asked of a model kept to low-high
  goes as high. This reverses #92 (47e12df41), which narrowed only the
  lists handed out; docs/subsystems/gateway-routing.md says so.
- entryFor: levels given a model with none known make it Reasoning.
- gateway AutoVision picks by the user's ModelImages (seesAt).
- GUI gateway client: a reasonless model offers no level chips.

Run at this tree (base a93190ae1):
- go test -count=1 -timeout 45m ./internal/{provider,cli,gui,gateway,
  settings,tui,agent,catalog}: all ok (gateway 505s, agent 360s).
- GUI: gateway-*.test.cjs, model-reasonless, plugin-gateway, i18n-keys
  (25 files, both engines, the new file at 1100 and 420 in en, zh,
  zh-TW, ja, de): 225/225 pass. app.js untouched.
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Sandbox HOME, built binary, `magpie web` on 47821/47820 and a fake
  Chat vendor on 47811: before, kenari/glm-5:free had no window or
  levels; after spec 128k/16k/on/low-high, /v1/models said 128000,
  16000, image input, [low medium high]; max_tokens 100000 went as
  16000, xhigh as high, low as low; qwen-x with --reasoning off was
  sent no reasoning field; /api/providers had context 128000, output
  16000, images/imageSet, kept [low medium high], reasonless for qwen-x.
  A models.dev sync during the run (GLM-5 202752/131072) didn't move
  the spec; after --reset the vendor's values came back. Bad values,
  an unknown flag and --help wrote nothing (files hashed).

Rebased onto a6a3dbde8 (the ZCode mover's min, one line): at the
pushed head 5af093d8b's tree, ./internal/provider and ./internal/cli
-timeout 45m ok, and the spec tests in gateway and gui ok.

Broken by hand, each went red: AutoVision on raw sees; Efforts on the
full list; the Reasoning line removed; output, vision or context not
written; ParseLevels skipped; agents told twice; --context 0 taken;
help printing modelUsage; old client.js; the GUI named() image and
reasonless branches.

Not tried / not changed: no full go test ./... (another session's
full GUI suite was running). Codex's ChatGPT-model /models pass-through
and the Codex effort dropdown read catalog.Codex(), not a spec. The
TUI shows no spec badges. A Context-tab trace keeps the window it was
recorded with. Pre-existing and the same on origin/main a6a3dbde8: a
GLM-5 relay with no levels known has xhigh sent as high.
2026-10-24 05:31:59 +08:00