Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions js/plugins/anthropic/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we apply these anywhere... (we may not be calling .parse for this schema)

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',
});
}
});

Expand Down