From 34bb95e04e7781f77f1f87a2e09caa95cbdf543a Mon Sep 17 00:00:00 2001 From: Bee <68532117+abeatrix@users.noreply.github.com> Date: Sat, 6 Dec 2025 05:03:29 -0800 Subject: [PATCH] refactor: require native tool call for Responses API (#7953) Add validation to ensure native tool calling is enabled when using OpenAI Responses API format. Previously, the code would silently fall back to completion stream when tools were not provided, which could lead to unexpected behavior. - Add explicit error when tools are missing for Responses API format - Update tools parameter type to non-optional in createResponseStream --- src/core/api/providers/openai-native.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/api/providers/openai-native.ts b/src/core/api/providers/openai-native.ts index c72cc27e..e9c34482 100644 --- a/src/core/api/providers/openai-native.ts +++ b/src/core/api/providers/openai-native.ts @@ -64,7 +64,10 @@ export class OpenAiNativeHandler implements ApiHandler { @withRetry() async *createMessage(systemPrompt: string, messages: ClineStorageMessage[], tools?: ChatCompletionTool[]): ApiStream { // Responses API requires tool format to be set to OPENAI_RESPONSES with native tools calling enabled - if (tools?.length && this.getModel()?.info?.apiFormat === ApiFormat.OPENAI_RESPONSES) { + if (this.getModel()?.info?.apiFormat === ApiFormat.OPENAI_RESPONSES) { + if (!tools?.length) { + throw new Error("Native Tool Call must be enabled in your setting for OpenAI Responses API") + } yield* this.createResponseStream(systemPrompt, messages, tools) } else { yield* this.createCompletionStream(systemPrompt, messages, tools) @@ -156,7 +159,7 @@ export class OpenAiNativeHandler implements ApiHandler { private async *createResponseStream( systemPrompt: string, messages: ClineStorageMessage[], - tools?: ChatCompletionTool[], + tools: ChatCompletionTool[], ): ApiStream { const client = this.ensureClient() const model = this.getModel()