Files
yetone a839119751 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.
2026-10-04 12:00:17 +08:00

64 lines
2.7 KiB
JavaScript

// A model's context is the largest window Qoder offers it (context_config,
// Qoder's Context setting: 200K / 400K / 1M), not max_input_tokens, which
// is 180K on Qwen3.8-Flash (yetone/magpie#722); a request is sent the
// default window while it fits, a larger one only when it needs it.
import { expect, test } from "bun:test"
import { _internal } from "./index.mjs"
const flash = {
key: "qfmodel",
enable: true,
display_name: "Qwen3.8-Flash",
max_input_tokens: 180000,
is_reasoning: true,
context_config: {
"1m": { token_count: 1000000 },
"200k": { token_count: 200000, is_default: true },
"400k": { token_count: 400000 },
},
}
test("the context is the largest window context_config offers", () => {
const m = _internal.modelInfo(flash)
expect(m.context).toBe(1000000)
expect(m.windows).toEqual([200000, 400000, 1000000])
expect(m.defaultWindow).toBe(200000)
})
test("available_context_windows is read without context_config", () => {
const m = _internal.modelInfo({ key: "x", max_input_tokens: 180000, available_context_windows: [400000, 200000], default_context_window: 200000 })
expect(m.context).toBe(400000)
expect(m.defaultWindow).toBe(200000)
})
test("a model with no windows keeps max_input_tokens", () => {
const m = _internal.modelInfo({ key: "y", max_input_tokens: 180000 })
expect(m.context).toBe(180000)
const body = _internal.qoderBody({ messages: [{ role: "user", content: "hi" }] }, { ...m, config: { key: "y" } })
expect(body.parameters.context_length).toBe(180000)
})
const sent = (chars) => {
const m = { ..._internal.modelInfo(flash), config: flash }
return _internal.qoderBody({ messages: [{ role: "user", content: "a".repeat(chars) }] }, m).parameters.context_length
}
test("a request is sent the default window while it fits, a larger one when it doesn't", () => {
expect(sent(10)).toBe(200000)
expect(sent(300000 * 3)).toBe(400000)
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)
})