From 7bacfc4e3195eafaa39245e71f2a84729c0dc952 Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 30 Apr 2026 05:09:35 +0200 Subject: [PATCH] fix(ai/utils): isForcedToolChoice typing - Changed the parameter type from OpenAICompletionsToolChoice to unknown to accommodate widening type changes in the OpenAI SDK's ChatCompletionToolChoiceOption. - The function only checks for specific open/forced values, so it safely handles any input shape. --- packages/ai/src/utils/tool-choice.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/ai/src/utils/tool-choice.ts b/packages/ai/src/utils/tool-choice.ts index 5356e73d7..b45cc7ad4 100644 --- a/packages/ai/src/utils/tool-choice.ts +++ b/packages/ai/src/utils/tool-choice.ts @@ -57,9 +57,11 @@ export function mapToOpenAICompletionsToolChoice(choice?: ToolChoice): OpenAICom /** * Returns true when an OpenAI-completions `tool_choice` value forces a tool * call (`"required"` or a function-name pin), as opposed to leaving it open - * (`"auto"`, `"none"`, or unset). + * (`"auto"`, `"none"`, or unset). Accepts `unknown` because the param shape + * pulled from the OpenAI SDK (`ChatCompletionToolChoiceOption`) widens with + * each release; this check only needs the open/forced bit. */ -export function isForcedToolChoice(choice: OpenAICompletionsToolChoice): boolean { +export function isForcedToolChoice(choice: unknown): boolean { if (choice === undefined || choice === "auto" || choice === "none") return false; return true; }