Files
plugins/packages/qoder/context.test.mjs
T
yetone a5f3321af3 qoder 0.2.5: a model's context is the largest window Qoder offers it, not max_input_tokens (yetone/magpie#722, Moody-Sin: qoder 的 qwen 3.8 flash 只有180K上下文) — modelInfo took the context from max_input_tokens, 180000 on Qwen3.8-Flash (and Qwen3.8-Max, Kimi-K3, GLM-5.3, MiniMax-M3, Sonus, Cantus), so magpie and every agent behind it were told 180K, and each request was sent context_length 180000. Qoder's client reads the windows a model offers from the listing's context_config ({name: {token_count, is_default}}; else available_context_windows / default_context_window), as qodercli's catalog does (YT/Yai in the Qoder.app 0.4.3 worker), and its Context setting offers 200K, 400K and 1M on Qwen3.8-Flash and twelve others (docs.qoder.com, model tier selector); max_input_tokens is only what a request naming no window gets. windowsOf reads them the same way; a model's context is now its largest window (max_input_tokens when it lists none), and windowFor sends the default window while the request fits it, else the smallest that holds it, else the largest — a larger window may change the rate, Qoder's docs say, so it is asked for only when the conversation needs it; the request is counted generously, a token per 3 bytes of its JSON. context.test.mjs (windows read from context_config and available_context_windows, a model without them keeping 180000, the default window sent for a short request and 400K/1M for longer ones) fails on the old code and passes; bun test (48 pass) and scripts/check.mjs qoder under a temp HOME pass. Not tried with a real Qoder account: the listing's context_config for qfmodel is read from Qoder's client code and docs, not from a live listing.
2026-10-04 06:50:17 +08:00

52 lines
2.0 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)
})