Commit Graph
1 Commits
Author SHA1 Message Date
yetone e4ac5e8712 zcode: models magpie writes have native web search on, and a model the user unticked stays off (Gearclickist on Discord)
Gearclickist (#help, 10-19): every model magpie writes into ZCode came
without web search, and each had to be ticked by hand in its settings.

ZCode 3.14 keeps the switch ("原生联网搜索") as
config.properties.supportsNativeWebSearch on a model rule in
provider_config.json (read from ZCode.app's own bundle). It only works
with an anthropic-messages provider, where ZCode sends a
web_search_20260209 tool, which the gateway already serves; on other
formats ZCode's WebSearch throws. Unticking writes nothing: ZCode drops
the key from magpie's rule because false is its default.

zcodeRules now:
- turns it on for each model magpie lists, on Anthropic Messages only,
  including rules an older magpie wrote without the key;
- remembers which models it turned on in the stash (zcode.web_search),
  so a model whose key went missing was unticked by the user and stays
  off on every later sync;
- keeps any value already in the rule, true or false;
- leaves manualProviderModelRules alone and drops those ids from the list;
- on another format takes back only its own true;
- turns nothing on when stash.json can't be read or parsed (unknown);
- forgets the list on disconnect.
config.json (pre-3.14 shape) has no such field and is unchanged.

Known gap, not fixed here: other edits a user makes in ZCode to a model
magpie lists (JSON output, mid-conversation system, context window) land
in the same rule and are still rewritten on sync.

Run at this head:
- TestZCodeWebSearch (new) fails on the old zcode.go ("first sync: pro is
  <nil>, want true"). Broken by hand, it goes red at each guard: the
  untick check removed ("unticked: flash is true"), the take-back on
  another format removed ("chat completions: pro is true"), and an
  unreadable stash read as empty ("unreadable stash: flash is true").
- go test -run TestZCode ./internal/agent/: ok.
- gofmt -l .: clean. go vet ./... on darwin, GOOS=linux -tags nogui,
  GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... (sandbox HOME, at 94df23926
  + this change, load average ~180 from six other sessions' suites): 63
  packages ok; internal/agent hit the 45m timeout, stacks show
  TestClaudeBehindLocalProxyKeepsIt running for 15s, no hang (the known
  #2723/#2544). Rerun alone: go test -timeout 45m ./internal/agent/ ok,
  1633s.

Not tried: the real ZCode app (no live config touched); the sync was
run only against provider_config.json files written in a sandbox HOME
in the shape ZCode 3.14 writes.
2026-10-20 00:45:12 +08:00