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