From 194edef4f39fa4f201c9a19ade8f59d8adf0bd73 Mon Sep 17 00:00:00 2001 From: jnjpng Date: Fri, 6 Mar 2026 14:58:25 -0800 Subject: [PATCH] fix: don't pass null max_output_tokens in model_settings (#1299) --- src/agent/modify.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/agent/modify.ts b/src/agent/modify.ts index bae743d..98794cc 100644 --- a/src/agent/modify.ts +++ b/src/agent/modify.ts @@ -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).max_output_tokens =