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:
+38
-26
@@ -13,6 +13,19 @@ import {
|
|||||||
|
|
||||||
export const ZERO_COST = Object.freeze({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
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. */
|
/** Shape of a single entry returned by the Qoder /model/list endpoint. */
|
||||||
export interface QoderModelEntry {
|
export interface QoderModelEntry {
|
||||||
key?: string;
|
key?: string;
|
||||||
@@ -67,7 +80,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 180000,
|
contextWindow: 180000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "ultimate",
|
id: "ultimate",
|
||||||
@@ -80,7 +93,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "performance",
|
id: "performance",
|
||||||
@@ -93,7 +106,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "efficient",
|
id: "efficient",
|
||||||
@@ -106,7 +119,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 180000,
|
contextWindow: 180000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "lite",
|
id: "lite",
|
||||||
@@ -119,7 +132,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 180000,
|
contextWindow: 180000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "qmodel",
|
id: "qmodel",
|
||||||
@@ -132,7 +145,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "cmodel",
|
id: "cmodel",
|
||||||
@@ -145,7 +158,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "qmodel_preview",
|
id: "qmodel_preview",
|
||||||
@@ -158,7 +171,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "qmodel_latest",
|
id: "qmodel_latest",
|
||||||
@@ -171,7 +184,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "dmodel",
|
id: "dmodel",
|
||||||
@@ -184,7 +197,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "dfmodel",
|
id: "dfmodel",
|
||||||
@@ -197,7 +210,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "gm51model",
|
id: "gm51model",
|
||||||
@@ -210,7 +223,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "kmodel",
|
id: "kmodel",
|
||||||
@@ -223,7 +236,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 256000,
|
contextWindow: 256000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "kmodel_latest",
|
id: "kmodel_latest",
|
||||||
@@ -236,7 +249,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "mmodel",
|
id: "mmodel",
|
||||||
@@ -249,7 +262,7 @@ export const staticModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -265,7 +278,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 200000,
|
contextWindow: 200000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN smart routing; fallback context window of 200K.",
|
description: "Qoder CN smart routing; fallback context window of 200K.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -279,7 +292,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN qmodel_latest; context options 200K/400K/1M.",
|
description: "Qoder CN qmodel_latest; context options 200K/400K/1M.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -293,7 +306,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN qmodel; context options 200K/400K/1M.",
|
description: "Qoder CN qmodel; context options 200K/400K/1M.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -307,7 +320,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN q36fmodel; context options 200K/400K/1M.",
|
description: "Qoder CN q36fmodel; context options 200K/400K/1M.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -321,7 +334,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN dmodel; context options 200K/400K/1M.",
|
description: "Qoder CN dmodel; context options 200K/400K/1M.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -335,7 +348,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 1000000,
|
contextWindow: 1000000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN dfmodel; context options 200K/400K/1M.",
|
description: "Qoder CN dfmodel; context options 200K/400K/1M.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -349,7 +362,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text", "image"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 200000,
|
contextWindow: 200000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN gm51model; live catalog currently displays GLM-5.2 with 200K context.",
|
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"],
|
input: ["text", "image"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 256000,
|
contextWindow: 256000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN kmodel; context option 256K.",
|
description: "Qoder CN kmodel; context option 256K.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -377,7 +390,7 @@ export const staticCnModels: QoderModelDef[] = [
|
|||||||
input: ["text"],
|
input: ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: 200000,
|
contextWindow: 200000,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
description: "Qoder CN mmodel; live catalog reports 200K context.",
|
description: "Qoder CN mmodel; live catalog reports 200K context.",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -465,7 +478,6 @@ export function getCachedModelConfig(modelKey: string, mode?: string): QoderMode
|
|||||||
return {
|
return {
|
||||||
key: modelKey,
|
key: modelKey,
|
||||||
is_reasoning: false,
|
is_reasoning: false,
|
||||||
max_output_tokens: 32768,
|
|
||||||
source: "system",
|
source: "system",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -588,7 +600,7 @@ export async function updateQoderModelsCache(
|
|||||||
input: isVL ? ["text", "image"] : ["text"],
|
input: isVL ? ["text", "image"] : ["text"],
|
||||||
cost: ZERO_COST,
|
cost: ZERO_COST,
|
||||||
contextWindow: ctxLen,
|
contextWindow: ctxLen,
|
||||||
maxTokens: 32768,
|
maxTokens: MAX_OUTPUT_TOKENS,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -20,7 +20,7 @@ import {
|
|||||||
getQoderUserEmailFallback,
|
getQoderUserEmailFallback,
|
||||||
isQoderCNMode,
|
isQoderCNMode,
|
||||||
} from "./cosy.js";
|
} from "./cosy.js";
|
||||||
import { getCachedModelConfig } from "./models.js";
|
import { getCachedModelConfig, MAX_OUTPUT_TOKENS } from "./models.js";
|
||||||
import { getCachedCredentials } from "./oauth.js";
|
import { getCachedCredentials } from "./oauth.js";
|
||||||
import { qoderEncodeBody } from "./qoder-encoding.js";
|
import { qoderEncodeBody } from "./qoder-encoding.js";
|
||||||
import { stripThinkingTags, ThinkingTagParser } from "./thinking-parser.js";
|
import { stripThinkingTags, ThinkingTagParser } from "./thinking-parser.js";
|
||||||
@@ -161,10 +161,12 @@ export function streamQoder(
|
|||||||
? `${stablePart}-${options.sessionId}`
|
? `${stablePart}-${options.sessionId}`
|
||||||
: `${stablePart}-${crypto.randomUUID()}`;
|
: `${stablePart}-${crypto.randomUUID()}`;
|
||||||
|
|
||||||
// Qoder's catalog exposes no per-model output cap (no max_output_tokens),
|
// Qoder's catalog exposes no per-model output cap, so we use the
|
||||||
// so we default to 32K (matches qodercli's 32e3 fallback) and let pi cap it
|
// documented upstream ceiling (MAX_OUTPUT_TOKENS = 131072, see models.ts)
|
||||||
// lower when the caller sets options.maxTokens (e.g. compaction at 40K).
|
// and let pi cap it lower when the caller sets options.maxTokens (e.g.
|
||||||
let maxTokens = 32768;
|
// compaction at 40K). This avoids truncating reasoning chains / long
|
||||||
|
// generations that the 32K default would cut off.
|
||||||
|
let maxTokens = MAX_OUTPUT_TOKENS;
|
||||||
if (options?.maxTokens && options.maxTokens < maxTokens) {
|
if (options?.maxTokens && options.maxTokens < maxTokens) {
|
||||||
maxTokens = options.maxTokens;
|
maxTokens = options.maxTokens;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user