feat: raise max output tokens to 128K (documented upstream ceiling)

Aliyun Model Studio (the upstream behind Qoder's CN catalog) documents
Max Output Length = 131072 for every model we expose, in both normal and
thinking modes (thinking chain alone goes to 262144):
  qwen3.8-max/flash, qwen3.7-max/plus/flash — all 131072.

The previous 32768 default (copied from qodercli's conservative 32e3) used
only 1/4 of the supported output budget. That truncates reasoning chains in
thinking mode (where the chain counts against output) and risks cutting long
generations / compaction summaries. qodercli caps its own UI at 65536, still
below the documented ceiling.

- models.ts: introduce MAX_OUTPUT_TOKENS = 131072 as the single source of
  truth; all 24 staticModels entries + the lazy-loaded CN entry now reference
  it. Remove the dead max_output_tokens field from the CN placeholder entry.
- stream.ts: maxTokens defaults to MAX_OUTPUT_TOKENS; still capped lower by
  options.maxTokens (e.g. pi compaction passes 40000).

Verified against the real CN endpoint: max_tokens=131072 returns 200 / stop
(accepted, not rejected); an xhigh reasoning run completes with
finish_reason=stop (not truncated). Field placement + reasoning_effort send
also confirmed working in the same request.
This commit is contained in:
Loongphy
2026-08-28 19:36:59 +08:00
parent 112da4deaf
commit 76c3b7201b
2 changed files with 45 additions and 31 deletions
+38 -26
View File
@@ -13,6 +13,19 @@ import {
export const ZERO_COST = Object.freeze({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
/**
* Maximum output tokens sent per request. Aliyun Model Studio (the upstream
* behind Qoder's CN catalog) documents Max Output Length = 131072 for every
* model we expose (qwen3.8-max/flash, qwen3.7-max/plus/flash), in both normal
* and thinking modes (thinking chain alone goes up to 262144). The Qoder
* /model/list catalog does not return a per-model output cap, so this single
* constant is the source of truth for both static models and request sending.
* qodercli ships a conservative 32e3 default and caps its UI at 65536; we use
* the documented upstream ceiling so reasoning chains and long generations
* are not truncated.
*/
export const MAX_OUTPUT_TOKENS = 131072;
/** Shape of a single entry returned by the Qoder /model/list endpoint. */
export interface QoderModelEntry {
key?: string;
@@ -67,7 +80,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 180000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "ultimate",
@@ -80,7 +93,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "performance",
@@ -93,7 +106,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "efficient",
@@ -106,7 +119,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 180000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "lite",
@@ -119,7 +132,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 180000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "qmodel",
@@ -132,7 +145,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "cmodel",
@@ -145,7 +158,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "qmodel_preview",
@@ -158,7 +171,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "qmodel_latest",
@@ -171,7 +184,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "dmodel",
@@ -184,7 +197,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "dfmodel",
@@ -197,7 +210,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "gm51model",
@@ -210,7 +223,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "kmodel",
@@ -223,7 +236,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 256000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "kmodel_latest",
@@ -236,7 +249,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
{
id: "mmodel",
@@ -249,7 +262,7 @@ export const staticModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
},
];
@@ -265,7 +278,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 200000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN smart routing; fallback context window of 200K.",
},
{
@@ -279,7 +292,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN qmodel_latest; context options 200K/400K/1M.",
},
{
@@ -293,7 +306,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN qmodel; context options 200K/400K/1M.",
},
{
@@ -307,7 +320,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN q36fmodel; context options 200K/400K/1M.",
},
{
@@ -321,7 +334,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN dmodel; context options 200K/400K/1M.",
},
{
@@ -335,7 +348,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 1000000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN dfmodel; context options 200K/400K/1M.",
},
{
@@ -349,7 +362,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 200000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN gm51model; live catalog currently displays GLM-5.2 with 200K context.",
},
{
@@ -363,7 +376,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text", "image"],
cost: ZERO_COST,
contextWindow: 256000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN kmodel; context option 256K.",
},
{
@@ -377,7 +390,7 @@ export const staticCnModels: QoderModelDef[] = [
input: ["text"],
cost: ZERO_COST,
contextWindow: 200000,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
description: "Qoder CN mmodel; live catalog reports 200K context.",
},
];
@@ -465,7 +478,6 @@ export function getCachedModelConfig(modelKey: string, mode?: string): QoderMode
return {
key: modelKey,
is_reasoning: false,
max_output_tokens: 32768,
source: "system",
};
}
@@ -588,7 +600,7 @@ export async function updateQoderModelsCache(
input: isVL ? ["text", "image"] : ["text"],
cost: ZERO_COST,
contextWindow: ctxLen,
maxTokens: 32768,
maxTokens: MAX_OUTPUT_TOKENS,
});
}