diff --git a/packages/workbuddy/README.md b/packages/workbuddy/README.md index 14be472..64c99cc 100644 --- a/packages/workbuddy/README.md +++ b/packages/workbuddy/README.md @@ -286,6 +286,17 @@ client sends it: WorkBuddy doesn't think when a chat names none, so OpenCode's default variant got answers without thinking. An effort the client names, `none` too, goes as it came. +Two values differ from the config, each measured with real requests: + +- DeepSeek-V4.1-Flash (and its paid `-sg` id) lists `none`, though the + config says it only reasons: WorkBuddy answers `reasoning_effort: "none"` + on it with no thinking at all (since 0.2.7, #563). +- On `workbuddy` (copilot.tencent.com), DeepSeek-V4.1-Flash's context is + 100000, not the config's 1000000: a longer prompt is refused with + "prompt is too long: … > 100000 maximum", while GLM-5.3-Flash on the same + endpoint takes the million. `workbuddy-ai` takes the million on it + (since 0.2.7, #561). + A chat goes gzipped (`Content-Encoding: gzip`), as WorkBuddy's own client sends its model requests (`RequestBodyGzip` in both builds' product.json). Claude's Messages route goes as it came, and so does anything that isn't a diff --git a/packages/workbuddy/deepseek-flash.test.mjs b/packages/workbuddy/deepseek-flash.test.mjs new file mode 100644 index 0000000..f36a286 --- /dev/null +++ b/packages/workbuddy/deepseek-flash.test.mjs @@ -0,0 +1,67 @@ +// deepseek-v4.1-flash as each build serves it, against each build's own +// /v3/config (testdata/config-561.json: copilot.tencent.com's and +// www.workbuddy.ai's, 2026-10-31, cut to the models compared here). +// plugins#561: the China build turns a prompt over 100000 tokens away on +// it, though its config says 1000000; glm-5.3-flash on the same endpoint +// takes the million, and WorkBuddy AI's deepseek-v4.1-flash took 181,887. +// plugins#563: it takes reasoning_effort "none" (0 reasoning tokens), +// though the config says onlyReasoning, so it lists an off level. +import { afterEach, expect, test } from "bun:test" +import { readFileSync } from "node:fs" +import { _internal } from "./index.mjs" + +const real = globalThis.fetch +afterEach(() => (globalThis.fetch = real)) + +const configs = JSON.parse(readFileSync(new URL("./testdata/config-561.json", import.meta.url), "utf8")) + +async function listed(site) { + globalThis.fetch = async () => new Response(JSON.stringify(configs[site])) + const out = await _internal.liveModels(_internal.SITES[site], { access: "a", uid: "u" }) + return Object.fromEntries(out.map((m) => [m.id, m])) +} + +test("the China build's deepseek-v4.1-flash takes 100000 tokens, its other models what the config says", async () => { + const m = await listed("workbuddy") + expect(m["deepseek-v4.1-flash"].context).toBe(100000) + expect(m["glm-5.3-flash"].context).toBe(1000000) + expect(m["deepseek-v4-pro"].context).toBe(1000000) +}) + +test("WorkBuddy AI's deepseek-v4.1-flash keeps the config's million", async () => { + const m = await listed("workbuddy-ai") + expect(m["deepseek-v4.1-flash"].context).toBe(1000000) + expect(m["deepseek-v4.1-flash-sg"].context).toBe(1000000) +}) + +test("a config smaller than the cap is kept", () => { + const site = _internal.SITES.workbuddy + expect(_internal.contextOf(site, "deepseek-v4.1-flash", 64000)).toBe(64000) + expect(_internal.contextOf(site, "deepseek-v4.1-flash", undefined)).toBe(100000) + expect(_internal.contextOf(site, "glm-5.3-flash", 1000000)).toBe(1000000) +}) + +test("the China build's own model list caps it too", () => { + const cn = _internal.configModels(_internal.SITES.workbuddy) + expect(cn["deepseek-v4.1-flash"].limit.context).toBe(100000) + expect(cn["glm-5.3-flash"].limit.context).toBe(1000000) +}) + +test("deepseek-v4.1-flash lists none on both builds, its paid id too", async () => { + const cn = await listed("workbuddy") + const ai = await listed("workbuddy-ai") + expect(cn["deepseek-v4.1-flash"].efforts).toEqual(["none", "low", "high", "max"]) + expect(ai["deepseek-v4.1-flash"].efforts).toEqual(["none", "low", "high", "max"]) + expect(ai["deepseek-v4.1-flash-sg"].efforts).toEqual(["none", "low", "high", "max"]) + // its default stays what the config says + expect(cn["deepseek-v4.1-flash"].effort).toBe("high") + expect(Object.keys(_internal.configModels(_internal.SITES.workbuddy)["deepseek-v4.1-flash"].variants)).toEqual(["none", "low", "high", "max"]) +}) + +test("glm-5.3-flash, which can't turn thinking off, still lists no none", async () => { + const cn = await listed("workbuddy") + const ai = await listed("workbuddy-ai") + expect(cn["glm-5.3-flash"].efforts).toEqual(["low", "high", "max"]) + expect(ai["glm-5.3-flash"].efforts).toEqual(["low", "high", "max"]) + expect(cn["deepseek-v4-pro"].efforts).toEqual(["none", "high", "xhigh"]) +}) diff --git a/packages/workbuddy/efforts.test.mjs b/packages/workbuddy/efforts.test.mjs index c8d1723..c2212bd 100644 --- a/packages/workbuddy/efforts.test.mjs +++ b/packages/workbuddy/efforts.test.mjs @@ -24,7 +24,7 @@ test("a model that says only supportsReasoning and a default takes low, high, ma expect(e["kimi-k3"]).toEqual(["low", "medium", "high", "max"]) expect(e["gemini-3.5-flash"]).toEqual(["low", "medium", "high", "max"]) expect(e["primary-model"]).toEqual(["low", "high", "max"]) - expect(e["deepseek-v4.1-flash-sg"]).toEqual(["low", "high", "max"]) + expect(e["deepseek-v4.1-flash-sg"]).toEqual(["none", "low", "high", "max"]) // it takes none (plugins#563) }) test("listed efforts are kept as they are, and a model that doesn't reason gets none", async () => { diff --git a/packages/workbuddy/index.mjs b/packages/workbuddy/index.mjs index 797c690..ffa6265 100644 --- a/packages/workbuddy/index.mjs +++ b/packages/workbuddy/index.mjs @@ -28,7 +28,7 @@ const CN_MODELS = [ ["hy4-preview-f", "Hy4 preview", 1000000, ["high"]], ["hy3", "Hy3", 192000, ["low", "high"]], ["hy3-x", "Hy3-X", 192000, ["low", "high"]], - ["deepseek-v4.1-flash", "Deepseek-V4.1-Flash", 1000000], + ["deepseek-v4.1-flash", "Deepseek-V4.1-Flash", 1000000, ["none", "low", "high", "max"]], ["glm-5.3", "GLM-5.3", 1000000, ["low", "high", "max"]], ["glm-5.3-flash", "GLM-5.3-Flash", 1000000, ["low", "high", "max"]], ["glm-5.2", "GLM-5.2", 1000000, ["high", "xhigh"]], @@ -81,6 +81,9 @@ const SITES = { // where this build's API keys are made (see keyAccount) keys: "https://www.workbuddy.cn/profile/keys", models: CN_MODELS, + // the prompt a model takes here, where it is less than the config's + // maxInputTokens (see contextOf) + contextCap: { "deepseek-v4.1-flash": 100000 }, // it serves the Claude models on Anthropic's Messages API too (see // nativeOf) messages: true, @@ -109,6 +112,33 @@ const SITES = { }, } +// contextOf is the prompt site takes for model: the config's +// maxInputTokens, or less where the site turns a longer prompt away. +// copilot.tencent.com's /v3/config gives deepseek-v4.1-flash 1000000, but +// its chat answers a prompt over 100000 tokens with 400 "prompt is too long: +// 100001 tokens > 100000 maximum" (plugins#561: 11 times on two accounts; +// the largest prompt it took was 76,065), while glm-5.3-flash on the same +// endpoint took 954,019. A client planning against 1M grows its thread +// past 100k and then can't compact it either, as the compaction resends it +// whole. WorkBuddy AI is not capped so: www.workbuddy.ai's +// deepseek-v4.1-flash took a 181,887-token prompt (measured 2026-10-31), +// so only the China build has the cap. +function contextOf(site, model, said) { + const cap = site.contextCap?.[model] + if (!cap) return said + return typeof said === "number" && said > 0 ? Math.min(said, cap) : cap +} + +// OFF_TAKEN are models that turn thinking off for reasoning_effort "none" +// though the config says onlyReasoning (so WorkBuddy's own client offers no +// off switch): deepseek-v4.1-flash, and the same model under its paid id. +// Measured 2026-10-31 on www.workbuddy.ai: "none" answered 200 with 0 +// reasoning tokens on both, where "low" thought 1221 and 1127; and on the +// China build by the reporter of plugins#563 (0 reasoning tokens, a 30-item +// prompt in 14s instead of 50s). Without the level magpie sends "low" for +// a client's "none". +const OFF_TAKEN = new Set(["deepseek-v4.1-flash", "deepseek-v4.1-flash-sg"]) + // textOnly says whether site drops the images sent to model, whatever its // config says. On 2026-10-13, with a real WorkBuddy AI account (Yirasumi on // Discord), www.workbuddy.ai's /v3/config marked every model @@ -2930,7 +2960,7 @@ function variants(efforts) { function configModels(site) { return Object.fromEntries(site.models.map(([id, name, context, efforts]) => [id, { name, - limit: { context, output: 0 }, + limit: { context: contextOf(site, id, context), output: 0 }, tool_call: true, // OpenCode (and magpie's host) read a config model's package and URL // from provider: { npm, api }, not api @@ -3125,14 +3155,15 @@ async function liveModels(site, a) { const d = (cfg.models ?? []).find((x) => x.id === id) const m = { id, name: d?.name || id } if (d) { - m.context = d.maxInputTokens + m.context = contextOf(site, id, d.maxInputTokens) m.output = d.maxOutputTokens m.images = d.supportsImages === true && !textOnly(site, id) Object.assign(m, priceOf(d, cfg.modelPromotions)) const es = effortsOf(d, site, id) if (es.length) { const canOff = d.reasoning?.canDisableThinking - m.efforts = [...(!d.onlyReasoning && (canOff == null || canOff) ? ["none"] : []), ...es] + const off = (!d.onlyReasoning && (canOff == null || canOff)) || OFF_TAKEN.has(id) + m.efforts = [...(off ? ["none"] : []), ...es] const def = defaultEffortOf(d, es) if (def) m.effort = def } @@ -3759,4 +3790,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy) export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"]) // for tests -export const _internal = { idFor, replyAfterToolsOn, withDefaultEffort, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, rowTime, rowAccount, ofAccount, windowOffset, windowReset, FREE_WINDOW_MODELS, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM } +export const _internal = { idFor, contextOf, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, rowTime, rowAccount, ofAccount, windowOffset, windowReset, FREE_WINDOW_MODELS, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM } diff --git a/packages/workbuddy/package.json b/packages/workbuddy/package.json index 99aee1e..ed9df0f 100644 --- a/packages/workbuddy/package.json +++ b/packages/workbuddy/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-workbuddy-auth", - "version": "0.2.6", + "version": "0.2.7", "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)", "type": "module", "main": "./index.mjs", diff --git a/packages/workbuddy/testdata/config-561.json b/packages/workbuddy/testdata/config-561.json new file mode 100644 index 0000000..6e7e2c7 --- /dev/null +++ b/packages/workbuddy/testdata/config-561.json @@ -0,0 +1,252 @@ +{ + "workbuddy": { + "code": 0, + "msg": "OK", + "data": { + "agents": [ + { + "name": "cli", + "models": [ + "deepseek-v4.1-flash", + "glm-5.3-flash", + "deepseek-v4-pro" + ] + } + ], + "models": [ + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 600000, + 1000000 + ] + }, + "credits": "x0.08", + "id": "glm-5.3-flash", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 131072, + "name": "GLM-5.3-Flash", + "onlyReasoning": true, + "reasoning": { + "canDisableThinking": false, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high", + "max" + ] + }, + "relatedModels": { + "builtin-lite": "wb-lite", + "lite": "glm-5.3-flash", + "reasoning": "glm-5.3-flash" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + }, + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 600000, + 1000000 + ] + }, + "credits": "x0.11", + "id": "deepseek-v4.1-flash", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "DeepSeek-V4.1-Flash", + "onlyReasoning": true, + "reasoning": { + "canDisableThinking": true, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high", + "max" + ] + }, + "relatedModels": { + "builtin-lite": "wb-lite", + "lite": "deepseek-v4.1-flash", + "reasoning": "deepseek-v4.1-flash" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + }, + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 600000, + 1000000 + ] + }, + "credits": "x0.51", + "id": "deepseek-v4-pro", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "DeepSeek-V4-Pro", + "onlyReasoning": false, + "reasoning": { + "canDisableThinking": true, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "high", + "xhigh" + ] + }, + "relatedModels": { + "builtin-lite": "wb-lite", + "lite": "deepseek-v4-pro", + "reasoning": "deepseek-v4-pro" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + } + ] + } + }, + "workbuddy-ai": { + "code": 0, + "msg": "OK", + "data": { + "agents": [ + { + "name": "cli", + "models": [ + "deepseek-v4.1-flash", + "deepseek-v4.1-flash-sg", + "glm-5.3-flash" + ] + } + ], + "models": [ + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 1000000 + ] + }, + "credits": "x0.00", + "id": "deepseek-v4.1-flash", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "Deepseek-V4.1-Flash", + "onlyReasoning": true, + "reasoning": { + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high", + "max" + ] + }, + "relatedModels": { + "lite": "deepseek-v4.1-flash", + "reasoning": "deepseek-v4.1-flash" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + }, + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 1000000 + ] + }, + "credits": "x0.03", + "id": "deepseek-v4.1-flash-sg", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "Deepseek-V4.1-Flash", + "onlyReasoning": true, + "reasoning": { + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high", + "max" + ] + }, + "relatedModels": { + "lite": "deepseek-v4.1-flash-sg", + "reasoning": "deepseek-v4.1-flash-sg" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + }, + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 1000000 + ] + }, + "credits": "x0.08", + "id": "glm-5.3-flash", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 32000, + "name": "GLM-5.3-Flash", + "onlyReasoning": true, + "reasoning": { + "canDisableThinking": true, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high", + "max" + ] + }, + "relatedModels": { + "builtin-lite": "wb-lite", + "lite": "glm-5.3-flash", + "reasoning": "glm-5.3-flash" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + } + ] + } + } +} \ No newline at end of file