Commit Graph
3 Commits
Author SHA1 Message Date
yetone 579de3baa0 agent: enabledModels lose a deselected model's entries after the catalog sync (#2055)
misaka9981: models deselected in a provider's editor left magpie's
provider in Pi's models.json, but their magpie/<provider>/<model>
entries stayed in settings.json's enabledModels, and Pi warned "No
models match pattern" for each at every start. Pi's resolver
(model-resolver.js resolveModelScope, 1.1.0) only warns, never prunes.

After the sync writes magpie's provider block, an enabledModels entry
that names one of magpie's models outright (no glob; a thinking level
read off) whose model the block no longer has is taken out. As the
entry may be the user's own, it is remembered in stash.json
(<agent>.scope.gone) and goes back on the list's end once the model is
offered again; a provider rename moves the remembered entries too and a
disconnect forgets them. Globs, entries on other providers and on
models still offered stay, in order, comments kept. A list left with
nothing is removed (never written []) and made again when its entries
come back, with the model picked meanwhile; a list the user removed
isn't made again. When the agent's model list can't be read, nothing
is taken out.

The same holds for the siblings with such a list: OmO and Prime Agent
(piLike), StepCode (config.toml; its wiring state's last scope follows,
so a disconnect still puts the user's list back) and omp (config.yml's
plain entries; folder-scoped entries are left alone).

Run:
- TestPiEnabledModelsLoseDeselected (pi, omo, prime-agent) with the
  reporter's provider and four models, beside the user's own entries
  (another provider at a level, a magpie glob, a model still offered
  at a level): deselect, select again, rename.
  TestPiEnabledModelsEmptiedAndBack: emptied and back; removed by the
  user stays removed; other providers' and globs' file byte for byte;
  an unreadable models.json prunes nothing.
  TestStepCodeAndOmpEnabledModelsLoseDeselected, StepCode's disconnect
  putting the original list back included.
- TestPiEnabledModelsFollowRename and TestStepCodeEnabledModelsFollowRename
  keep a magpie/deepseekx/flash entry to show a rename leaves a name
  sharing a prefix alone; deepseekx is now a real provider there, as the
  sync would otherwise (rightly) take an entry naming nothing out.
- Broken by hand, each red: Pi's, StepCode's and omp's Sync hook off;
  the put-back off; the rename of remembered entries off.
- Real Pi 1.1.0 (@earendil-works/pi-coding-agent) under a sandbox
  HOME, `pi -p`: the stale exact entries gave the reporter's warnings;
  the list as pruned gave none.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./... green on origin/main 7d15df78a. Rebased again
  over 2eee900dc (omp's Sync now keeps the user's keys, ompProvider(models);
  the conflict is that one line), then vets and ./internal/agent/ and
  ./internal/cli/ again: green but for TestReasonixCLI*, whose fixture
  build read a go1.26.8 toolchain another session was unpacking into the
  shared module cache ("internal/oserror is not in std"); both pass run
  alone right after.

Not tried: the GUI's provider editor end to end with a real Pi session,
real omp and StepCode binaries, WSL. A magpie glob that matches nothing
still gets Pi's warning: it is the user's pattern and stays.
2026-10-14 13:33:28 +08:00
yetoneandggbdpq 90ac1f0385 agent: a renamed provider's models follow it in StepCode's enabledModels (#1919, ggbdpq)
Renaming a provider moved StepCode's defaultModel to the new id and
appended it to enabledModels, but the list kept magpie/<old>/ entries
(the model it was on, others the user listed, a glob), which name nothing
after the rename. StepCode now has a RenameRefs hook, as omp has
(e6753190): it renames magpie/<old>/ entries in config.toml's
enabledModels, drops the copy the move just appended, and renames the
scopes kept for Disconnect (OrigScope, LastScope, AppendedScope), so a
reset neither puts the old id back nor leaves the appended one. An entry
that only shares a prefix (magpie/deepseekx/...) and the user's own
entries stay; a list naming none of the provider's models is not
rewritten.

ggbdpq's patch from #1919, taken as written.

Run:
- go test -tags nogui -count=1 -run 'TestStepCode' ./internal/agent: ok.
- With only the RenameRefs hook removed, TestStepCodeEnabledModelsFollowRename
  fails with the scope the issue quotes; TestStepCodeRenameLeavesUserScope
  is a guard and passes on the old code too.
- -race -count=5 on the two new tests: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok.
- The full ./internal/agent package timed out at the default 10m on a
  machine at load ~120 (many sessions testing at once); the run with
  this and the Pi sibling together is in the next commit's body.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 15:50:19 +08:00
yetoneandBUKOWSKIREAL 8b393938f5 agent: StepCode can be connected to magpie, and Disconnect puts back its own model (#1526, BUKOWSKIREAL)
StepCode (StepFun's coding CLI, `step`) is a Pi fork that keeps Pi's
settings as TOML in ~/.stepcode/config.toml and Pi's models.json beside
it. It is now an agent target: Connect sets defaultProvider/defaultModel
to magpie, appends the magpie pattern to enabledModels when the user
scopes models, and writes providers.magpie into models.json with the
per-agent key. Disconnect puts back the user's own provider, model and
scope (only the patterns magpie added are taken out if the user changed
the scope since), restores or removes providers.magpie, and removes a
models.json magpie created. STEP_CODING_AGENT_DIR and STEPCODE_CONFIG_DIR
move the folder as StepCode's own resolveStepConfigRoot does; WSL is
covered.

The patch is BUKOWSKIREAL's (7cc88463 in their fork), reviewed line by
line: no network, telemetry or credential reads, writes only to the two
StepCode files and magpie's stash. Added here: a test that StepCode's
real User-Agent, "step (darwin 25.2.0; arm64)", counts as StepCode, and
the real-CLI test now looks for a "magpie" row in `step --list-models`
rather than the word anywhere (the docs path step prints can contain it).

Run:
- Config format checked against stepfun-ai/Step-Code at 3d70bae5 and the
  official 0.1.3 darwin-arm64 binary (sha256 matches latest.json):
  `step config path --json` names ~/.stepcode/config.toml and models.json.
- Sandbox HOME, sandbox gateway on 127.0.0.1:3647: a user config with
  defaultProvider "step", step-3.7-flash, thinking high, two scoped
  models, telemetry off. `magpie stepcode magpie/deepseek/deepseek-flash`,
  then `step -p` answered PONG through the gateway (usage record: agent
  stepcode, deepseek-flash, 200). `magpie stepcode default` put
  config.toml back value for value, removed models.json, and
  `step --list-models` no longer listed magpie.
- The same round trip from the real web page (sandbox `magpie web`),
  switch on, then off through the disconnect preview, which listed the
  three values it puts back; config.toml came back byte-identical. The
  row and icon checked in Chromium and WebKit, en and zh; no GUI assets
  change.
- Broke the guarantee: with unwire never restoring the defaults,
  TestStepCodeLifecycle, ...NativeChangedAndPreexisting and
  ...StrictValidationAndRollback go red. Without the "step" alias the
  new UA check goes red.
- MAGPIE_TEST_STEPCODE_BIN=<0.1.3> go test -run TestStepCodeRealCLISandbox
  passes (it failed before the row check above).
- go test -tags nogui ./... ; gofmt -l; go vet (darwin, GOOS=linux,
  GOOS=windows) on internal/agent and internal/agentenv; go build for
  darwin, linux (nogui) and windows.
Not tried on a real Windows, Linux or WSL machine.

Co-authored-by: BUKOWSKIREAL <233685554+BUKOWSKIREAL@users.noreply.github.com>
2026-10-11 04:03:29 +08:00