From 6d52e88b33e2d9a41a0cd65106f5914fd2d57cd8 Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Fri, 12 Dec 2025 13:48:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20fix:=20enable=20xhigh=20thinking?= =?UTF-8?q?=20for=20gpt-5.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7af560b6693e4dc4364c98bc98eca70f3822534b Signed-off-by: Thomas Kosiewski --- src/browser/utils/thinking/policy.test.ts | 44 +++++++++++++++++++++++ src/browser/utils/thinking/policy.ts | 10 ++++-- src/common/types/thinking.ts | 2 +- src/common/utils/tokens/models-extra.ts | 1 + 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/browser/utils/thinking/policy.test.ts b/src/browser/utils/thinking/policy.test.ts index 4e259c0306..0fe7bc27b2 100644 --- a/src/browser/utils/thinking/policy.test.ts +++ b/src/browser/utils/thinking/policy.test.ts @@ -64,6 +64,36 @@ describe("getThinkingPolicyForModel", () => { ]); }); + test("returns 5 levels including xhigh for gpt-5.2", () => { + expect(getThinkingPolicyForModel("openai:gpt-5.2")).toEqual([ + "off", + "low", + "medium", + "high", + "xhigh", + ]); + }); + + test("returns 5 levels including xhigh for gpt-5.2 behind mux-gateway", () => { + expect(getThinkingPolicyForModel("mux-gateway:openai/gpt-5.2")).toEqual([ + "off", + "low", + "medium", + "high", + "xhigh", + ]); + }); + + test("returns 5 levels including xhigh for gpt-5.2 with version suffix", () => { + expect(getThinkingPolicyForModel("openai:gpt-5.2-2025-12-11")).toEqual([ + "off", + "low", + "medium", + "high", + "xhigh", + ]); + }); + test("returns 5 levels including xhigh for gpt-5.1-codex-max behind mux-gateway", () => { expect(getThinkingPolicyForModel("mux-gateway:openai/gpt-5.1-codex-max")).toEqual([ "off", @@ -205,6 +235,20 @@ describe("enforceThinkingPolicy", () => { }); }); + describe("GPT-5.2 (5 levels including xhigh)", () => { + test("allows xhigh for base model", () => { + expect(enforceThinkingPolicy("openai:gpt-5.2", "xhigh")).toBe("xhigh"); + }); + + test("allows xhigh behind mux-gateway", () => { + expect(enforceThinkingPolicy("mux-gateway:openai/gpt-5.2", "xhigh")).toBe("xhigh"); + }); + + test("allows xhigh for versioned model", () => { + expect(enforceThinkingPolicy("openai:gpt-5.2-2025-12-11", "xhigh")).toBe("xhigh"); + }); + }); + describe("xhigh fallback for non-codex-max models", () => { test("falls back to medium when xhigh requested on standard model", () => { // Standard models don't support xhigh, so fall back to medium (preferred fallback) diff --git a/src/browser/utils/thinking/policy.ts b/src/browser/utils/thinking/policy.ts index 7bcfcac869..3fd3fbafd0 100644 --- a/src/browser/utils/thinking/policy.ts +++ b/src/browser/utils/thinking/policy.ts @@ -25,10 +25,11 @@ export type ThinkingPolicy = readonly ThinkingLevel[]; * * Rules: * - openai:gpt-5.1-codex-max → ["off", "low", "medium", "high", "xhigh"] (5 levels including xhigh) + * - openai:gpt-5.2 → ["off", "low", "medium", "high", "xhigh"] (5 levels including xhigh) * - openai:gpt-5.2-pro → ["medium", "high", "xhigh"] (3 levels) * - openai:gpt-5-pro → ["high"] (only supported level, legacy) * - gemini-3 → ["low", "high"] (thinking level only) - * - default → ["off", "low", "medium", "high"] (standard 4 levels) + * - default → ["off", "low", "medium", "high"] (standard 4 levels; xhigh is opt-in per model) * * Tolerates version suffixes (e.g., gpt-5-pro-2025-10-06). * Does NOT match gpt-5-pro-mini (uses negative lookahead). @@ -55,6 +56,11 @@ export function getThinkingPolicyForModel(modelString: string): ThinkingPolicy { return ["medium", "high", "xhigh"]; } + // gpt-5.2 supports 5 reasoning levels including xhigh (Extra High) + if (/^gpt-5\.2(?!-[a-z])/.test(withoutProviderNamespace)) { + return ["off", "low", "medium", "high", "xhigh"]; + } + // gpt-5-pro (legacy) only supports high if (/^gpt-5-pro(?!-[a-z])/.test(withoutProviderNamespace)) { return ["high"]; @@ -65,7 +71,7 @@ export function getThinkingPolicyForModel(modelString: string): ThinkingPolicy { return ["low", "high"]; } - // Default policy: standard 4 levels (xhigh only for codex-max) + // Default policy: standard 4 levels (off/low/medium/high). Models with xhigh must opt in above. return ["off", "low", "medium", "high"]; } diff --git a/src/common/types/thinking.ts b/src/common/types/thinking.ts index a30d258793..0b820144e8 100644 --- a/src/common/types/thinking.ts +++ b/src/common/types/thinking.ts @@ -68,7 +68,7 @@ export const OPENAI_REASONING_EFFORT: Record low: "low", medium: "medium", high: "high", - xhigh: "xhigh", // Extra High - only supported by gpt-5.1-codex-max + xhigh: "xhigh", // Extra High - supported by models that expose xhigh (e.g., gpt-5.1-codex-max, gpt-5.2) }; /** diff --git a/src/common/utils/tokens/models-extra.ts b/src/common/utils/tokens/models-extra.ts index 9d24f7abe9..3863a4b2b7 100644 --- a/src/common/utils/tokens/models-extra.ts +++ b/src/common/utils/tokens/models-extra.ts @@ -43,6 +43,7 @@ export const modelsExtra: Record = { // GPT-5.2 - Released December 11, 2025 // $1.75/M input, $14/M output // Cached input: $0.175/M + // Supports off, low, medium, high, xhigh reasoning levels "gpt-5.2": { max_input_tokens: 400000, max_output_tokens: 128000,