workbuddy: a model over 200K offers WorkBuddy's context choice, set to its whole window

xiao9could on X: WorkBuddy shows no context button for magpie's models,
Opus included. WorkBuddy 5.5.6's CLI builds its "Context" session option
(and the renderer its 200K/1M submenu) only from a model's
contextWindow.supportedLengths with two sizes or more, each no larger
than maxInputTokens; magpie wrote maxInputTokens alone. Each entry over
200K now has supportedLengths [200000, window] and defaultLength set to
the window. defaultLength matters: without it resolveEffectiveContextBudget
takes the smallest size, which would have cut every session to 200K.
Read from /Applications/WorkBuddy.app's app.asar (cli/dist/codebuddy.js:
resolveEffectiveContextBudget, the context_window config option;
renderer lib-chat-ui: getSupportedContextWindows). The models.json loader
spreads each entry whole, so the field reaches the model config.

Run (mote): go test ./internal/agent -count=1 ok (157s); go vet
./internal/agent for darwin, linux, windows ok; gofmt clean.
Broken by hand: without the workbuddy.go change TestWorkBuddyContextChoice
fails.
Not tried: the menu in the running WorkBuddy app.
This commit is contained in:
yetone
2026-10-28 09:30:24 +08:00
parent 08b02cf18c
commit 9ba3f049e2
2 changed files with 27 additions and 0 deletions
+12
View File
@@ -9,6 +9,7 @@ package agent
// [{"id":"deepseek/pro","name":…,"vendor":"magpie","apiKey":"magpie-workbuddy",
// "url":"http://127.0.0.1:3425/v1/chat/completions",
// "maxInputTokens":…,"maxOutputTokens":…,
// "contextWindow":{"supportedLengths":[200000,…],"defaultLength":…},
// "supportsToolCall":true,"supportsImages":…,"supportsReasoning":true,
// "reasoning":{"supportedEfforts":[…],"canDisableThinking":…,"defaultEffort":…}}]
//
@@ -350,6 +351,10 @@ func buddyWriteAt(path, agent string, on bool, where place) error {
return edit.WriteAtomic(path, append(b, '\n'))
}
// buddySmallWindow is the smaller context WorkBuddy offers beside a
// model's whole window, the size its own models offer.
const buddySmallWindow = 200000
// buddyModel is one of magpie's models as a models.json entry, under
// agent's key.
func buddyModel(agent, id, name string, context, output int, images bool, efforts []string) map[string]any {
@@ -362,6 +367,13 @@ func buddyModel(agent, id, name string, context, output int, images bool, effort
"maxInputTokens": context,
"supportsToolCall": true, "supportsImages": images, "supportsReasoning": false,
}
// WorkBuddy offers a choice of context in its model menu only for a
// model whose contextWindow lists two sizes or more (its own Opus has
// 200K and 1M); the session's budget is defaultLength, or the smallest
// size when it is missing, so it is set to the whole window as before
if context > buddySmallWindow {
e["contextWindow"] = map[string]any{"supportedLengths": []int{buddySmallWindow, context}, "defaultLength": context}
}
// without it WorkBuddy caps every reply at its own default; output
// comes already trimmed (zcodeOutput) unless the user set it (outputOr)
if out := output; out > 0 {
+15
View File
@@ -126,6 +126,21 @@ func TestWorkBuddyEfforts(t *testing.T) {
}
}
// A model with more than 200K of context gets WorkBuddy's context menu,
// set to its whole window (xiao9could on X: no context button for Opus).
func TestWorkBuddyContextChoice(t *testing.T) {
e := buddyModel("workbuddy", "claude/claude-opus-5-5", "Opus", 1000000, 128000, true, nil)
cw, _ := e["contextWindow"].(map[string]any)
if l, _ := cw["supportedLengths"].([]int); len(l) != 2 || l[0] != 200000 || l[1] != 1000000 || cw["defaultLength"] != 1000000 || e["maxInputTokens"] != 1000000 {
t.Fatalf("%v", e)
}
for _, c := range []int{0, 128000, 200000} {
if e := buddyModel("workbuddy", "x/y", "Y", c, 0, false, nil); e["contextWindow"] != nil {
t.Fatalf("%d: %v", c, e)
}
}
}
// WorkBuddy pointed at a magpie on another machine stays there through a
// sync, with that magpie's key (悠悠哥 on Discord: models moved to the
// magpie on a NAS were put back on this machine's), while one on this