agent: a reasoning effort picked in VS Code's Copilot Chat survives magpie's sync (chim3744 on Discord)
chim3744 (magpie 0.1.1318) picked "max" for a magpie model in Copilot
Chat's model picker, and requests went out at "low".
Cause: VS Code 1.142 keeps that pick inside the provider group, as
settings["<model id>"].reasoningEffort (languageModels.ts
setModelConfiguration). magpie's setGroup built its group with
vscodeGroupJSON, which has no settings key, compared the whole object
with sameJSON, and edit.SetJSONItem replaced the whole group. Every Sync
(catalog.Changed on start, a vendor list fetch, a provider edit) and
every magpie model pick in VS Code wiped the pick, and Copilot Chat fell
back to the model's first level ("low" of [low, high, max]).
Fix: vscodeGroupKept lays magpie's group over the one in the file with
mergeTheirs, as theirsKept does for the other agents (#2030). Every key
magpie doesn't write stays: settings, and anything else VS Code or the
user puts there, such as an apiKey reference. The models list stays
magpie's whole, so a model gone from the catalog still leaves it. The
settings of a model magpie no longer lists are kept, since they are the
user's values. When nothing magpie owns changed, the compare is a no-op
and the file is not written. This covers VS Code, VS Code Insiders and
VSCodium (customendpoint and customoai), every profile, since all go
through setGroup. agent-wiring.md lists what is kept.
Siblings checked:
- chatLanguageModels.json is written only by vscode.go. Cursor
(cursorlocal.go) writes nothing of Cursor's. magpie writes no
language-model groups for Windsurf, Trae or Kiro IDE.
- Every other syncJSON caller in internal/agent already merges through
theirsKept, piBlockKept, openCodeKept, mothxBlockKept, qoderKept or
t3Merged (2eee900dc, #2030's siblings). That covers Pi, Crush, Ante,
Aside, MothX, StepCode, OpenCode, Qoder, Cline, Command Code, Pencil
and T3 Code. The exception is Zed's available_models. That is
magpie's model list, an array, and Zed keeps the model the user picked
in agent.default_model, outside it.
Test: TestVSCodeKeepsThePickedEffort. It writes the group as VS Code
does after a pick (settings for a listed model and for one no longer
listed), then runs a Sync with nothing changed (the file must stay byte
for byte), a Sync after the catalog gained a model, a magpie model pick,
and a Sync after a model went (the list shrinks and both settings stay).
With the fix broken by hand (want = v, the old whole rewrite) it fails:
"vscode_test.go:550: a sync with nothing changed: the picked effort is
"", want max". With the fix restored it passes.
Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
68 packages ok. The one red was internal/gui's
TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
app.js under the stack. The autoscroll commit's own comments were cut
(to 1,334,629) rather than the budget raised, and go test -count=1
./internal/gui is ok at this head (113s). Packages the run took from
Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
202 of 204 pass (tree 068acf128, this push less the last commit). The
two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
chromium "several accounts" (#2163, red on main the same way).
- internal/agent ok in that run, TestVSCodeKeepsThePickedEffort with it.
- No GUI file reaches this change; the GUI suite's reds below are none of
its.
The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
alone at the stack and at origin/main 8278fd9b0. Eight are red the same
way on main: plugin-card-update (#3079), quota-count-wrap and
quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
(#2276), usage-checkin (#3091), usage-fold's chromium "several
accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
and were red only under that run's load (50 to 335): currency #3101,
plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
routing-wb-restricted #1905, sessions-folder-delete #2218,
sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
#3296.
Not tried: real VS Code/Copilot Chat.
This commit is contained in:
@@ -52,6 +52,7 @@ something else shows up as drift.
|
||||
- omp's `models.yml` keeps `modelOverrides`, `discovery`, `disableStrictTools`, headers and compat flags (`ompKept`). Its `auth` and `apiKey` are magpie's, or gone.
|
||||
- Kimi Code's `[providers.magpie]` has magpie's three keys set in place, so `custom_headers`, `env` and `default_model` stay (`kimiProvider`).
|
||||
- Cline's `models.json` keeps the provider's other keys, and on each model magpie lists what magpie doesn't write, such as a VS Code override (`clineKept`).
|
||||
- VS Code's, Insiders' and VSCodium's group in `chatLanguageModels.json` (each profile's too) keeps every key magpie doesn't write, such as `settings["<model id>"].reasoningEffort`, which VS Code writes there when the user picks an effort in Copilot Chat's model picker (`setModelConfiguration`); a whole rewrite on each Sync and pick sent the model at its first level (chim3744 on Discord). A model's settings stay after it leaves the catalog; the model list is magpie's (`vscodeGroupKept`, `TestVSCodeKeepsThePickedEffort`).
|
||||
- Goose's custom provider file keeps a name, `timeout_seconds`, `toolshim`, headers and the like (`gooseProviderKept`).
|
||||
- ZCode's provider rule keeps its name, logo, visibility, API headers and the key's management link (`zcodeRules`).
|
||||
- Each model magpie writes into ZCode's `providerModelRules` has native web search (`properties.supportsNativeWebSearch`, "原生联网搜索") on while the provider's format is Anthropic Messages, the only format ZCode sends it on (`zcodeWebSearch`). The models magpie turned it on for are kept in the stash under `zcode.web_search`, so a model the user unticked in ZCode (which takes the key out of the rule) stays off, a value in the rule stays, a manual rule is left alone, and a stash that can't be read turns nothing on. On another format magpie's own on is taken out. Disconnect forgets the list.
|
||||
|
||||
@@ -201,10 +201,13 @@ func vscodeKindAt(k vscodeKind, dir string) *Agent {
|
||||
}
|
||||
}
|
||||
}
|
||||
if cur, ok := edit.GetJSONItem(lm, vscodeGroupOf(vendor)); ok && sameJSON(cur, v) {
|
||||
continue
|
||||
var want any = v
|
||||
if cur, ok := edit.GetJSONItem(lm, vscodeGroupOf(vendor)); ok {
|
||||
if want = vscodeGroupKept(cur, v); sameJSON(cur, want) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if err := edit.SetJSONItem(lm, vscodeGroupOf(vendor), v); err != nil {
|
||||
if err := edit.SetJSONItem(lm, vscodeGroupOf(vendor), want); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -453,6 +456,24 @@ func vscodeGroupJSON(k vscodeKind, vendor string) map[string]any {
|
||||
return map[string]any{"name": magpieID, "vendor": vscodeEndpoint, "apiType": "chat-completions", "models": list}
|
||||
}
|
||||
|
||||
// vscodeGroupKept is magpie's group v laid over the one in the file, cur,
|
||||
// with every key of cur magpie doesn't write kept: VS Code itself writes
|
||||
// the reasoning effort picked for a model in Chat's model picker into the
|
||||
// group, as settings["<model id>"].reasoningEffort (languageModels.ts
|
||||
// setModelConfiguration), and a whole rewrite on each Sync and pick sent
|
||||
// that model at its first level (chim3744 on Discord: max went out as
|
||||
// low). The settings of a model magpie no longer lists stay too, as the
|
||||
// user's. The model list is magpie's whole, so a model gone from the
|
||||
// catalog leaves it.
|
||||
func vscodeGroupKept(cur string, v map[string]any) any {
|
||||
var have, want map[string]json.RawMessage
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil || json.Unmarshal([]byte(cur), &have) != nil || have == nil || json.Unmarshal(b, &want) != nil || want == nil {
|
||||
return v
|
||||
}
|
||||
return mergeTheirs(have, want, []string{"models"})
|
||||
}
|
||||
|
||||
// vscodeChatID is Copilot Chat's extension id.
|
||||
const vscodeChatID = "github.copilot-chat"
|
||||
|
||||
|
||||
@@ -500,3 +500,83 @@ func TestVSCodeChatInstalledWithoutExtensionsJSON(t *testing.T) {
|
||||
t.Fatalf("unreadable: %+v", c)
|
||||
}
|
||||
}
|
||||
|
||||
// the reasoning effort picked for a model in Copilot Chat's model picker,
|
||||
// which VS Code writes into magpie's group as
|
||||
// settings["<model id>"].reasoningEffort, stays through a Sync with nothing
|
||||
// changed, a Sync after the catalog changed and a model picked in magpie
|
||||
// (chim3744 on Discord: max went out as low, the first level, after each)
|
||||
func TestVSCodeKeepsThePickedEffort(t *testing.T) {
|
||||
home := syncHome(t)
|
||||
dir := filepath.Join(home, "vscode", "User")
|
||||
a := vscodeAt(dir)
|
||||
writeFile(t, a.Path, "{}\n")
|
||||
if err := a.Connect(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
lm := filepath.Join(dir, "chatLanguageModels.json")
|
||||
// what VS Code 1.142 writes on a pick (setModelConfiguration), with a
|
||||
// model magpie no longer lists picked before
|
||||
g, ok := edit.GetJSONItem(lm, vscodeGroup)
|
||||
if !ok {
|
||||
t.Fatalf("no group:\n%s", readFile(lm))
|
||||
}
|
||||
var group map[string]any
|
||||
if err := json.Unmarshal([]byte(g), &group); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
group["settings"] = map[string]any{
|
||||
"relay/glm-4.6": map[string]any{"reasoningEffort": "max"},
|
||||
"relay/gone": map[string]any{"reasoningEffort": "high"},
|
||||
}
|
||||
if err := edit.SetJSONItem(lm, vscodeGroup, group); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kept := func(when string) {
|
||||
t.Helper()
|
||||
g, _ := edit.GetJSONItem(lm, vscodeGroup)
|
||||
if e := gjson.Get(g, `settings.relay/glm-4\.6.reasoningEffort`).String(); e != "max" {
|
||||
t.Fatalf("%s: the picked effort is %q, want max:\n%s", when, e, g)
|
||||
}
|
||||
if e := gjson.Get(g, "settings.relay/gone.reasoningEffort").String(); e != "high" {
|
||||
t.Fatalf("%s: a gone model's effort is %q, want high:\n%s", when, e, g)
|
||||
}
|
||||
}
|
||||
|
||||
before := readFile(lm)
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kept("a sync with nothing changed")
|
||||
if readFile(lm) != before {
|
||||
t.Fatalf("a sync with nothing changed rewrote the file:\n%s\n---\n%s", before, readFile(lm))
|
||||
}
|
||||
|
||||
if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"glm-4.6", "other"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kept("a sync after the catalog changed")
|
||||
if g, _ := edit.GetJSONItem(lm, vscodeGroup); gjson.Get(g, "models.#").Int() != 2 {
|
||||
t.Fatalf("not synced: %s", g)
|
||||
}
|
||||
|
||||
if err := a.Apply("model", "magpie/relay/other"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kept("a model picked in magpie")
|
||||
|
||||
// a model gone from the catalog still leaves the list
|
||||
if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"glm-4.6"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kept("a sync after a model went")
|
||||
if g, _ := edit.GetJSONItem(lm, vscodeGroup); gjson.Get(g, "models.#").Int() != 1 {
|
||||
t.Fatalf("a gone model stayed: %s", g)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user