diff --git a/src/cliproxy/thinking-validator.ts b/src/cliproxy/thinking-validator.ts index 747cd497..9414eae5 100644 --- a/src/cliproxy/thinking-validator.ts +++ b/src/cliproxy/thinking-validator.ts @@ -105,6 +105,15 @@ export function validateThinking( ): ThinkingValidationResult { const thinking = getModelThinkingSupport(provider, modelId); + // Handle empty string explicitly + if (typeof value === 'string' && value.trim() === '') { + return { + valid: false, + value: 'off', + warning: 'Empty thinking value not allowed. Using "off".', + }; + } + // Handle off/none/disabled values if (typeof value === 'string') { const normalizedValue = value.toLowerCase().trim(); @@ -198,6 +207,15 @@ function validateBudgetThinking( budget = value; } + // Reject NaN/Infinity budgets + if (!Number.isFinite(budget)) { + return { + valid: false, + value: min || THINKING_BUDGET_DEFAULT_MIN, + warning: `Budget must be a finite number. Using minimum ${min || THINKING_BUDGET_DEFAULT_MIN}.`, + }; + } + // Reject negative budgets if (budget < THINKING_BUDGET_MIN) { return {