workbuddy 0.2.37: a kimi-k3.1-pro call-only turn carries a space
Gloria335056 on X: from dsh through magpie, WorkBuddy's kimi-k3.1-pro fails with 400 "Invalid request parameters" while every other model works. dsh (pi-ai openai-completions) records a call-only assistant turn as "content": null, captured at magpie's gateway, so every request after the model's first tool call carries one. The same model on QwenWork refused null and "" and served one space (nanfei892, #1213, measured), and kimi-k3 on www.workbuddy.ai took the null turn (measured today). systemOn now runs callText: for kimi-k3.1-pro and kimi-k3.1-pro-highspeed on both sites, an assistant turn with tool_calls and an empty content (null, "", or only empty text parts) goes with content " ". A turn with text, and every other model (kimi-k3, kimi-k3-1, kimi-k2.6, DeepSeek, GLM), go as they came. Test: kimi-call-text.test.mjs uses dsh 0.2.1's literal second request through the loader on both sites. Run (temp HOME, mica): bun test in packages/workbuddy 390 pass, 0 fail; bun scripts/check.mjs workbuddy ok. Broken by hand: with the callText call taken out of systemOn, the four null-turn cases fail (mica). Not tried: a real kimi-k3.1-pro request. Both owner accounts are free (WorkBuddy AI refuses the model for personal_free_user before reading the body), and the China account's refresh token is refused (12153).
This commit is contained in:
@@ -262,6 +262,14 @@ client sends. WorkBuddy drops `reasoning_content`, so a client such as Grok
|
||||
Build that sends it lost its earlier thinking; nothing is folded into the
|
||||
message's content.
|
||||
|
||||
`kimi-k3.1-pro` (and `-highspeed`) answers 400 "Invalid request parameters"
|
||||
to an assistant turn with `tool_calls` and no text, which is how OpenAI
|
||||
clients such as dsh record a call-only turn (`"content": null`), so an
|
||||
agent failed from its first tool call on. Since 0.2.37 such a turn goes to
|
||||
that model with one space as its content, as the same model on QwenWork
|
||||
serves it (#1213). A turn with text, and every other model, go as they
|
||||
came; `kimi-k3` takes the empty turn.
|
||||
|
||||
A chat's tools are given shapes WorkBuddy's models take. Without them
|
||||
WorkBuddy AI answers 400 "Invalid request parameters" (11133), DeepSeek's
|
||||
models to each shape below and Kimi's, GPT's, Gemini's and GLM's to some:
|
||||
|
||||
@@ -1005,6 +1005,7 @@ function systemOn(b) {
|
||||
changed = true
|
||||
}
|
||||
if (asReasoning(b.messages)) changed = true
|
||||
if (callText(b)) changed = true
|
||||
if (b.messages[0]?.role !== "system") {
|
||||
b.messages.unshift({ role: "system", content: "You are a helpful assistant." })
|
||||
changed = true
|
||||
@@ -1012,6 +1013,40 @@ function systemOn(b) {
|
||||
return changed
|
||||
}
|
||||
|
||||
// Kimi K3.1 Pro refuses an assistant turn with tool_calls and no text,
|
||||
// which is how every OpenAI client records a call-only turn (dsh sends
|
||||
// "content": null), so an agent fails from its second request on, once the
|
||||
// model has called a tool. WorkBuddy answers it 400 "Invalid request
|
||||
// parameters" (Gloria335056 on X: only kimi-k3.1-pro, every other model
|
||||
// fine, from dsh). The same model on QwenWork refused null and "" and took
|
||||
// one space, with DeepSeek, GLM and Qwen on the same account taking the
|
||||
// empty turn (nanfei892, plugins #1213, measured). Measured 2026-11-19 on
|
||||
// www.workbuddy.ai, kimi-k3 took the null turn. So a kimi-k3.1-pro (and
|
||||
// -highspeed) call-only turn goes with one space; a turn with text, and
|
||||
// every other model, go as they came.
|
||||
const CALL_TEXT = " "
|
||||
function callTextModel(id) {
|
||||
return /^kimi-k3\.1-pro(?:-|$)/i.test(String(id ?? ""))
|
||||
}
|
||||
|
||||
function emptyContent(c) {
|
||||
if (c === null || c === undefined || c === "") return true
|
||||
return Array.isArray(c) && c.every((p) => p?.type === "text" && !p.text)
|
||||
}
|
||||
|
||||
// callText gives b's call-only assistant turns CALL_TEXT for a model that
|
||||
// needs it; true when it changed any
|
||||
function callText(b) {
|
||||
if (!callTextModel(b?.model)) return false
|
||||
let changed = false
|
||||
for (const m of b.messages) {
|
||||
if (m?.role !== "assistant" || !Array.isArray(m.tool_calls) || !m.tool_calls.length || !emptyContent(m.content)) continue
|
||||
m.content = CALL_TEXT
|
||||
changed = true
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
// WorkBuddy's channel check reads the system and assistant messages only:
|
||||
// tried on 2026-10-21 with real accounts on both builds (glm-5.3,
|
||||
// deepseek-v4.1-flash, gpt-5.5), each refused line was served in the user's
|
||||
@@ -5000,4 +5035,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
||||
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
||||
|
||||
// for tests
|
||||
export const _internal = { replyFacts, reportEvents, stepOf, reporting, machineOf, endpointOf, moved, at, signInsIn, importSignIns, importFrom, otherSite, withGrowth, inputLengthOf, HIDE_DSH, hideDsh, dshHidden, planCodes, listedExtra, idFor, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, SMALL_BUDGET, 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, freeWindowRouting, routingRefusalRows, readRoutingRefusals, readLedgerTail, pinned, pinning, rowTime, rowAccount, ofAccount, windowOffset, windowReset, CN_ESTIMATED_WINDOWS, FREE_WINDOW_AI, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM, routingReads, routingParsed, restIdentity, routingLines, ROUTING_LINE_MAX }
|
||||
export const _internal = { callText, replyFacts, reportEvents, stepOf, reporting, machineOf, endpointOf, moved, at, signInsIn, importSignIns, importFrom, otherSite, withGrowth, inputLengthOf, HIDE_DSH, hideDsh, dshHidden, planCodes, listedExtra, idFor, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, SMALL_BUDGET, 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, freeWindowRouting, routingRefusalRows, readRoutingRefusals, readLedgerTail, pinned, pinning, rowTime, rowAccount, ofAccount, windowOffset, windowReset, CN_ESTIMATED_WINDOWS, FREE_WINDOW_AI, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM, routingReads, routingParsed, restIdentity, routingLines, ROUTING_LINE_MAX }
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// Kimi K3.1 Pro refuses an assistant turn with tool_calls and no text
|
||||
// (Gloria335056 on X: 400 "Invalid request parameters" from dsh on
|
||||
// kimi-k3.1-pro alone; plugins #1213 measured the same model on QwenWork,
|
||||
// where one space is served). The history is dsh 0.2.1's second request,
|
||||
// after its read call, as it reached magpie's gateway.
|
||||
import { expect, test } from "bun:test"
|
||||
import { WorkBuddyAIAuthPlugin, WorkBuddyAuthPlugin, _internal } from "./index.mjs"
|
||||
import { unz } from "./testdata/unz.mjs"
|
||||
|
||||
const { callText } = _internal
|
||||
|
||||
const call = { id: "read_0_a4137ac1", type: "function", function: { name: "read", arguments: '{"file_path":"a.txt"}' } }
|
||||
const history = (content) => [
|
||||
{ role: "system", content: "You are DeepSeek Harness." },
|
||||
{ role: "user", content: "Read the file a.txt with your file tool and tell me its content." },
|
||||
{ role: "assistant", content, reasoning_content: "Simple task: read a.txt.", tool_calls: [call] },
|
||||
{ role: "tool", content: "<path>a.txt</path>\n<content>\n1: hello\n</content>", tool_call_id: "read_0_a4137ac1" },
|
||||
]
|
||||
|
||||
async function upstream(plugin, url, model, messages) {
|
||||
const realFetch = globalThis.fetch
|
||||
const sent = []
|
||||
globalThis.fetch = async (u, init) => {
|
||||
if (String(u).includes("/chat/completions")) sent.push(JSON.parse(unz(init.body)))
|
||||
return new Response("data: [DONE]\n\n", { headers: { "content-type": "text/event-stream" } })
|
||||
}
|
||||
try {
|
||||
const hooks = await plugin({ client: {} })
|
||||
const loader = await hooks.auth.loader(async () => ({ type: "oauth", access: "access", uid: "uid", expires: Date.now() + 3600_000 }))
|
||||
const res = await loader.fetch(url, { method: "POST", body: JSON.stringify({ model, stream: true, max_completion_tokens: 32000, messages }) })
|
||||
expect(res.status).toBe(200)
|
||||
} finally {
|
||||
globalThis.fetch = realFetch
|
||||
}
|
||||
expect(sent.length).toBe(1)
|
||||
return sent[0].messages
|
||||
}
|
||||
|
||||
const AI = [WorkBuddyAIAuthPlugin, "https://www.workbuddy.ai/v2/chat/completions"]
|
||||
const CN = [WorkBuddyAuthPlugin, "https://copilot.tencent.com/v2/chat/completions"]
|
||||
|
||||
for (const [name, [plugin, url]] of Object.entries({ "workbuddy-ai": AI, workbuddy: CN })) {
|
||||
for (const model of ["kimi-k3.1-pro", "kimi-k3.1-pro-highspeed"]) {
|
||||
test(`${name} ${model}: dsh's call-only turn (content null) goes with one space`, async () => {
|
||||
const m = await upstream(plugin, url, model, history(null))
|
||||
const a = m.find((x) => x.role === "assistant")
|
||||
expect(a.content).toBe(" ")
|
||||
expect(a.tool_calls).toEqual([call])
|
||||
expect(a.reasoning).toBe("Simple task: read a.txt.")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
test("an empty string or empty text parts get the space too", () => {
|
||||
for (const content of ["", [], [{ type: "text", text: "" }]]) {
|
||||
const b = { model: "kimi-k3.1-pro", messages: history(content) }
|
||||
expect(callText(b)).toBe(true)
|
||||
expect(b.messages[2].content).toBe(" ")
|
||||
}
|
||||
})
|
||||
|
||||
test("a call-only turn with text, and a turn with no call, go as they came", () => {
|
||||
const b = { model: "kimi-k3.1-pro", messages: [...history("Reading it."), { role: "assistant", content: "" }] }
|
||||
expect(callText(b)).toBe(false)
|
||||
expect(b.messages[2].content).toBe("Reading it.")
|
||||
expect(b.messages[4].content).toBe("")
|
||||
})
|
||||
|
||||
test("other models keep the empty turn: kimi-k3 took it on www.workbuddy.ai", async () => {
|
||||
for (const model of ["kimi-k3", "kimi-k3-1", "kimi-k2.6", "deepseek-v4.1-flash", "glm-5.3"]) {
|
||||
const m = await upstream(...AI, model, history(null))
|
||||
expect(m.find((x) => x.role === "assistant").content).toBeNull()
|
||||
}
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-workbuddy-auth",
|
||||
"version": "0.2.36",
|
||||
"version": "0.2.37",
|
||||
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
||||
"type": "module",
|
||||
"main": "./opencode.mjs",
|
||||
|
||||
Reference in New Issue
Block a user