Просмотр исходного кода

fix: enable thinking for all reasoning models on alibaba-cn (DashScope) (#12772)

Co-authored-by: lujia <[email protected]>
AdJIa 1 неделя назад
Родитель
Сommit
0cd52f830c
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      packages/opencode/src/provider/transform.ts

+ 14 - 0
packages/opencode/src/provider/transform.ts

@@ -643,6 +643,20 @@ export namespace ProviderTransform {
       }
       }
     }
     }
 
 
+    // Enable thinking for reasoning models on alibaba-cn (DashScope).
+    // DashScope's OpenAI-compatible API requires `enable_thinking: true` in the request body
+    // to return reasoning_content. Without it, models like kimi-k2.5, qwen-plus, qwen3, qwq,
+    // deepseek-r1, etc. never output thinking/reasoning tokens.
+    // Note: kimi-k2-thinking is excluded as it returns reasoning_content by default.
+    if (
+      input.model.providerID === "alibaba-cn" &&
+      input.model.capabilities.reasoning &&
+      input.model.api.npm === "@ai-sdk/openai-compatible" &&
+      !modelId.includes("kimi-k2-thinking")
+    ) {
+      result["enable_thinking"] = true
+    }
+
     if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) {
     if (input.model.api.id.includes("gpt-5") && !input.model.api.id.includes("gpt-5-chat")) {
       if (!input.model.api.id.includes("gpt-5-pro")) {
       if (!input.model.api.id.includes("gpt-5-pro")) {
         result["reasoningEffort"] = "medium"
         result["reasoningEffort"] = "medium"