Files
plugins/packages/qoder/small-budget.test.mjs
T
yetone 58adeadfac qoder 0.2.55: a request whose max_tokens is 1024 or less does not think at the default (#643)
The same default as WorkBuddy's #643 (itspig): qoderBody's effortFor
thought at the model's default effort when no effort was asked, so a
title asked at a small max_tokens could spend it on reasoning. A request
that names no effort and a max_tokens (or max_completion_tokens) of 1024
or less is now asked as "none": thinking off, or the lowest level for a
model that always thinks. An asked effort, and a larger or unnamed budget,
are unchanged.

Run, at this head, on mote:
- packages/qoder: bun test, 365 pass, 0 fail; small-budget.test.mjs new.
- bun scripts/check.mjs qoder: ok.
- Broken by hand (the SMALL_BUDGET line in effortFor removed):
  small-budget.test.mjs is red, 1 pass, 1 fail.

Not tried: a real Qoder account. Qoder answers 401 to the owner's account
(plugins#181), and no Qoder report showed a small budget spent on
thinking; the change follows WorkBuddy's measured case.
Other siblings checked: trae, devin, commandcode, loomy and kiro send only
an effort the client asked or leave the server's default; none add one.
2026-11-03 02:25:46 +08:00

31 lines
1.8 KiB
JavaScript

// A request whose own max_tokens is small asks for no thinking: the default
// effort would spend its whole output budget on reasoning, as WorkBuddy's
// did on a 64-token title (plugins#643, itspig). Qoder's qoderBody had the
// same default, so it gets the same rule.
import { expect, test } from "bun:test"
import { _internal } from "./index.mjs"
const { qoderBody, modelInfo } = _internal
const tc = (disabled) => ({ enabled: { efforts: { low: {}, medium: {}, high: { is_default: true } } }, ...(disabled ? { disabled: {} } : {}) })
const optional = modelInfo({ key: "think-opt", is_reasoning: true, thinking_config: tc(true) })
const always = modelInfo({ key: "think-always", is_reasoning: true, thinking_config: tc(false) })
const chat = (extra) => ({ messages: [{ role: "user", content: "Title this chat." }], ...extra })
const params = (m, extra) => qoderBody(chat(extra), m).parameters
test("a small max_tokens with no effort asked does not think at the default", () => {
for (const extra of [{ max_tokens: 64 }, { max_tokens: 1024 }, { max_completion_tokens: 64 }]) {
expect(params(optional, extra).enable_thinking).toBe(false)
expect(params(optional, extra).reasoning_effort).toBeUndefined()
// A model that always thinks thinks at its lowest, as a request for none does.
expect(params(always, extra)).toMatchObject({ enable_thinking: true, reasoning_effort: "low" })
}
expect(params(optional, { max_tokens: 64 }).max_tokens).toBe(64)
})
test("an asked effort, a larger budget or none named keeps what it had", () => {
expect(params(optional, { max_tokens: 64, reasoning_effort: "high" })).toMatchObject({ enable_thinking: true, reasoning_effort: "high" })
for (const extra of [{ max_tokens: 1025 }, { max_completion_tokens: 32000 }, {}]) {
expect(params(optional, extra)).toMatchObject({ enable_thinking: true, reasoning_effort: "high" })
}
})