refactor: drop dead max_output_tokens, simplify maxTokens to 32K + pi cap
Qoder's /model/list catalog never returns max_output_tokens (the field does not exist on any entry — only max_input_tokens is present), so the per-model lookup `entry.max_output_tokens || 32768` was dead code that always fell back to the 32768 literal. - models.ts: remove max_output_tokens from QoderModelEntry; maxTokens is now a flat 32768 (matches qodercli's 32e3 fallback). - stream.ts: remove the now-unused maxOutputTokens variable and its always-true branch; maxTokens = 32768, capped lower only by options.maxTokens (e.g. pi compaction passes 40000). pi-ai's maxTokens setting still has an outlet. - stream.ts fallback modelConfig: drop the dead max_output_tokens: 32768 field. qodercli does conditionally send max_tokens (user setting → generation config → 32K fallback), but the field is not required by the upstream API. Keeping it gives pi-ai's options.maxTokens a place to flow through.
This commit is contained in:
+1
-2
@@ -19,7 +19,6 @@ export interface QoderModelEntry {
|
|||||||
enable?: boolean;
|
enable?: boolean;
|
||||||
display_name?: string;
|
display_name?: string;
|
||||||
max_input_tokens?: number;
|
max_input_tokens?: number;
|
||||||
max_output_tokens?: number;
|
|
||||||
context_config?: Record<string, { token_count?: number; is_default?: boolean }>;
|
context_config?: Record<string, { token_count?: number; is_default?: boolean }>;
|
||||||
is_vl?: boolean;
|
is_vl?: boolean;
|
||||||
is_reasoning?: boolean;
|
is_reasoning?: boolean;
|
||||||
@@ -589,7 +588,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: entry.max_output_tokens || 32768,
|
maxTokens: 32768,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -128,7 +128,6 @@ export function streamQoder(
|
|||||||
const modelConfig = getCachedModelConfig(model.id, providerMode) || {
|
const modelConfig = getCachedModelConfig(model.id, providerMode) || {
|
||||||
key: model.id,
|
key: model.id,
|
||||||
is_reasoning: false,
|
is_reasoning: false,
|
||||||
max_output_tokens: 32768,
|
|
||||||
source: "system",
|
source: "system",
|
||||||
};
|
};
|
||||||
// Use the cached entry's original upstream key when available; fall back to
|
// Use the cached entry's original upstream key when available; fall back to
|
||||||
@@ -136,7 +135,6 @@ export function streamQoder(
|
|||||||
const qoderModel = modelConfig.key || model.id;
|
const qoderModel = modelConfig.key || model.id;
|
||||||
|
|
||||||
const isReasoning = !!modelConfig.is_reasoning;
|
const isReasoning = !!modelConfig.is_reasoning;
|
||||||
const maxOutputTokens = modelConfig.max_output_tokens || 32768;
|
|
||||||
|
|
||||||
const normalizedMessages = transformMessagesForQoder(context.messages);
|
const normalizedMessages = transformMessagesForQoder(context.messages);
|
||||||
const systemText = context.systemPrompt || "";
|
const systemText = context.systemPrompt || "";
|
||||||
@@ -163,10 +161,10 @@ 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),
|
||||||
|
// so we default to 32K (matches qodercli's 32e3 fallback) and let pi cap it
|
||||||
|
// lower when the caller sets options.maxTokens (e.g. compaction at 40K).
|
||||||
let maxTokens = 32768;
|
let maxTokens = 32768;
|
||||||
if (maxOutputTokens > 0) {
|
|
||||||
maxTokens = maxOutputTokens;
|
|
||||||
}
|
|
||||||
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