From 79159190d36935c692872817adfc0013fbdf472b Mon Sep 17 00:00:00 2001 From: Corie Watson Date: Fri, 12 Dec 2025 14:04:39 +0000 Subject: [PATCH] fix(anthropic): budgetTokens not working in UI --- js/plugins/anthropic/src/types.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/plugins/anthropic/src/types.ts b/js/plugins/anthropic/src/types.ts index 9796d71c36..7b37867301 100644 --- a/js/plugins/anthropic/src/types.ts +++ b/js/plugins/anthropic/src/types.ts @@ -93,15 +93,26 @@ export type AnthropicBaseConfigSchemaType = typeof AnthropicBaseConfigSchema; export const ThinkingConfigSchema = z .object({ enabled: z.boolean().optional(), - budgetTokens: z.number().int().min(1_024).optional(), + budgetTokens: z.number().min(1_024).optional(), }) .superRefine((value, ctx) => { - if (value.enabled && value.budgetTokens === undefined) { + if (!value.enabled) return; + + if (value.budgetTokens === undefined) { ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['budgetTokens'], message: 'budgetTokens is required when thinking is enabled', }); + } else if ( + value.budgetTokens !== undefined && + !Number.isInteger(value.budgetTokens) + ) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + path: ['budgetTokens'], + message: 'budgetTokens must be an integer', + }); } });