From 518c558d56375d91a3a14fedf0bf30ab32dd3972 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 7 Aug 2025 10:11:01 -0400 Subject: [PATCH] Fix rounding of max tokens (#6808) --- src/shared/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/api.ts b/src/shared/api.ts index 4cd2459f70..014b903453 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -92,7 +92,7 @@ export const getModelMaxOutputTokens = ({ // If model has explicit maxTokens, clamp it to 20% of the context window if (model.maxTokens) { - return Math.min(model.maxTokens, model.contextWindow * 0.2) + return Math.min(model.maxTokens, Math.ceil(model.contextWindow * 0.2)) } // For non-Anthropic formats without explicit maxTokens, return undefined