anomalyco / anomalyco/opencode

Reasoning variants ineffective for alibaba provider: catalog npm (@ai-sdk/openai-compatible) drops enableThinking/thinkingBudget

Open
#46,647 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Sep 1, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Summary

Reasoning variants (thinking control) do not work for models served by the built-in alibaba provider. Variant options declared in config (enableThinking / thinkingBudget) are silently dropped before reaching the wire, so users cannot disable or budget thinking on Qwen3 models via Alibaba/DashScope-compatible endpoints.

opencode version: 1.18.25 (desktop and CLI behave identically)

Root cause

The models.dev catalog entry for the alibaba provider uses npm: "@ai-sdk/openai-compatible". Meanwhile:

  1. opencode bundles @ai-sdk/alibaba (it is in BUNDLED_PROVIDERS) and that SDK supports enableThinking / thinkingBudget provider options, mapped to the wire fields enable_thinking / thinking_budget (verified in the bundled dist and in @ai-sdk/alibaba sources >= 1.0.17).
  2. ProviderTransform.reasoningToggle() even has alibaba-specific handling ({ none: { enableThinking: false }, high: { enableThinking: true } }), and reasoningEffort() deliberately returns nothing for @ai-sdk/alibaba — both only reachable when the model's npm actually is @ai-sdk/alibaba.
  3. With the catalog npm (@ai-sdk/openai-compatible), ProviderTransform.providerOptions() wraps variant options under the openaiCompatible key, and that SDK's provider-options schema strips everything except its own fields. Result: no enable_thinking, no thinking_budget on the wire. Only reasoningEffort survives, emitted as reasoning_effort, which DashScope-compatible endpoints ignore (and values like xhigh are not standard effort values anyway).

This overlaps with #42876 and #42793 (body-level variant fields being discarded), but the specific failure here is the catalog npm mismatch: the alibaba-specific variant machinery exists but is never engaged because the provider resolves to the generic openai-compatible SDK.

Reproduction

Config (no secrets needed; any DashScope-compatible endpoint with a thinking model works):

{
  "provider": {
    "alibaba": {
      "options": { "baseURL": "<dashscope-compatible endpoint>", "apiKey": "<key>" },
      "models": {
        "qwen3.8-max": {
          "reasoning": true,
          "variants": {
            "none": { "enableThinking": false },
            "xhigh": { "enableThinking": true, "thinkingBudget": 262144 }
          }
        }
      }
    }
  }
}

Log the outgoing HTTP bodies with a local proxy (opencode run -m alibaba/qwen3.8-max --variant none|xhigh "...").

Observed (1.18.25, catalog npm):

variant wire body response reasoning tokens
none no thinking fields at all ~13 (thinking still ON server-side)
xhigh reasoning_effort: "xhigh" (ignored) ~12

Expected / workaround: adding "npm": "@ai-sdk/alibaba" at the provider level engages the bundled SDK:

variant wire body response reasoning tokens
none enable_thinking: false 0 (no reasoning_content in stream)
xhigh enable_thinking: true, thinking_budget: 262144 58

Suggested fixes

  • Point the alibaba catalog models that support thinking controls at the bundled @ai-sdk/alibaba instead of @ai-sdk/openai-compatible (it is already bundled, so no runtime install is needed), or
  • Teach the openai-compatible path to pass enable_thinking / thinking_budget through for alibaba-hosted models.

Related: #42876, #42793

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.