The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
[BOT-2148] Keep Qwen3.8 Max's OpenRouter handling under its dated id (#83522)
Voytek Pituład443b6bd42cf
diff --git a/docs/ai/providers.md b/docs/ai/providers.mdindex 479b2dd3742..5e68d3deda0 100644--- a/docs/ai/providers.md+++ b/docs/ai/providers.md@@ -103,7 +103,7 @@ Supported models:| GPT-5.6 Luna | `openai/gpt-5.6-luna` | 922,000 || GPT-5.6 Sol | `openai/gpt-5.6-sol` | 922,000 || GPT-5.6 Terra | `openai/gpt-5.6-terra` | 922,000 |-| Qwen3.8 Max | `qwen/qwen3.8-max` | 1,000,000 |+| Qwen3.8 Max 0902 | `qwen/qwen3.8-max-0902` | 1,000,000 || GLM-5.2 | `z-ai/glm-5.2` | 1,048,576 || GLM-5.3 | `z-ai/glm-5.3` | 1,048,576 |diff --git a/src/metabase/llm/provider.clj b/src/metabase/llm/provider.cljindex 88575a36805..98049b4e972 100644--- a/src/metabase/llm/provider.clj+++ b/src/metabase/llm/provider.clj@@ -85,6 +85,11 @@:label (deferred-tru "OpenRouter"):default-model "anthropic/claude-sonnet-4.6":mini-model "anthropic/claude-haiku-4.5"+ ;; Ids of retired models, each mapped to the model that now serves it. OpenRouter lists only the dated+ ;; `qwen/qwen3.8-max-0902` (https://openrouter.ai/api/v1/models). Saved selections may still name a retired id,+ ;; and they read as the successor. Treat an entry as permanent: nothing rewrites a value pinned by an environment+ ;; variable, and a stored value converges only when the setting is next written.+ :retired-models {"qwen/qwen3.8-max" "qwen/qwen3.8-max-0902"}:fields [{:key :api-key:label (deferred-tru "API key"):type :password@@ -874,6 +879,33 @@(when model-ref(second (str/split model-ref #"/" 2))))+(def ^:private retired-model-ids+ "Every model id some provider type has retired, so a reference naming none of them needs no connection lookup."+ (into #{} (mapcat (comp keys :retired-models)) provider-type-registry))++(defn- current-model+ "The model now serving `model` on provider type `type-name`.++ Its successor when the type retired it, otherwise `model` itself. Read from the raw registry, like+ [[retired-model-ids]]: retirement is not hosted policy, so it needs no [[provider-type]] lookup.++ \"openrouter\" \"qwen/qwen3.8-max\" => \"qwen/qwen3.8-max-0902\""+ [type-name model]+ (get-in provider-type-by-name [type-name :retired-models model] model))++(defn canonical-model-ref+ "`model-ref` with any retired model id replaced by its successor.++ A selection saved before a rename reads as the current model. Returns any other `model-ref` unchanged.++ \"openrouter/qwen/qwen3.8-max\" => \"openrouter/qwen/qwen3.8-max-0902\""+ [model-ref]+ (let [model (model-ref->model model-ref)]+ (if-let [{:keys [key type]} (when (contains? retired-model-ids model)+ (connection (model-ref->connection-key model-ref)))]+ (str key "/" (current-model type model))+ model-ref)))+(defn strip-managed-prefix"Drop the `metabase/` routing prefix from a model reference, leaving the `provider/model` pair the proxy forwards.Returns `model-ref` unchanged when it has no such prefix."@@ -905,7 +937,8 @@Returns `{:connection-key :type :model :credentials :ai-proxy?}`, or nil when no such connection exists. `:type`is the provider type whose adapter should serve the request: for the managed connection that is the wire familynamed by the model's own first segment (`metabase/anthropic/claude-...` is served by the Anthropic adapter over- the proxy), and `:model` is what remains."+ the proxy), and `:model` is what remains. A retired model id resolves to the model that now serves it, as+ in [[canonical-model-ref]]."[model-ref](let [conn-key (model-ref->connection-key model-ref)model (model-ref->model model-ref)]@@ -918,7 +951,7 @@:ai-proxy? true}{:connection-key conn-key:type type- :model model+ :model (current-model type model):credentials (with-field-defaults type config):ai-proxy? false}))))diff --git a/src/metabase/metabot/self/openrouter.clj b/src/metabase/metabot/self/openrouter.cljindex f8a143c6662..fe51712aef5 100644--- a/src/metabase/metabot/self/openrouter.clj+++ b/src/metabase/metabot/self/openrouter.clj@@ -50,14 +50,16 @@the direct openai adapter.`:reasoning` classifies what each model streams back, probed live against OpenRouter on- 2026-08-31 (all 26 models) and cross-checked with the `reasoning` metadata in+ 2026-08-31 (all 26 models then in the catalog; rows added or renamed since carry their own+ probe notes) and cross-checked with the `reasoning` metadata in`GET /v1/models` (https://openrouter.ai/docs/use-cases/reasoning-tokens):`:renderable` streams reasoning text under an explicit `reasoning {:enabled true}`;`:renderable-default` streams reasoning summaries under the server default but must receiveNO directive — an explicit enable verifiably suppresses gpt-5.6's reasoning entirely;`:budget-only` (`supported_efforts` nil in the catalog) silently ignores the unified enableand would need an explicit token budget.- `:reasoning-mandatory?` marks models where `reasoning {:enabled false}` is rejected with a 400."+ `:reasoning-mandatory?` marks models where `reasoning {:enabled false}` is rejected with a 400.+ `:required-tool-choice? false` marks models that don't support `:tool_choice \"required\"`; absent means they do."{"anthropic/claude-fable-5" {:display-name "Claude Fable 5" :context-window 1000000 :reasoning :renderable :reasoning-mandatory? true}"anthropic/claude-opus-5" {:display-name "Claude Opus 5" :context-window 1000000 :reasoning :renderable}"anthropic/claude-opus-4.8" {:display-name "Claude Opus 4.8" :context-window 1000000 :reasoning :renderable}@@ -90,7 +92,9 @@"openai/gpt-5.4" {:display-name "GPT-5.4" :context-window 922000 :reasoning :renderable}"openai/gpt-5.4-mini" {:display-name "GPT-5.4 Mini" :context-window 272000 :reasoning :renderable}"openai/gpt-5.4-pro" {:display-name "GPT-5.4 Pro" :context-window 922000 :reasoning :renderable-default :reasoning-mandatory? true}- "qwen/qwen3.8-max" {:display-name "Qwen3.8 Max" :context-window 1000000 :reasoning :renderable :reasoning-mandatory? true}+ ;; classified from the 2026-08-31 and 2026-09-03 probes of the undated `qwen/qwen3.8-max`, which OpenRouter+ ;; has retired in favor of this dated id (see `:retired-models` in `metabase.llm.provider`)+ "qwen/qwen3.8-max-0902" {:display-name "Qwen3.8 Max 0902" :context-window 1000000 :reasoning :renderable :reasoning-mandatory? true :required-tool-choice? false};; probed 2026-09-04 (post-dating the 2026-08-31 run): the enable streams reasoning, the;; disable is rejected with a 400 (thinking-only upstream, as on native z.ai), and a forced;; tool call at the floored budget completes@@ -192,14 +196,10 @@(re-find #"^openai/o\d" model)(anthropic-current-gen? model)))))-(def ^:private required-tool-choice-unsupported-models- "Models that don't support `:tool_choice \"required\"`"- #{"qwen/qwen3.8-max"})-(defn- supports-required-tool-choice?- "Whether `model` accepts `:tool_choice \"required\"`."+ "Whether `model` accepts `:tool_choice \"required\"`: true unless its [[supported-models]] row says otherwise."[model]- (not (contains? required-tool-choice-unsupported-models model)))+ (get-in supported-models [(str model) :required-tool-choice?] true))(defn- required-tool-choice->auto"Downgrade `:tool_choice \"required\"` to `\"auto\"`."diff --git a/src/metabase/metabot/settings.clj b/src/metabase/metabot/settings.cljindex e10cceab98c..ac52e119f44 100644--- a/src/metabase/metabot/settings.clj+++ b/src/metabase/metabot/settings.clj@@ -186,10 +186,12 @@:visibility :settings-manager:export? false:deprecated-name :ee-ai-metabot-provider+ :getter #(llm.provider/canonical-model-ref (setting/get-value-of-type :string :llm-metabot-provider)):setter (fn [new-value](when new-value(validate-model-ref! new-value))- (setting/set-value-of-type! :string :llm-metabot-provider new-value)))+ (setting/set-value-of-type! :string :llm-metabot-provider+ (llm.provider/canonical-model-ref new-value))))(defn- mini-model-ref"The model reference for the fastest model of the connection `model-ref` names, or nil when that connection's@@ -200,11 +202,13 @@(str conn-key "/" model))))(defn explicit-mini-model- "The model reference [[llm-mini-model]] was explicitly set to, or nil while it is being derived- from [[llm-metabot-provider]]. Callers that act on the admin's choice rather than on the model quick tasks happen- to run on want this: [[llm-mini-model]] itself resolves, so it names a connection even when none was ever picked."+ "The model reference [[llm-mini-model]] was explicitly set to, or nil when derived from [[llm-metabot-provider]].++ Callers that act on the admin's choice rather than on the model quick tasks happen to run on want this:+ [[llm-mini-model]] itself resolves, so it names a connection even when none was ever picked.+ A retired model id reads as the model that now serves it (see [[llm.provider/canonical-model-ref]])."[]- (setting/get-value-of-type :string :llm-mini-model))+ (llm.provider/canonical-model-ref (setting/get-value-of-type :string :llm-mini-model)))(defn- -llm-mini-model"Quick background tasks — naming a conversation, and whatever short, high-volume calls come next — do not need the@@ -227,7 +231,7 @@:setter (fn [new-value](when new-value(validate-model-ref! new-value))- (setting/set-value-of-type! :string :llm-mini-model new-value)))+ (setting/set-value-of-type! :string :llm-mini-model (llm.provider/canonical-model-ref new-value))))(defsetting llm-metabot-configured?"Whether the connection selected for Metabot has the credentials it needs."diff --git a/test/metabase/llm/provider_test.clj b/test/metabase/llm/provider_test.cljindex 9c129085eea..59992df61de 100644--- a/test/metabase/llm/provider_test.clj+++ b/test/metabase/llm/provider_test.clj@@ -618,6 +618,33 @@(is (nil? (llm.provider/resolve-model-ref "openai/gpt-5.4")))(is (nil? (llm.provider/resolve-model-ref nil))))))+(deftest resolve-model-ref-reads-a-retired-model-as-its-successor-test+ (mt/with-temporary-setting-values [llm-providers [(connection "openrouter" "openrouter" {:api-key "sk-or-v1-db"})+ (connection "anthropic" "anthropic" {:api-key "sk-ant-db"})]]+ (testing "a retired model id resolves to the model that now serves it"+ (is (= "qwen/qwen3.8-max-0902" (:model (llm.provider/resolve-model-ref "openrouter/qwen/qwen3.8-max")))))+ (testing "the same id under another provider type is not retired there"+ (is (= "qwen/qwen3.8-max" (:model (llm.provider/resolve-model-ref "anthropic/qwen/qwen3.8-max")))))))++(deftest canonical-model-ref-test+ (mt/with-temporary-setting-values [llm-providers [(connection "openrouter" "openrouter" {:api-key "sk-or-v1-db"})+ (connection "anthropic" "anthropic" {:api-key "sk-ant-db"})]]+ (testing "a retired model id reads as the model that now serves it"+ (is (= "openrouter/qwen/qwen3.8-max-0902" (llm.provider/canonical-model-ref "openrouter/qwen/qwen3.8-max"))))+ (testing "any other reference is returned unchanged"+ (is (= "openrouter/qwen/qwen3.8-max-0902" (llm.provider/canonical-model-ref "openrouter/qwen/qwen3.8-max-0902")))+ (is (= "anthropic/qwen/qwen3.8-max" (llm.provider/canonical-model-ref "anthropic/qwen/qwen3.8-max")))+ (is (= "nope/qwen/qwen3.8-max" (llm.provider/canonical-model-ref "nope/qwen/qwen3.8-max")))+ (is (nil? (llm.provider/canonical-model-ref nil))))))++(deftest ^:parallel retired-models-map-straight-to-a-current-model-test+ (testing (str "a retired model's successor is never itself retired: a model ref resolves through a single "+ "lookup, so a chain would leave a saved selection naming a retired id")+ (doseq [{:keys [type retired-models]} (llm.provider/provider-types)+ successor (vals retired-models)]+ (testing type+ (is (not (contains? retired-models successor)))))))+(deftest with-field-defaults-normalizes-base-urls-test(testing "a base URL keeps no trailing slash, whichever source it comes from, so joining a path cannot double the /"(is (= "https://api.mistral.ai/v1"diff --git a/test/metabase/metabot/self/openrouter_test.clj b/test/metabase/metabot/self/openrouter_test.cljindex d429aa081ae..be6f10cac41 100644--- a/test/metabase/metabot/self/openrouter_test.clj+++ b/test/metabase/metabot/self/openrouter_test.clj@@ -126,7 +126,7 @@(deftest ^:parallel request-body-no-required-tool-choice-model-downgrades-schema-tool-choice-test(testing "the structured-output forced tool call is downgraded to auto for qwen3.8-max"(let [body (openrouter/openrouter-request-body- {:model "qwen/qwen3.8-max"+ {:model "qwen/qwen3.8-max-0902":input [{:role :user :content "hi"}]:schema {:type "object" :properties {:answer {:type "string"}}}})](is (=? {:tool_choice "auto"@@ -136,7 +136,7 @@(deftest ^:parallel request-body-no-required-tool-choice-model-downgrades-explicit-tool-choice-test(testing "an explicit tool_choice required is downgraded too"(let [body (openrouter/openrouter-request-body- {:model "qwen/qwen3.8-max"+ {:model "qwen/qwen3.8-max-0902":input [{:role :user :content "hi"}]:tools [{:tool-name "get_thing":doc "Get a thing."@@ -148,7 +148,7 @@(deftest ^:parallel request-body-no-required-tool-choice-model-leaves-auto-tool-choice-test(testing "a tool_choice that is already auto is left alone for qwen3.8-max"(let [body (openrouter/openrouter-request-body- {:model "qwen/qwen3.8-max"+ {:model "qwen/qwen3.8-max-0902":input [{:role :user :content "hi"}]:tools [{:tool-name "get_thing":doc "Get a thing."@@ -208,7 +208,7 @@:tool_choice "required"})))))(testing "qwen's required->auto downgrade lands first, so its directive stays enabled"(is (= {:enabled true}- (:reasoning (body-for {:model "qwen/qwen3.8-max"+ (:reasoning (body-for {:model "qwen/qwen3.8-max-0902":tools [{:tool-name "get_thing":doc "Get a thing.":schema [:=> [:cat [:map [:id :int]]] :any]@@ -216,7 +216,7 @@:tool_choice "required"})))))(testing "mandatory-reasoning models get no directive instead of a rejected disable"(is (not (contains? (body-for {:model "anthropic/claude-fable-5" :reasoning? false}) :reasoning)))- (is (not (contains? (body-for {:model "qwen/qwen3.8-max" :schema {:type "object"}}) :reasoning))))+ (is (not (contains? (body-for {:model "qwen/qwen3.8-max-0902" :schema {:type "object"}}) :reasoning))))(testing "renderable-default models never get a directive, even under structured output:they stream summaries server-side by default and an explicit enable suppressesgpt-5.6's reasoning entirely"@@ -239,7 +239,7 @@(testing "a forced tool call on a mandatory-reasoning model gets its max_tokens cap floored";; safety net — its reasoning cannot be disabled and bills against the same budget as the;; tool call; theory vs practice in openrouter/forced-tool-call-token-floor- (are [expected opts] (= expected (:max_tokens (body-for (assoc opts :model "qwen/qwen3.8-max"))))+ (are [expected opts] (= expected (:max_tokens (body-for (assoc opts :model "qwen/qwen3.8-max-0902"))))2048 {:schema {:type "object"} :max-tokens 512}4096 {:schema {:type "object"} :max-tokens 4096}nil {:schema {:type "object"}}@@ -266,7 +266,7 @@"anthropic/claude-opus-4.7" "anthropic/claude-opus-4.6" "anthropic/claude-sonnet-5""anthropic/claude-sonnet-4.6" "deepseek/deepseek-v4-pro" "deepseek/deepseek-v4-pro-0813""deepseek/deepseek-v4-flash-0731" "mistralai/mistral-medium-3-5" "moonshotai/kimi-k3"- "openai/gpt-5.4" "openai/gpt-5.4-mini" "qwen/qwen3.8-max" "z-ai/glm-5.3" "z-ai/glm-5.2"}+ "openai/gpt-5.4" "openai/gpt-5.4-mini" "qwen/qwen3.8-max-0902" "z-ai/glm-5.3" "z-ai/glm-5.2"}renderable-default #{"openai/gpt-5.6-sol" "openai/gpt-5.6-terra" "openai/gpt-5.6-luna" "openai/gpt-5.5""openai/gpt-5.5-pro" "openai/gpt-5.4-pro"}budget #{"anthropic/claude-opus-4.5" "anthropic/claude-opus-4.1" "anthropic/claude-sonnet-4.5"@@ -510,7 +510,7 @@:body {:data [{:id "openai/gpt-5.6-sol" :name "OpenAI: GPT-5.6 Sol" :created 50}{:id "openai/gpt-5.6-terra" :name "OpenAI: GPT-5.6 Terra" :created 49}{:id "openai/gpt-5.6-luna" :name "OpenAI: GPT-5.6 Luna" :created 48}- {:id "qwen/qwen3.8-max" :name "Qwen: Qwen3.8 Max" :created 41}+ {:id "qwen/qwen3.8-max-0902" :name "Qwen: Qwen3.8 Max 0902" :created 41}{:id "qwen/qwen3.7-max" :name "Qwen: Qwen3.7 Max" :created 40}{:id "openai/gpt-5.4" :name "OpenAI: GPT-5.4" :created 30}{:id "openai/gpt-oss-120b:free" :name "OpenAI: gpt-oss-120b (free)" :created 28}@@ -527,7 +527,7 @@{:id "openai/gpt-5.6-luna" :display_name "OpenAI: GPT-5.6 Luna"}{:id "openai/gpt-5.6-sol" :display_name "OpenAI: GPT-5.6 Sol"}{:id "openai/gpt-5.6-terra" :display_name "OpenAI: GPT-5.6 Terra"}- {:id "qwen/qwen3.8-max" :display_name "Qwen: Qwen3.8 Max"}+ {:id "qwen/qwen3.8-max-0902" :display_name "Qwen: Qwen3.8 Max 0902"}{:id "z-ai/glm-5.3" :display_name "Z.AI: GLM 5.3"}](:models (openrouter/list-models {:credentials byok-credentials}))))))))diff --git a/test/metabase/metabot/self_test.clj b/test/metabase/metabot/self_test.cljindex 7303d84e8dc..40e44cf926b 100644--- a/test/metabase/metabot/self_test.clj+++ b/test/metabase/metabot/self_test.clj@@ -58,7 +58,10 @@(doseq [[provider-type supported] supported-models-by-provider-type](testing provider-type(is (contains? @supported (llm.provider/default-model provider-type)))- (is (contains? @supported (llm.provider/mini-model provider-type)))))))+ (is (contains? @supported (llm.provider/mini-model provider-type)))+ (testing "and a retired model reads as one the picker offers"+ (doseq [successor (vals (:retired-models (llm.provider/provider-type provider-type)))]+ (is (contains? @supported successor))))))))(deftest parse-provider-model-test(llm.tu/with-default-connectionsdiff --git a/test/metabase/metabot/settings_test.clj b/test/metabase/metabot/settings_test.cljindex 63c9c241da9..8c69d2afb27 100644--- a/test/metabase/metabot/settings_test.clj+++ b/test/metabase/metabot/settings_test.clj@@ -492,6 +492,46 @@(mt/with-temporary-setting-values [llm-mini-model nil](is (= "anthropic/claude-haiku-4-5-20251001" (metabot.settings/llm-mini-model))))))))+(deftest retired-model-reads-as-its-successor-test+ (testing "a saved retired OpenRouter id reads as the model now serving it, so the admin picker shows it selected"+ (with-connections [(connection "openrouter" "openrouter" {:api-key "sk-or-v1-test"})]+ (with-selected-model "openrouter/qwen/qwen3.8-max"+ (mt/with-temp-env-var-value! [mb-llm-mini-model nil]+ (mt/with-temporary-raw-setting-values [llm-mini-model "openrouter/qwen/qwen3.8-max"]+ (is (= "openrouter/qwen/qwen3.8-max-0902" (metabot.settings/llm-metabot-provider)))+ (is (= "openrouter/qwen/qwen3.8-max-0902" (metabot.settings/explicit-mini-model)))+ (is (= "openrouter/qwen/qwen3.8-max-0902" (metabot.settings/llm-mini-model)))+ (is (true? (metabot.settings/llm-metabot-supports-reasoning?)))+ (testing "including through the settings API the picker loads"+ (let [values (into {}+ (map (juxt :key :value))+ (mt/user-http-request :crowberto :get 200 "setting"))]+ (is (= "openrouter/qwen/qwen3.8-max-0902" (get values "llm-metabot-provider")))+ (is (= "openrouter/qwen/qwen3.8-max-0902" (get values "llm-mini-model")))))))))))++(deftest retired-model-is-stored-as-its-successor-test+ (testing "writing a retired OpenRouter id stores the model now serving it, so saved values converge"+ (with-connections [(connection "openrouter" "openrouter" {:api-key "sk-or-v1-test"})]+ (mt/with-temp-env-var-value! [mb-llm-metabot-provider nil+ mb-llm-mini-model nil]+ (mt/discard-setting-changes [llm-metabot-provider llm-mini-model]+ (metabot.settings/llm-metabot-provider! "openrouter/qwen/qwen3.8-max")+ (metabot.settings/llm-mini-model! "openrouter/qwen/qwen3.8-max")+ (is (= "openrouter/qwen/qwen3.8-max-0902" (setting/get-value-of-type :string :llm-metabot-provider)))+ (is (= "openrouter/qwen/qwen3.8-max-0902" (setting/get-value-of-type :string :llm-mini-model))))))))++(deftest retired-model-written-before-its-connection-test+ (testing (str "a retired id written before its connection exists is stored as given, and reads as its successor "+ "once the connection appears")+ (mt/with-temp-env-var-value! [mb-llm-metabot-provider nil]+ (mt/discard-setting-changes [llm-metabot-provider]+ ;; `my-openrouter` rather than `openrouter`: no environment variable can synthesize a connection under this key+ (with-connections []+ (metabot.settings/llm-metabot-provider! "my-openrouter/qwen/qwen3.8-max")+ (is (= "my-openrouter/qwen/qwen3.8-max" (setting/get-value-of-type :string :llm-metabot-provider))))+ (with-connections [(connection "my-openrouter" "openrouter" {:api-key "sk-or-v1-test"})]+ (is (= "my-openrouter/qwen/qwen3.8-max-0902" (metabot.settings/llm-metabot-provider))))))))+(deftest explicit-mini-model-reports-only-what-was-set-test(testing "the explicit reading is nil while the model is derived, so callers can tell a choice from a fallback"(with-connections [configured-anthropic]