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
Make GPT-5.4 reason in Metabot and show Bedrock GPT summaries (#83784)
Andrei Simionescuef59a82379fa
diff --git a/src/metabase/metabot/self/bedrock.clj b/src/metabase/metabot/self/bedrock.cljindex 8de32c5c56c..fd50d788eaf 100644--- a/src/metabase/metabot/self/bedrock.clj+++ b/src/metabase/metabot/self/bedrock.clj@@ -401,14 +401,7 @@(case (model-family model):anthropic (claude/reasoning-model? model):runtime (claude/reasoning-model? (runtime-base-model model))- ;; The mantle's Responses surface accepts the reasoning request fields and- ;; the GPT models do reason (at a per-model default effort: gpt-5.4 "none",- ;; gpt-5.5 "medium"), but it never streams reasoning summaries — `summary`- ;; comes back empty at every effort/summary combination — so nothing will- ;; ever render. The request deliberately keeps its reasoning fields (see- ;; [[openai/openai-request-body]]): where the model reasons by default they- ;; buy encrypted-content replay across tool calls.- :openai false+ :openai (openai/reasoning-model? model)nil false))(mu/defn streams-reasoning? :- :booleandiff --git a/src/metabase/metabot/self/openai.clj b/src/metabase/metabot/self/openai.cljindex e47ca2a356a..b714dc16da0 100644--- a/src/metabase/metabot/self/openai.clj+++ b/src/metabase/metabot/self/openai.clj@@ -297,6 +297,12 @@[model](not (model-supports-temperature? model)))+(defn- reasons-only-when-asked?+ "Whether `model` defaults to reasoning effort `none`, so it doesn't reason unless the request sets an effort.+ That's GPT-5.4 and its mini and nano; GPT-5.4 Pro defaults to `medium`."+ [model]+ (boolean (re-find #"^gpt-5\.4(?!-pro)" (strip-vendor-prefix model))))+(mu/defn streams-reasoning? :- :boolean"Registry capability. OpenAI answers from the model name."[{:keys [model]} :- adapter/ResolvedRef]@@ -330,7 +336,8 @@;; encrypted_content lets us replay reasoning items across tool-call;; round-trips despite store:false — see [[parts->openai-input]](and reasoning? (reasoning-model? model))- (assoc :reasoning {:summary "auto"}+ (assoc :reasoning (cond-> {:summary "auto"}+ (and (not schema) (reasons-only-when-asked? model)) (assoc :effort "low")):include ["reasoning.encrypted_content"])(and temperature (model-supports-temperature? model))diff --git a/test/metabase/metabot/self/bedrock_test.clj b/test/metabase/metabot/self/bedrock_test.cljindex 4dd8c52925c..4caae8912f5 100644--- a/test/metabase/metabot/self/bedrock_test.clj+++ b/test/metabase/metabot/self/bedrock_test.clj@@ -375,27 +375,20 @@(doseq [model (keys @#'bedrock/supported-models)](testing model(let [body (captured-body! {:model model})]- ;; `case` so a model of an unknown family fails loudly here- (case (#'bedrock/model-family model)- :anthropic- (testing "the gate and the thinking request agree"- (is (= (bedrock/reasoning-model? model) (contains? body :thinking))))- ;; deliberately asymmetric: the request keeps its reasoning fields- ;; (encrypted-content replay works) while the gate answers false,- ;; because the mantle never streams summaries — nothing will render.- ;; See [[bedrock/reasoning-model?]].- :openai- (testing "reasoning is requested but the gate answers false"- (is (contains? body :reasoning))- (is (false? (bedrock/reasoning-model? model)))))))))+ (testing "the gate and the reasoning request agree"+ (is (= (bedrock/reasoning-model? model)+ ;; `case` so a model of an unknown family fails loudly here+ (contains? body (case (#'bedrock/model-family model)+ :anthropic :thinking+ :openai :reasoning)))))))))(deftest ^:parallel reasoning-model?-test(are [model expected] (= expected (bedrock/reasoning-model? model))"anthropic.claude-opus-4-8" true"anthropic.claude-fable-5" true"anthropic.claude-haiku-4-5" false- "openai.gpt-5.5" false- "openai.gpt-5.4-2026-03-05" false+ "openai.gpt-5.5" true+ "openai.gpt-5.4-2026-03-05" true"deepseek.v3.2" falsenil false))@@ -486,9 +479,6 @@{:type "message_delta" :delta {:stop_reason "end_turn"} :usage {:input_tokens 3 :output_tokens 2}}{:type "message_stop"}]))))-;; The mantle has never been observed to emit reasoning_summary_* events (see-;; [[bedrock/reasoning-model?]]) — this pins the translation wiring so only the-;; gate needs flipping if it ever starts.(deftest openai-model-streams-reasoning-test(is (=? [{:type :start :id "resp_1"}{:type :reasoning :text "keeping it short"}diff --git a/test/metabase/metabot/self/openai_test.clj b/test/metabase/metabot/self/openai_test.cljindex ca27d887d88..1ebe5d803b8 100644--- a/test/metabase/metabot/self/openai_test.clj+++ b/test/metabase/metabot/self/openai_test.clj@@ -368,14 +368,22 @@(deftest ^:parallel openai-request-body-reasoning-gating-test(testing "reasoning models ask for a summary; others don't"(let [reasoning #(:reasoning (openai/openai-request-body {:model % :input []}))]- (is (= {:summary "auto"} (reasoning "gpt-5.4")))+ (is (= {:summary "auto"} (reasoning "gpt-5.5")))(is (= {:summary "auto"} (reasoning "gpt-5.6-sol")))(is (= {:summary "auto"} (reasoning "gpt-6-astra")))(is (= {:summary "auto"} (reasoning "o3")))+ (is (= {:summary "auto"} (reasoning "gpt-5.4-pro")))(testing "bedrock/azure vendor prefix is stripped"- (is (= {:summary "auto"} (reasoning "openai.gpt-5.4"))))+ (is (= {:summary "auto"} (reasoning "openai.gpt-5.5"))))(testing "non-reasoning models get no reasoning param"(is (nil? (reasoning "gpt-4.1"))))))+ (testing "GPT-5.4, its mini and its nano default to no reasoning, so chat requests ask for low effort"+ (are [model] (= {:summary "auto" :effort "low"}+ (:reasoning (openai/openai-request-body {:model model :input []})))+ "gpt-5.4" "gpt-5.4-mini" "gpt-5.4-nano" "gpt-5.4-2026-03-05" "openai.gpt-5.4" "GPT-5.4")+ (testing "but structured output keeps the model's default"+ (is (= {:summary "auto"}+ (:reasoning (openai/openai-request-body {:model "gpt-5.4" :input [] :schema {:type "object"}}))))))(testing "reasoning requests ask for encrypted content so items can be replayed"(is (= ["reasoning.encrypted_content"](:include (openai/openai-request-body {:model "gpt-5.4" :input []}))))diff --git a/test/metabase/metabot/settings_test.clj b/test/metabase/metabot/settings_test.cljindex 162291e5ac4..cccdabf9257 100644--- a/test/metabase/metabot/settings_test.clj+++ b/test/metabase/metabot/settings_test.clj@@ -209,9 +209,7 @@"openai/gpt-4o" false"bedrock/anthropic.claude-opus-4-8" true"bedrock/anthropic.claude-haiku-4-5" false- ;; requests reasoning (encrypted replay), but the mantle never- ;; streams summaries, so nothing renders — see bedrock/reasoning-model?- "bedrock/openai.gpt-5.5" false+ "bedrock/openai.gpt-5.5" true"azure/anthropic/claude-opus-5" true"azure/anthropic/claude-haiku-4-5" false"azure/openai/gpt-5.4" true