From 394aaf677793b71582579c2d6b232ff210c2e972 Mon Sep 17 00:00:00 2001 From: Ari Webb Date: Tue, 10 Feb 2026 15:23:41 -0800 Subject: [PATCH] fix: send max tokens to cloud on model update (#901) --- src/agent/modify.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/agent/modify.ts b/src/agent/modify.ts index 7eb3b97..f3fde33 100644 --- a/src/agent/modify.ts +++ b/src/agent/modify.ts @@ -137,8 +137,12 @@ function buildModelSettings( settings = {}; } - // Apply max_output_tokens for all providers if specified - if (typeof updateArgs?.max_output_tokens === "number") { + // Apply max_output_tokens only when provider_type is present. + // Without provider_type the discriminated union rejects the payload (e.g. MiniMax). + if ( + typeof updateArgs?.max_output_tokens === "number" && + "provider_type" in settings + ) { (settings as Record).max_output_tokens = updateArgs.max_output_tokens; } @@ -175,6 +179,9 @@ export async function updateAgentLLMConfig( model: modelHandle, ...(hasModelSettings && { model_settings: modelSettings }), ...(contextWindow && { context_window_limit: contextWindow }), + ...(typeof updateArgs?.max_output_tokens === "number" && { + max_tokens: updateArgs.max_output_tokens, + }), }); const finalAgent = await client.agents.retrieve(agentId);