Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/browser/utils/thinking/policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions src/browser/utils/thinking/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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"];
Expand All @@ -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"];
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/types/thinking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const OPENAI_REASONING_EFFORT: Record<ThinkingLevel, string | undefined>
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)
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/common/utils/tokens/models-extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const modelsExtra: Record<string, ModelData> = {
// 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,
Expand Down
Loading