From 22b3be834ea58dba4ef31e21eaa054d51f2583a5 Mon Sep 17 00:00:00 2001 From: Yoshiaki Okuyama Date: Sat, 28 Feb 2026 05:33:14 +0900 Subject: [PATCH] fix(ai): use enable_thinking for Z.ai instead of thinking param (#1674) Z.ai uses the same enable_thinking: boolean parameter as Qwen to control reasoning, not thinking: { type: "enabled" | "disabled" }. The wrong parameter name means Z.ai ignores the disable request and always runs with thinking enabled, wasting tokens and adding latency. Merge the Z.ai and Qwen branches since they use the same format. PR by @okuyam2y --- packages/ai/src/providers/openai-completions.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index f724401b..019f1726 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -423,12 +423,8 @@ function buildParams(model: Model<"openai-completions">, context: Context, optio params.tool_choice = options.toolChoice; } - if (compat.thinkingFormat === "zai" && model.reasoning) { - // Z.ai uses binary thinking: { type: "enabled" | "disabled" } - // Must explicitly disable since z.ai defaults to thinking enabled - (params as any).thinking = { type: options?.reasoningEffort ? "enabled" : "disabled" }; - } else if (compat.thinkingFormat === "qwen" && model.reasoning) { - // Qwen uses enable_thinking: boolean + if ((compat.thinkingFormat === "zai" || compat.thinkingFormat === "qwen") && model.reasoning) { + // Both Z.ai and Qwen use enable_thinking: boolean (params as any).enable_thinking = !!options?.reasoningEffort; } else if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) { // OpenAI-style reasoning_effort