fix: don't pass null max_output_tokens in model_settings (#1299)

This commit is contained in:
jnjpng
2026-03-06 14:58:25 -08:00
committed by GitHub
parent 82c4794616
commit 194edef4f3

View File

@@ -159,13 +159,12 @@ function buildModelSettings(
settings = {}; settings = {};
} }
// Apply max_output_tokens only when provider_type is present. // Apply max_output_tokens only when provider_type is present and the value
// Without provider_type the discriminated union rejects the payload (e.g. MiniMax). // is a concrete number. Null means "unset" and should only be forwarded via
// Pass null through so the server can explicitly unset max_output_tokens // the top-level max_tokens field — some providers (e.g. OpenAI) reject null
// (prevents stale values lingering from a previous model). // inside their typed model_settings.
if ( if (
(typeof updateArgs?.max_output_tokens === "number" || typeof updateArgs?.max_output_tokens === "number" &&
updateArgs?.max_output_tokens === null) &&
"provider_type" in settings "provider_type" in settings
) { ) {
(settings as Record<string, unknown>).max_output_tokens = (settings as Record<string, unknown>).max_output_tokens =