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.
107 lines
5.6 KiB
JavaScript
107 lines
5.6 KiB
JavaScript
// 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: 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 { WorkBuddyAuthPlugin, _internal } from "./index.mjs"
|
|
import { unz } from "./testdata/unz.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 the config's million, as its other models do", async () => {
|
|
const m = await listed("workbuddy")
|
|
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)
|
|
})
|
|
|
|
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 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("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")
|
|
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"])
|
|
})
|