fix: send max_tokens null to explicitly unset stale values on model switch (#1281)

Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
jnjpng
2026-03-05 17:28:25 -08:00
committed by GitHub
parent cdf7167b26
commit 4e0751f069
3 changed files with 58 additions and 30 deletions

View File

@@ -161,8 +161,11 @@ function buildModelSettings(
// 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).
if (
typeof updateArgs?.max_output_tokens === "number" &&
(typeof updateArgs?.max_output_tokens === "number" ||
updateArgs?.max_output_tokens === null) &&
"provider_type" in settings
) {
(settings as Record<string, unknown>).max_output_tokens =
@@ -207,7 +210,8 @@ export async function updateAgentLLMConfig(
...(isMinimax && { parallel_tool_calls: true }),
...(hasModelSettings && { model_settings: modelSettings }),
...(contextWindow && { context_window_limit: contextWindow }),
...(typeof updateArgs?.max_output_tokens === "number" && {
...((typeof updateArgs?.max_output_tokens === "number" ||
updateArgs?.max_output_tokens === null) && {
max_tokens: updateArgs.max_output_tokens,
}),
});