commandcode 0.1.15: DeepSeek models that take reasoning_effort "off" offer an off level and are sent "off" for it (#334)
CHENJIAMIAN measured Command Code's Provider API on a GOAT key: "off"
gives 0 reasoning tokens on deepseek-v4-pro, v4-flash,
v4-flash-vision-exp, v4.1-flash and v4.1-flash-fast; "none" is refused
as no option, thinking {"type":"disabled"} is ignored, and
deepseek-v4-flash-fast and Kimi-K3 refuse "off". The plugin offered no
off level and passed magpie's none on unchanged, so every way of asking
for off still thought.
- THINK_OFF: those five models list none, low, high, max on the
Provider API's list and in the default list (low/high/max are the
levels magpie borrowed from DeepSeek for them before).
- The Provider API fetch sends reasoning_effort "off" for none or a
client's "off" on those models, and drops the field for any other
model, which refuses both spellings. Other levels go as they came.
- Go's /alpha/generate: not measured with "off", so its levels are
unchanged and off (none or "off") is sent as no level, as none was.
magpie needs no change: a plugin model's variants are its levels
(pluginCatalog), and magpie sends none to a plugin model that lists it
(TestPluginThinkingOff).
Run at base 421117e (origin/main, fetched just before the commit):
- packages/commandcode: TMPDIR=$H HOME=$H/home bun test, 62 pass 0 fail.
- repo root: HOME=<temp> bun test, 2317 pass 0 fail; bun
scripts/check.mjs ok.
- think-off.test.mjs against the old index.mjs: 5 of 6 red (none sent
as "none", no "none" level listed, Go sent "off"); the sixth, other
levels unchanged, passes on both, as it should.
Not tried: no real Command Code account was used. The "off" behaviour
rests on the reporter's measurements, and Go's /alpha/generate with
"off" is untested. The Responses API path (reasoning.effort) is not
rewritten: magpie and OpenCode ask these models on chat completions.
This commit is contained in:
@@ -112,6 +112,14 @@ that refusal reaches the agent.
|
|||||||
The Go models carry their reasoning levels, and a requested level is
|
The Go models carry their reasoning levels, and a requested level is
|
||||||
fitted to the nearest one the model has.
|
fitted to the nearest one the model has.
|
||||||
|
|
||||||
|
Thinking can be turned off on the Provider API for DeepSeek V4 Pro, V4
|
||||||
|
Flash, V4 Flash Vision (exp), V4.1 Flash and V4.1 Flash Fast. These models
|
||||||
|
offer an off level (`none`), and the plugin sends it as Command Code's
|
||||||
|
`reasoning_effort: "off"`. A client's own `"off"` is sent the same way. The
|
||||||
|
other models, DeepSeek V4 Flash Fast and Kimi K3 among them, refuse `"off"`,
|
||||||
|
so turning thinking off sends them no level. Go's `/alpha/generate` hasn't
|
||||||
|
been tried with `"off"`, so it is sent no level there either.
|
||||||
|
|
||||||
The `/models` list doesn't say which models take images. A model is marked
|
The `/models` list doesn't say which models take images. A model is marked
|
||||||
as taking them when it is a Claude model, or when the default list or the
|
as taking them when it is a Claude model, or when the default list or the
|
||||||
CLI's table says so. For any other model the plugin says nothing either
|
CLI's table says so. For any other model the plugin says nothing either
|
||||||
|
|||||||
@@ -45,6 +45,21 @@ const RESPONSES = "@ai-sdk/openai" // the Responses API, which magpie speaks to
|
|||||||
|
|
||||||
// ---- models -------------------------------------------------------------------
|
// ---- models -------------------------------------------------------------------
|
||||||
|
|
||||||
|
// THINK_OFF are the models the Provider API turns thinking off for at
|
||||||
|
// reasoning_effort "off" (CHENJIAMIAN, magpie-community/plugins#334, on a
|
||||||
|
// GOAT key: 0 reasoning tokens on each, where "none" is refused as no
|
||||||
|
// option and thinking {"type":"disabled"} is ignored). Others, DeepSeek V4
|
||||||
|
// Flash Fast and Kimi K3 among them, refuse "off" ("does not support
|
||||||
|
// reasoning_effort \"off\""). Each is offered magpie's off level, none,
|
||||||
|
// beside the levels magpie gave it before (DeepSeek's: low, high, max),
|
||||||
|
// and none or "off" asked of it is sent as "off" (providerBody). Go's
|
||||||
|
// /alpha/generate is not known to take "off": its levels stay the CLI's.
|
||||||
|
const THINK_OFF = new Set([
|
||||||
|
"deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash", "deepseek/deepseek-v4-flash-vision-exp",
|
||||||
|
"deepseek/deepseek-v4.1-flash", "deepseek/deepseek-v4.1-flash-fast",
|
||||||
|
])
|
||||||
|
const OFF_EFFORTS = ["none", "low", "high", "max"]
|
||||||
|
|
||||||
// The plan's models when its list can't be asked: Claude on Messages, the
|
// The plan's models when its list can't be asked: Claude on Messages, the
|
||||||
// rest on chat completions. Pictures as models.dev has them (DeepSeek V4
|
// rest on chat completions. Pictures as models.dev has them (DeepSeek V4
|
||||||
// and GLM-5.3 read text alone, so say nothing).
|
// and GLM-5.3 read text alone, so say nothing).
|
||||||
@@ -52,8 +67,8 @@ const MODELS = [
|
|||||||
{ id: "claude-sonnet-5", name: "Claude Sonnet 5", context: 1_000_000, images: true },
|
{ id: "claude-sonnet-5", name: "Claude Sonnet 5", context: 1_000_000, images: true },
|
||||||
{ id: "claude-opus-5-5", name: "Claude Opus 5.5", context: 1_000_000, images: true },
|
{ id: "claude-opus-5-5", name: "Claude Opus 5.5", context: 1_000_000, images: true },
|
||||||
{ id: "gpt-6-sol", name: "GPT-6 Sol", context: 1_050_000, images: true },
|
{ id: "gpt-6-sol", name: "GPT-6 Sol", context: 1_050_000, images: true },
|
||||||
{ id: "deepseek/deepseek-v4-pro", name: "DeepSeek V4 Pro", context: 1_000_000 },
|
{ id: "deepseek/deepseek-v4-pro", name: "DeepSeek V4 Pro", context: 1_000_000, efforts: OFF_EFFORTS },
|
||||||
{ id: "deepseek/deepseek-v4-flash", name: "DeepSeek V4 Flash", context: 1_000_000 },
|
{ id: "deepseek/deepseek-v4-flash", name: "DeepSeek V4 Flash", context: 1_000_000, efforts: OFF_EFFORTS },
|
||||||
{ id: "moonshotai/Kimi-K3", name: "Kimi K3", context: 1_000_000, images: true },
|
{ id: "moonshotai/Kimi-K3", name: "Kimi K3", context: 1_000_000, images: true },
|
||||||
{ id: "zai-org/GLM-5.3", name: "GLM-5.3", context: 1_000_000 },
|
{ id: "zai-org/GLM-5.3", name: "GLM-5.3", context: 1_000_000 },
|
||||||
{ id: "MiniMaxAI/MiniMax-M3", name: "MiniMax M3", context: 1_000_000, images: true },
|
{ id: "MiniMaxAI/MiniMax-M3", name: "MiniMax M3", context: 1_000_000, images: true },
|
||||||
@@ -253,8 +268,10 @@ function runtimeModel(m) {
|
|||||||
// liveModels is the Provider API's list, with the APIs each model is
|
// liveModels is the Provider API's list, with the APIs each model is
|
||||||
// served on (its Claude models on /messages alone, the open ones on
|
// served on (its Claude models on /messages alone, the open ones on
|
||||||
// /chat/completions and /responses, some on /responses alone); the default list's names and
|
// /chat/completions and /responses, some on /responses alone); the default list's names and
|
||||||
// windows fill in what it leaves out. The list says nothing of pictures:
|
// windows fill in what it leaves out. A model that turns thinking off
|
||||||
// a model takes them as the default list or the CLI's table (GO_MODELS)
|
// (THINK_OFF) has its levels, off among them; the list names no levels,
|
||||||
|
// and magpie gives every other model its maker's. The list says nothing
|
||||||
|
// of pictures: a model takes them as the default list or the CLI's table (GO_MODELS)
|
||||||
// says, and every Claude model does; of any other nothing is said, and
|
// says, and every Claude model does; of any other nothing is said, and
|
||||||
// magpie answers from models.dev.
|
// magpie answers from models.dev.
|
||||||
async function liveModels(key) {
|
async function liveModels(key) {
|
||||||
@@ -281,6 +298,7 @@ async function liveModels(key) {
|
|||||||
context: Number.isFinite(ctx) && ctx > 0 ? ctx : k?.context ?? 0,
|
context: Number.isFinite(ctx) && ctx > 0 ? ctx : k?.context ?? 0,
|
||||||
images,
|
images,
|
||||||
npm,
|
npm,
|
||||||
|
...(THINK_OFF.has(m.id) ? { efforts: OFF_EFFORTS } : {}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (!out.length) throw new Error("models: an empty list")
|
if (!out.length) throw new Error("models: an empty list")
|
||||||
@@ -918,8 +936,10 @@ function generateBody(chat, place = {}) {
|
|||||||
stream: true,
|
stream: true,
|
||||||
}
|
}
|
||||||
if (typeof chat.temperature === "number") params.temperature = chat.temperature
|
if (typeof chat.temperature === "number") params.temperature = chat.temperature
|
||||||
|
// off ("none", or a client's "off") is not known to be taken here: it
|
||||||
|
// is sent as nothing, the model's own default
|
||||||
const effort = chat.reasoning_effort
|
const effort = chat.reasoning_effort
|
||||||
if (effort && effort !== "none") params.reasoning_effort = fitEffort(effort, GO_EFFORTS[chat.model] ?? [])
|
if (effort && effort !== "none" && effort !== "off") params.reasoning_effort = fitEffort(effort, GO_EFFORTS[chat.model] ?? [])
|
||||||
const d = new Date()
|
const d = new Date()
|
||||||
const date = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`
|
const date = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`
|
||||||
return {
|
return {
|
||||||
@@ -1218,6 +1238,19 @@ async function generate(key, chat, signal, place, zdr = false) {
|
|||||||
return new Response(stream, { status: 200, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" } })
|
return new Response(stream, { status: 200, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// providerBody is the chat completion chat as the Provider API is sent it,
|
||||||
|
// or undefined when it goes as it came: off, magpie's none or a client's
|
||||||
|
// "off", is "off" for a model that turns thinking off (THINK_OFF), and
|
||||||
|
// left out for any other, which refuses both "none" and "off" (#334).
|
||||||
|
function providerBody(chat) {
|
||||||
|
const e = chat?.reasoning_effort
|
||||||
|
if (e !== "none" && e !== "off") return undefined
|
||||||
|
const out = { ...chat }
|
||||||
|
if (THINK_OFF.has(chat.model)) out.reasoning_effort = "off"
|
||||||
|
else delete out.reasoning_effort
|
||||||
|
return e === out.reasoning_effort ? undefined : JSON.stringify(out)
|
||||||
|
}
|
||||||
|
|
||||||
// ---- the plugin ---------------------------------------------------------------
|
// ---- the plugin ---------------------------------------------------------------
|
||||||
|
|
||||||
export const _internal = { subsSeen, extraSeen, waits, liveKey, failure, goModels, refuses, GO_MODELS, GO_REFUSED, zdrOn }
|
export const _internal = { subsSeen, extraSeen, waits, liveKey, failure, goModels, refuses, GO_MODELS, GO_REFUSED, zdrOn }
|
||||||
@@ -1273,7 +1306,10 @@ export async function CommandCodePlugin({ client, magpie } = {}) {
|
|||||||
}
|
}
|
||||||
// the Provider API's answer goes on as it came, the account
|
// the Provider API's answer goes on as it came, the account
|
||||||
// kept: the built-in neither marked one lapsed nor cleared it
|
// kept: the built-in neither marked one lapsed nor cleared it
|
||||||
const res = await fetch(input, { ...init, headers })
|
const body = chatting ? providerBody(chat) : undefined
|
||||||
|
const res = await (body === undefined
|
||||||
|
? fetch(input, { ...init, headers })
|
||||||
|
: fetch(url, { ...init, method: init.method ?? (input instanceof Request ? input.method : "POST"), headers, body }))
|
||||||
if (res.ok) return kept(res)
|
if (res.ok) return kept(res)
|
||||||
// a Go key the plan wasn't known for (billing/subscriptions slow
|
// a Go key the plan wasn't known for (billing/subscriptions slow
|
||||||
// or failing, nothing saved yet) is refused by the Provider API
|
// or failing, nothing saved yet) is refused by the Provider API
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/opencode-commandcode-auth",
|
"name": "@magpie-community/opencode-commandcode-auth",
|
||||||
"version": "0.1.14",
|
"version": "0.1.15",
|
||||||
"description": "Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams) in OpenCode and magpie",
|
"description": "Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams) in OpenCode and magpie",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./index.mjs",
|
"main": "./index.mjs",
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// CHENJIAMIAN (magpie-community/plugins#334): Command Code's Provider API
|
||||||
|
// turns a DeepSeek model's thinking off at reasoning_effort "off", its own
|
||||||
|
// word: "none" is refused ('Invalid option: expected one of
|
||||||
|
// "off"|"low"|"medium"|"high"|"xhigh"|"max"'), and so is "off" for a model
|
||||||
|
// that can't turn it off (deepseek/deepseek-v4-flash-fast, Kimi K3:
|
||||||
|
// 'does not support reasoning_effort "off"'), as measured on a GOAT key on
|
||||||
|
// 2026-10-23. So the five models that took it offer magpie's off level,
|
||||||
|
// none, and are sent "off" for it; any other is sent no level for it, and
|
||||||
|
// Go's /alpha/generate, not measured, is sent none either.
|
||||||
|
import { afterEach, expect, test } from "bun:test"
|
||||||
|
import { readFileSync } from "node:fs"
|
||||||
|
import { join } from "node:path"
|
||||||
|
import { CommandCodePlugin, _internal } from "./index.mjs"
|
||||||
|
|
||||||
|
const real = globalThis.fetch
|
||||||
|
afterEach(() => {
|
||||||
|
globalThis.fetch = real
|
||||||
|
_internal.subsSeen.clear()
|
||||||
|
_internal.extraSeen.clear()
|
||||||
|
})
|
||||||
|
|
||||||
|
const OFF = [
|
||||||
|
"deepseek/deepseek-v4-pro",
|
||||||
|
"deepseek/deepseek-v4-flash",
|
||||||
|
"deepseek/deepseek-v4-flash-vision-exp",
|
||||||
|
"deepseek/deepseek-v4.1-flash",
|
||||||
|
"deepseek/deepseek-v4.1-flash-fast",
|
||||||
|
]
|
||||||
|
const ON = ["deepseek/deepseek-v4-flash-fast", "moonshotai/Kimi-K3"]
|
||||||
|
|
||||||
|
const LIST = readFileSync(join(import.meta.dir, "testdata", "models-2026-10-13.json"), "utf8")
|
||||||
|
const GOAT_SUB = readFileSync(join(import.meta.dir, "testdata", "subscriptions-goat.json"), "utf8")
|
||||||
|
const CREDITS = readFileSync(join(import.meta.dir, "testdata", "credits-goat.json"), "utf8")
|
||||||
|
|
||||||
|
// chat sends a chat completion for model at effort through a GOAT
|
||||||
|
// account's fetch, as the AI SDK hands it, and gives the body the
|
||||||
|
// Provider API was sent
|
||||||
|
async function chat(model, effort) {
|
||||||
|
const sent = []
|
||||||
|
globalThis.fetch = async (input, init = {}) => {
|
||||||
|
const path = new URL(typeof input === "string" ? input : input.url ?? String(input)).pathname
|
||||||
|
if (path.endsWith("/chat/completions")) {
|
||||||
|
sent.push({ method: init.method, body: JSON.parse(init.body), auth: new Headers(init.headers).get("x-api-key") })
|
||||||
|
return Response.json({ choices: [] })
|
||||||
|
}
|
||||||
|
return new Response("", { status: 404 })
|
||||||
|
}
|
||||||
|
const hooks = await CommandCodePlugin()
|
||||||
|
const opts = await hooks.auth.loader(async () => ({ type: "api", key: "k", metadata: { plan: "GOAT" } }))
|
||||||
|
const body = { model, stream: false, messages: [{ role: "user", content: "1+1=?" }] }
|
||||||
|
if (effort !== undefined) body.reasoning_effort = effort
|
||||||
|
const res = await opts.fetch("https://api.commandcode.ai/provider/v1/chat/completions", { method: "POST", body: JSON.stringify(body) })
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
expect(sent.length).toBe(1)
|
||||||
|
expect(sent[0].method).toBe("POST")
|
||||||
|
expect(sent[0].auth).toBe("k")
|
||||||
|
expect(sent[0].body.messages).toEqual(body.messages)
|
||||||
|
return sent[0].body
|
||||||
|
}
|
||||||
|
|
||||||
|
test("off (magpie's none, or a client's \"off\") goes to the Provider API as \"off\" for each model that takes it", async () => {
|
||||||
|
for (const model of OFF) {
|
||||||
|
expect((await chat(model, "none")).reasoning_effort).toBe("off")
|
||||||
|
expect((await chat(model, "off")).reasoning_effort).toBe("off")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("off is sent as no level to a model that refuses \"off\"", async () => {
|
||||||
|
for (const model of ON) {
|
||||||
|
for (const e of ["none", "off"]) {
|
||||||
|
const b = await chat(model, e)
|
||||||
|
expect("reasoning_effort" in b).toBe(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("any other level, or none asked, goes as it came", async () => {
|
||||||
|
expect((await chat("deepseek/deepseek-v4.1-flash", "low")).reasoning_effort).toBe("low")
|
||||||
|
expect((await chat("deepseek/deepseek-v4-flash-fast", "max")).reasoning_effort).toBe("max")
|
||||||
|
expect("reasoning_effort" in (await chat("deepseek/deepseek-v4.1-flash"))).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("the Provider API's list offers the off level for those models alone", async () => {
|
||||||
|
globalThis.fetch = async (url) => {
|
||||||
|
const path = new URL(String(url)).pathname
|
||||||
|
if (path === "/alpha/billing/subscriptions") return new Response(GOAT_SUB)
|
||||||
|
if (path === "/alpha/billing/credits") return new Response(CREDITS)
|
||||||
|
if (path === "/provider/v1/models") return new Response(LIST)
|
||||||
|
return new Response("", { status: 404 })
|
||||||
|
}
|
||||||
|
const hooks = await CommandCodePlugin()
|
||||||
|
const ms = await hooks.provider.models({ models: {} }, { auth: { type: "api", key: "goat", metadata: { plan: "GOAT" } } })
|
||||||
|
for (const id of OFF) {
|
||||||
|
expect(ms[id]).toBeDefined()
|
||||||
|
expect(Object.keys(ms[id].variants)).toEqual(["none", "low", "high", "max"])
|
||||||
|
expect(ms[id].variants.none).toEqual({ reasoningEffort: "none" })
|
||||||
|
expect(ms[id].capabilities.reasoning).toBe(true)
|
||||||
|
}
|
||||||
|
for (const [id, m] of Object.entries(ms)) if (!OFF.includes(id)) expect(Object.keys(m.variants)).not.toContain("none")
|
||||||
|
for (const id of ON) expect(ms[id]).toBeDefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("the default list, standing in for the Provider API's, offers it too", async () => {
|
||||||
|
const cfg = {}
|
||||||
|
const hooks = await CommandCodePlugin()
|
||||||
|
await hooks.config(cfg)
|
||||||
|
const ms = cfg.provider["commandcode-plan"].models
|
||||||
|
expect(Object.keys(ms["deepseek/deepseek-v4-pro"].variants)).toEqual(["none", "low", "high", "max"])
|
||||||
|
expect(Object.keys(ms["deepseek/deepseek-v4-flash"].variants)).toEqual(["none", "low", "high", "max"])
|
||||||
|
expect(ms["moonshotai/Kimi-K3"].variants).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("Go's /alpha/generate, not known to take \"off\", is sent no level for off, and Go's levels have none", async () => {
|
||||||
|
const sent = []
|
||||||
|
globalThis.fetch = async (input, init = {}) => {
|
||||||
|
const path = new URL(typeof input === "string" ? input : input.url ?? String(input)).pathname
|
||||||
|
if (path === "/alpha/generate") {
|
||||||
|
sent.push(JSON.parse(init.body).params)
|
||||||
|
return new Response(JSON.stringify({ type: "finish", finishReason: "stop", totalUsage: { inputTokens: 1, outputTokens: 1 } }) + "\n")
|
||||||
|
}
|
||||||
|
return new Response("", { status: 404 })
|
||||||
|
}
|
||||||
|
const hooks = await CommandCodePlugin()
|
||||||
|
const opts = await hooks.auth.loader(async () => ({ type: "api", key: "go", metadata: { plan: "Go" } }))
|
||||||
|
for (const e of ["none", "off", "high"]) {
|
||||||
|
await opts.fetch("https://api.commandcode.ai/provider/v1/chat/completions", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ model: "deepseek/deepseek-v4.1-flash", stream: false, reasoning_effort: e, messages: [{ role: "user", content: "hi" }] }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
expect(sent.map((p) => p.reasoning_effort)).toEqual([undefined, undefined, "high"])
|
||||||
|
for (const m of _internal.GO_MODELS) expect(m.efforts ?? []).not.toContain("none")
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user