qoder 0.2.6: the window a request is sent holds the reply's max_tokens too (yetone/magpie#700 follow-up, kyzhouxu: a group's DeepSeek V4.1 Flash refused near 207K until Qoder's DeepSeek-Flash was taken out of it) — since 0.2.5 windowFor sends the model's default window (200K on the models context_config lists 200K/400K/1M for) while the request's estimate, a token per 3 bytes of its messages and tools, fits it, and asked for nothing of the reply: a 180K conversation with the 32000 max_tokens Qoder is sent went out with context_length 200000, which a prompt plus reply past 200K overflows, while magpie and the agents behind it are told the model takes 1M. The estimate now adds the reply's max_tokens (what qoderBody sends), so that request is sent 400K; a short one still gets the default window. Qoder's own metadata does say 1M for dfmodel: its live listing's max_input_tokens was 1000000 (the context 0.2.4 cached for it in a sandbox magpie on 2026-10-03, where MiniMax-M3 read 180000) and 0.2.5 reads 1M as its largest window, and docs.qoder.com/cli/model lists DeepSeek-V4-Flash with 200K / 400K / 1M, so the reported context stays 1M. When kyzhouxu's refusal happened isn't known: #700 itself (ynky007) was opened before 0.2.5, when every request was sent context_length 1000000, and their comment came after it (2026-10-04 03:34 UTC), so this is the way 0.2.5 can refuse a request under the window magpie reports, not shown to be what they hit. context.test.mjs gains the case (180K prompt: 200K with max_tokens 1000, 400K with 32000 and with none asked); it fails on 0.2.5 (200000) and passes; bun test (49 pass) and bun scripts/check.mjs qoder under a temp HOME pass. Not tried with a real Qoder account.
This commit is contained in:
@@ -49,3 +49,15 @@ test("a request is sent the default window while it fits, a larger one when it d
|
||||
expect(sent(700000 * 3)).toBe(1000000)
|
||||
expect(sent(1200000 * 3)).toBe(1000000)
|
||||
})
|
||||
|
||||
// a window holds the reply too: a prompt that fits 200K alone but not with
|
||||
// the max_tokens asked for the reply is sent the next window (yetone/magpie#700)
|
||||
test("the reply's max_tokens is counted in the window a request needs", () => {
|
||||
const m = { ..._internal.modelInfo(flash), config: flash }
|
||||
const ctx = (max_tokens) =>
|
||||
_internal.qoderBody({ max_tokens, messages: [{ role: "user", content: "a".repeat(180000 * 3) }] }, m).parameters.context_length
|
||||
expect(ctx(1000)).toBe(200000)
|
||||
expect(ctx(32000)).toBe(400000)
|
||||
// none asked: the 32000 Qoder is sent counts
|
||||
expect(_internal.qoderBody({ messages: [{ role: "user", content: "a".repeat(180000 * 3) }] }, m).parameters.context_length).toBe(400000)
|
||||
})
|
||||
|
||||
@@ -576,11 +576,14 @@ function qoderMessages(msgs) {
|
||||
// (Qoder: changing the Context "may change the rate"), so it is asked for
|
||||
// only when the conversation needs it. The request's size is counted
|
||||
// generously, a token for every 3 bytes of its UTF-8 JSON, so a window is
|
||||
// raised a little early rather than late.
|
||||
function windowFor(chat, m) {
|
||||
// raised a little early rather than late, and the reply's max_tokens is
|
||||
// counted in it: a window holds the prompt and the reply, so a
|
||||
// conversation of 180K asking 32K for the reply is sent 400K, not the 200K
|
||||
// it would overflow while magpie says the model takes 1M (yetone/magpie#700).
|
||||
function windowFor(chat, m, reply = 0) {
|
||||
const base = m.defaultWindow || (m.config?.max_input_tokens > 0 ? m.config.max_input_tokens : 0) || m.context
|
||||
if (!m.windows?.length) return m.context
|
||||
const need = Math.ceil(Buffer.byteLength(JSON.stringify({ m: chat.messages ?? [], t: chat.tools ?? [] })) / 3)
|
||||
const need = Math.ceil(Buffer.byteLength(JSON.stringify({ m: chat.messages ?? [], t: chat.tools ?? [] })) / 3) + Math.max(0, reply)
|
||||
if (base > 0 && need <= base) return base
|
||||
return m.windows.find((w) => w >= need) ?? m.windows[m.windows.length - 1]
|
||||
}
|
||||
@@ -596,7 +599,7 @@ function qoderBody(chat, m) {
|
||||
const [thinking, effort] = effortFor(chat.reasoning_effort, m)
|
||||
const params = { enable_thinking: thinking, max_tokens: chat.max_completion_tokens || chat.max_tokens || 32000 }
|
||||
if (effort) params.reasoning_effort = effort
|
||||
const window = windowFor(chat, m)
|
||||
const window = windowFor(chat, m, params.max_tokens)
|
||||
if (window > 0) params.context_length = window
|
||||
const body = {
|
||||
parameters: params,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-qoder-auth",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"description": "Qoder subscriptions in OpenCode and magpie: Qoder (qoder.com) and Qoder CN (qoder.cn)",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user