The list declared before an account's own config is read (a key whose CLI reads no config, a config WorkBuddy doesn't answer) said output 0 for every model, and magpie filled in models.dev's: 384000 for deepseek-v4.1-flash, where WorkBuddy's /v3/config says maxOutputTokens 128000. Agents were told a 384000-token reply. The declared tuples take a fifth field, the output, for every model a real config in testdata names: deepseek-v4.1-flash and deepseek-v4-pro 128000 and glm-5.3-flash 131072 on workbuddy; default-model 24000, fast-model 32000, primary-model 72000, hy3 64000, gemini-3.5-flash 65536, glm-5.2 48000 and kimi-k3 32000 on workbuddy-ai. The rest stay 0 (left to models.dev, as before). The live list already carried the config's value. Run: HOME=$(mktemp -d) bun test packages/workbuddy/ on mote, 335 pass; bun scripts/check.mjs ok. Broken by hand: with index.mjs back at 0.2.25, the new test fails (hy3 64000 expected, 0 received; deepseek-v4.1-flash 0 for 128000). Not tried: a real WorkBuddy sign-in or key; the outputs of models no saved config names (hy4-preview-f, glm-5.3, kimi-k3-1, ...). Reported-by: sayagoodbyeplz (Discord)
131 lines
6.8 KiB
JavaScript
131 lines
6.8 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"])
|
|
})
|
|
|
|
// sayagoodbyeplz on Discord: WorkBuddy's deepseek-v4.1-flash read as a
|
|
// 384000-token reply. That is models.dev's, which magpie fills in for a
|
|
// model its list gives no output for: the list declared before an
|
|
// account's own is read (a key, a config that can't be read) said 0. It
|
|
// says the config's maxOutputTokens now, for every model the configs read
|
|
// give one.
|
|
test("the declared list's reply limits are the configs' maxOutputTokens", async () => {
|
|
const efforts = JSON.parse(readFileSync(new URL("./testdata/config-efforts.json", import.meta.url), "utf8"))
|
|
const said = { workbuddy: [configs.workbuddy], "workbuddy-ai": [configs["workbuddy-ai"], efforts] }
|
|
let checked = 0
|
|
for (const [site, cfgs] of Object.entries(said)) {
|
|
const declared = _internal.configModels(_internal.SITES[site])
|
|
for (const cfg of cfgs) {
|
|
for (const d of cfg.data.models) {
|
|
if (!declared[d.id]) continue
|
|
expect([site, d.id, declared[d.id].limit.output]).toEqual([site, d.id, d.maxOutputTokens])
|
|
checked++
|
|
}
|
|
}
|
|
}
|
|
expect(_internal.configModels(_internal.SITES.workbuddy)["deepseek-v4.1-flash"].limit.output).toBe(128000)
|
|
expect(checked).toBeGreaterThan(5)
|
|
})
|