workbuddy 0.2.8: deepseek-v4.1-flash takes the config's million on copilot.tencent.com again (#561)
0.2.7 capped deepseek-v4.1-flash's context at 100000 on the China build (SITES.workbuddy.contextCap, contextOf) from one report's error text, "prompt is too long: 100001 tokens > 100000 maximum", which I could not check myself. It was wrong for every other account we have numbers for. On 2026-10-31, on copilot.tencent.com with China Free-plan accounts (#561): - CNife: 110,041, 200,041, 500,041 and 900,041 prompt tokens, all 200; a 900,077-token prompt with needles at 5/40/75/99.5% recalled all four. - 1529119384: 82,767 to 992,389 tokens, all 200 with a needle at position 0 recalled; 1,157,831 answered 400 "prompt is too long: 1157831 tokens > 1048576 maximum", the vendor's own ceiling. After the 0.2.7 update the cap hurt their compaction. - UNscientific-9: 153,501 and 203,021 tokens, 200 on four accounts. brickhao on Discord said 100k compacts far too often. The cap and contextOf are gone: both sites list the config's maxInputTokens (1000000) for it, as for every other model. #563's none level from 0.2.7 stays. No cap in its place: a prompt WorkBuddy does find too long is its own 400, which the plugin already passes on as it came (explained leaves it alone, X-Magpie-Sign-In kept). magpie's tooLongRe matches "prompt is too long", so overflowed() makes it context_length_exceeded for the agent to compact, and retryable() says false for it, so no account is rested or asked again. The new tests hold that passthrough. Run: - deepseek-flash.test.mjs against 0.2.7's index.mjs on mote: 3 fail (the China million, a 1048576 config listed as given, no site caps), 5 pass; against this one: 8 pass. - Broken by hand: explained() treating "too long" as credits exhausted turns both passthrough tests red (2 fail). - The workbuddy package on mote, HOME=$(mktemp -d) bun test: 299 pass, 0 fail. - bun scripts/check.mjs on mote: ok. Not tried: a real request on copilot.tencent.com (my CN sign-ins still answer 401); the numbers above are the testers'. The passthrough test's envelopes are WorkBuddy's {code, msg, extError} as it words other 400s and the bare OpenAI shape; only the message text is the vendor's literal.
This commit is contained in:
@@ -286,16 +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:
|
||||
One value differs from the config, 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).
|
||||
|
||||
- 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 model's context is the config's `maxInputTokens` on both sites. 0.2.7
|
||||
capped DeepSeek-V4.1-Flash at 100000 on `workbuddy` (copilot.tencent.com)
|
||||
from one report's error; China accounts took prompts up to 992,389 tokens
|
||||
on it, so 0.2.8 lifted the cap (#561). A prompt WorkBuddy does find too
|
||||
long ("prompt is too long: … > … maximum") is answered with its own 400,
|
||||
passed on as it came, which magpie takes as the context overflowing.
|
||||
|
||||
A chat goes gzipped (`Content-Encoding: gzip`), as WorkBuddy's own client
|
||||
sends its model requests (`RequestBodyGzip` in both builds' product.json).
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
// 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#561: 0.2.7 capped it at 100000 on the China build from one
|
||||
// report's error. China Free-plan accounts of three other users took
|
||||
// 110,041 to 992,389-token prompts there, and the vendor's own refusal of
|
||||
// a 1,157,831-token one named 1048576 as the maximum, so both builds give
|
||||
// it the config's million again (0.2.8), and a prompt WorkBuddy finds too
|
||||
// long is its own 400, passed on as it came.
|
||||
// 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"
|
||||
import { WorkBuddyAuthPlugin, _internal } from "./index.mjs"
|
||||
import { unz } from "./testdata/unz.mjs"
|
||||
|
||||
const real = globalThis.fetch
|
||||
afterEach(() => (globalThis.fetch = real))
|
||||
@@ -21,9 +25,9 @@ async function listed(site) {
|
||||
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 () => {
|
||||
test("the China build's deepseek-v4.1-flash takes the config's million, as its other models do", async () => {
|
||||
const m = await listed("workbuddy")
|
||||
expect(m["deepseek-v4.1-flash"].context).toBe(100000)
|
||||
expect(m["deepseek-v4.1-flash"].context).toBe(1000000)
|
||||
expect(m["glm-5.3-flash"].context).toBe(1000000)
|
||||
expect(m["deepseek-v4-pro"].context).toBe(1000000)
|
||||
})
|
||||
@@ -34,19 +38,54 @@ test("WorkBuddy AI's deepseek-v4.1-flash keeps the config's million", async () =
|
||||
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("a context the config gives is what is listed, whatever its size", async () => {
|
||||
const cfg = structuredClone(configs.workbuddy)
|
||||
for (const d of cfg.data.models) if (d.id === "deepseek-v4.1-flash") d.maxInputTokens = 1048576
|
||||
globalThis.fetch = async () => new Response(JSON.stringify(cfg))
|
||||
const out = await _internal.liveModels(_internal.SITES.workbuddy, { access: "a", uid: "u" })
|
||||
expect(out.find((m) => m.id === "deepseek-v4.1-flash").context).toBe(1048576)
|
||||
})
|
||||
|
||||
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("neither build caps a model below its config", () => {
|
||||
for (const site of ["workbuddy", "workbuddy-ai"]) {
|
||||
expect(_internal.SITES[site].contextCap).toBeUndefined()
|
||||
const listed = _internal.configModels(_internal.SITES[site])
|
||||
for (const [id, , context] of _internal.SITES[site].models) expect(listed[id].limit.context).toBe(context)
|
||||
}
|
||||
expect(_internal.configModels(_internal.SITES.workbuddy)["deepseek-v4.1-flash"].limit.context).toBe(1000000)
|
||||
})
|
||||
|
||||
// The refusal's words are the ones 1529119384 got from copilot.tencent.com
|
||||
// (plugins#561); the envelope around them is WorkBuddy's {code, msg,
|
||||
// extError} as it words other 400s, and the bare OpenAI shape.
|
||||
const TOO_LONG = "prompt is too long: 1157831 tokens > 1048576 maximum"
|
||||
for (const [shape, body] of [
|
||||
["WorkBuddy's own envelope", { code: 11102, msg: TOO_LONG, extError: { code: "400001", message: TOO_LONG, type: "invalid_request_error", StatusCode: 400 } }],
|
||||
["an OpenAI error", { error: { message: TOO_LONG, type: "invalid_request_error" } }],
|
||||
]) {
|
||||
test(`a prompt WorkBuddy finds too long is its 400 as it came, once, the sign-in kept (${shape})`, async () => {
|
||||
const sent = []
|
||||
globalThis.fetch = async (_url, init) => {
|
||||
sent.push(JSON.parse(unz(init.body)))
|
||||
return new Response(JSON.stringify(body), { status: 400, headers: { "content-type": "application/json" } })
|
||||
}
|
||||
const hooks = await WorkBuddyAuthPlugin({ client: {} })
|
||||
const loader = await hooks.auth.loader(async () => ({ type: "oauth", access: "access", uid: "uid", expires: Date.now() + 3600_000 }))
|
||||
const res = await loader.fetch("https://copilot.tencent.com/v2/chat/completions", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ model: "deepseek-v4.1-flash", stream: true, messages: [{ role: "user", content: "hi" }] }),
|
||||
})
|
||||
expect(sent.length).toBe(1)
|
||||
expect(res.status).toBe(400)
|
||||
expect(res.headers.get("X-Magpie-Sign-In")).toBe("kept")
|
||||
// word for word, so magpie reads it as the context overflowing (its
|
||||
// tooLongRe: "prompt is too long"), not as quota or a refusal
|
||||
const text = await res.text()
|
||||
expect(JSON.parse(text)).toEqual(body)
|
||||
expect(text).not.toMatch(/insufficient_quota|permission_error/)
|
||||
})
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
@@ -81,9 +81,6 @@ 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,
|
||||
@@ -112,22 +109,17 @@ 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
|
||||
}
|
||||
// A model's context is its config's maxInputTokens, on both sites. 0.2.7
|
||||
// capped deepseek-v4.1-flash at 100000 on copilot.tencent.com from one
|
||||
// report's error ("prompt is too long: 100001 tokens > 100000 maximum"),
|
||||
// and it was wrong: on 2026-10-31 China Free-plan accounts of three other
|
||||
// users took 110,041 to 992,389-token prompts on it there, the whole prompt
|
||||
// read (needles recalled), and the vendor's own refusal of 1,157,831 named
|
||||
// 1048576 as the maximum (plugins#561). The cap made every client compact at
|
||||
// 100k. Where a prompt really is too long, WorkBuddy's 400 says "prompt is
|
||||
// too long" and goes to the client as it came (explained), which magpie
|
||||
// reads as the context overflowing (context_length_exceeded): the agent is
|
||||
// told to compact, and the account isn't rested for it.
|
||||
|
||||
// OFF_TAKEN are models that turn thinking off for reasoning_effort "none"
|
||||
// though the config says onlyReasoning (so WorkBuddy's own client offers no
|
||||
@@ -2960,7 +2952,7 @@ function variants(efforts) {
|
||||
function configModels(site) {
|
||||
return Object.fromEntries(site.models.map(([id, name, context, efforts]) => [id, {
|
||||
name,
|
||||
limit: { context: contextOf(site, id, context), output: 0 },
|
||||
limit: { 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
|
||||
@@ -3155,7 +3147,7 @@ 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 = contextOf(site, id, d.maxInputTokens)
|
||||
m.context = d.maxInputTokens
|
||||
m.output = d.maxOutputTokens
|
||||
m.images = d.supportsImages === true && !textOnly(site, id)
|
||||
Object.assign(m, priceOf(d, cfg.modelPromotions))
|
||||
@@ -3790,4 +3782,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
||||
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
||||
|
||||
// for tests
|
||||
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 }
|
||||
export const _internal = { idFor, 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 }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-workbuddy-auth",
|
||||
"version": "0.2.7",
|
||||
"version": "0.2.8",
|
||||
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user