Browse Source

fix: bad variants for grok models

Aiden Cline 1 month ago
parent
commit
d841e70d26
1 changed files with 16 additions and 1 deletions
  1. 16 1
      packages/opencode/src/provider/transform.ts

+ 16 - 1
packages/opencode/src/provider/transform.ts

@@ -325,9 +325,24 @@ export namespace ProviderTransform {
     const id = model.id.toLowerCase()
     const id = model.id.toLowerCase()
     if (id.includes("deepseek") || id.includes("minimax") || id.includes("glm") || id.includes("mistral")) return {}
     if (id.includes("deepseek") || id.includes("minimax") || id.includes("glm") || id.includes("mistral")) return {}
 
 
+    // see: https://docs.x.ai/docs/guides/reasoning#control-how-hard-the-model-thinks
+    if (id.includes("grok") && id.includes("grok-3-mini")) {
+      if (model.api.npm === "@openrouter/ai-sdk-provider") {
+        return {
+          low: { reasoning: { effort: "low" } },
+          high: { reasoning: { effort: "high" } },
+        }
+      }
+      return {
+        low: { reasoningEffort: "low" },
+        high: { reasoningEffort: "high" },
+      }
+    }
+    if (id.includes("grok")) return {}
+
     switch (model.api.npm) {
     switch (model.api.npm) {
       case "@openrouter/ai-sdk-provider":
       case "@openrouter/ai-sdk-provider":
-        if (!model.id.includes("gpt") && !model.id.includes("gemini-3") && !model.id.includes("grok-4")) return {}
+        if (!model.id.includes("gpt") && !model.id.includes("gemini-3")) return {}
         return Object.fromEntries(OPENAI_EFFORTS.map((effort) => [effort, { reasoning: { effort } }]))
         return Object.fromEntries(OPENAI_EFFORTS.map((effort) => [effort, { reasoning: { effort } }]))
 
 
       // TODO: YOU CANNOT SET max_tokens if this is set!!!
       // TODO: YOU CANNOT SET max_tokens if this is set!!!