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