Skip to content

Commit ecc4440

Browse files
committed
🤖 feat: add GPT-5.1-Codex-Max model with xhigh reasoning level
Add support for OpenAI's gpt-5.1-codex-max model which introduces a new 'xhigh' (Extra High) reasoning effort level for extended deep thinking. Changes: - Extended ThinkingLevel type to include 'xhigh' as 5th option - Added GPT_CODEX_MAX to known models with codex-max alias - Updated thinking policy to return 5 levels for codex-max only - Added xhigh to UI level descriptions and command palette - Added model pricing/capability data to models-extra - Updated SendMessageOptionsSchema to accept xhigh - Added comprehensive tests for codex-max policy The xhigh level is exclusive to gpt-5.1-codex-max. Other models gracefully fall back to their maximum supported level when xhigh is requested. Change-Id: Iab7ba7187703e275c4c0aa76779381dff4006316 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 4d1947a commit ecc4440

File tree

9 files changed

+105
-7
lines changed

9 files changed

+105
-7
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
513513
low: "Low — adds light reasoning",
514514
medium: "Medium — balanced reasoning",
515515
high: "High — maximum reasoning depth",
516+
xhigh: "Extra High — extended deep thinking",
516517
};
517518

518519
setToast({

src/browser/utils/commands/sources.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface BuildSourcesParams {
5050
onOpenSettings?: (section?: string) => void;
5151
}
5252

53-
const THINKING_LEVELS: ThinkingLevel[] = ["off", "low", "medium", "high"];
53+
const THINKING_LEVELS: ThinkingLevel[] = ["off", "low", "medium", "high", "xhigh"];
5454

5555
/**
5656
* Command palette section names
@@ -431,6 +431,7 @@ export function buildCoreSources(p: BuildSourcesParams): Array<() => CommandActi
431431
low: "Low — add a bit of reasoning",
432432
medium: "Medium — balanced reasoning",
433433
high: "High — maximum reasoning depth",
434+
xhigh: "Extra High — extended deep thinking",
434435
};
435436
const currentLevel = p.getThinkingLevel(workspaceId);
436437

src/browser/utils/thinking/policy.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@ import { describe, expect, test } from "bun:test";
22
import { getThinkingPolicyForModel, enforceThinkingPolicy } from "./policy";
33

44
describe("getThinkingPolicyForModel", () => {
5+
test("returns 5 levels including xhigh for gpt-5.1-codex-max", () => {
6+
expect(getThinkingPolicyForModel("openai:gpt-5.1-codex-max")).toEqual([
7+
"off",
8+
"low",
9+
"medium",
10+
"high",
11+
"xhigh",
12+
]);
13+
});
14+
15+
test("returns 5 levels for gpt-5.1-codex-max with version suffix", () => {
16+
expect(getThinkingPolicyForModel("openai:gpt-5.1-codex-max-2025-12-01")).toEqual([
17+
"off",
18+
"low",
19+
"medium",
20+
"high",
21+
"xhigh",
22+
]);
23+
});
24+
25+
test("returns 5 levels for gpt-5.1-codex-max with whitespace after colon", () => {
26+
expect(getThinkingPolicyForModel("openai: gpt-5.1-codex-max")).toEqual([
27+
"off",
28+
"low",
29+
"medium",
30+
"high",
31+
"xhigh",
32+
]);
33+
});
34+
535
test("returns single HIGH for gpt-5-pro base model", () => {
636
expect(getThinkingPolicyForModel("openai:gpt-5-pro")).toEqual(["high"]);
737
});
@@ -111,6 +141,32 @@ describe("enforceThinkingPolicy", () => {
111141
expect(enforceThinkingPolicy("anthropic:claude-opus-4-5-20251101", "off")).toBe("off");
112142
});
113143
});
144+
145+
describe("GPT-5.1-Codex-Max (5 levels including xhigh)", () => {
146+
test("allows all 5 levels including xhigh", () => {
147+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max", "off")).toBe("off");
148+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max", "low")).toBe("low");
149+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max", "medium")).toBe("medium");
150+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max", "high")).toBe("high");
151+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max", "xhigh")).toBe("xhigh");
152+
});
153+
154+
test("allows xhigh for versioned model", () => {
155+
expect(enforceThinkingPolicy("openai:gpt-5.1-codex-max-2025-12-01", "xhigh")).toBe("xhigh");
156+
});
157+
});
158+
159+
describe("xhigh fallback for non-codex-max models", () => {
160+
test("falls back to medium when xhigh requested on standard model", () => {
161+
// Standard models don't support xhigh, so fall back to medium (preferred fallback)
162+
expect(enforceThinkingPolicy("anthropic:claude-opus-4-5", "xhigh")).toBe("medium");
163+
});
164+
165+
test("falls back to high when xhigh requested on gpt-5-pro", () => {
166+
// gpt-5-pro only supports high, so xhigh falls back to high
167+
expect(enforceThinkingPolicy("openai:gpt-5-pro", "xhigh")).toBe("high");
168+
});
169+
});
114170
});
115171

116172
// Note: Tests for invalid levels removed - TypeScript type system prevents invalid

src/browser/utils/thinking/policy.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ export type ThinkingPolicy = readonly ThinkingLevel[];
2424
* Returns the thinking policy for a given model.
2525
*
2626
* Rules:
27+
* - openai:gpt-5.1-codex-max → ["off", "low", "medium", "high", "xhigh"] (5 levels including xhigh)
2728
* - openai:gpt-5-pro → ["high"] (only supported level)
2829
* - gemini-3 → ["low", "high"] (thinking level only)
29-
* - default → ["off", "low", "medium", "high"] (all levels selectable)
30+
* - default → ["off", "low", "medium", "high"] (standard 4 levels)
3031
*
3132
* Tolerates version suffixes (e.g., gpt-5-pro-2025-10-06).
3233
* Does NOT match gpt-5-pro-mini (uses negative lookahead).
3334
*/
3435
export function getThinkingPolicyForModel(modelString: string): ThinkingPolicy {
36+
// GPT-5.1-Codex-Max supports 5 reasoning levels including xhigh (Extra High)
37+
// Match "openai:" followed by optional whitespace and "gpt-5.1-codex-max"
38+
if (/^openai:\s*gpt-5\.1-codex-max/.test(modelString)) {
39+
return ["off", "low", "medium", "high", "xhigh"];
40+
}
41+
3542
// Match "openai:" followed by optional whitespace and "gpt-5-pro"
3643
// Allow version suffixes like "-2025-10-06" but NOT "-mini" or other text suffixes
3744
if (/^openai:\s*gpt-5-pro(?!-[a-z])/.test(modelString)) {
@@ -43,7 +50,7 @@ export function getThinkingPolicyForModel(modelString: string): ThinkingPolicy {
4350
return ["low", "high"];
4451
}
4552

46-
// Default policy: all levels selectable
53+
// Default policy: standard 4 levels (xhigh only for codex-max)
4754
return ["off", "low", "medium", "high"];
4855
}
4956

src/common/constants/knownModels.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ const MODEL_DEFINITIONS = {
7070
providerModelId: "gpt-5.1-codex-mini",
7171
aliases: ["codex-mini"],
7272
},
73+
GPT_CODEX_MAX: {
74+
provider: "openai",
75+
providerModelId: "gpt-5.1-codex-max",
76+
aliases: ["codex-max"],
77+
warm: true,
78+
tokenizerOverride: "openai/gpt-5",
79+
},
7380
GEMINI_3_PRO: {
7481
provider: "google",
7582
providerModelId: "gemini-3-pro-preview",

src/common/orpc/schemas/stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export const ToolPolicySchema = z.array(ToolPolicyFilterSchema).meta({
313313
// SendMessage options
314314
export const SendMessageOptionsSchema = z.object({
315315
editMessageId: z.string().optional(),
316-
thinkingLevel: z.enum(["off", "low", "medium", "high"]).optional(),
316+
thinkingLevel: z.enum(["off", "low", "medium", "high", "xhigh"]).optional(),
317317
model: z.string("No model specified"),
318318
toolPolicy: ToolPolicySchema.optional(),
319319
additionalSystemInstructions: z.string().optional(),

src/common/types/thinking.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* different AI providers (Anthropic, OpenAI, etc.)
66
*/
77

8-
export type ThinkingLevel = "off" | "low" | "medium" | "high";
8+
export type ThinkingLevel = "off" | "low" | "medium" | "high" | "xhigh";
99

1010
/**
1111
* Active thinking levels (excludes "off")
@@ -30,6 +30,7 @@ export const ANTHROPIC_THINKING_BUDGETS: Record<ThinkingLevel, number> = {
3030
low: 4000,
3131
medium: 10000,
3232
high: 20000,
33+
xhigh: 20000, // Same as high - Anthropic doesn't support xhigh
3334
};
3435

3536
/**
@@ -47,6 +48,7 @@ export const ANTHROPIC_EFFORT: Record<ThinkingLevel, "low" | "medium" | "high">
4748
low: "low",
4849
medium: "medium",
4950
high: "high",
51+
xhigh: "high", // Fallback to high - Anthropic doesn't support xhigh
5052
};
5153

5254
/**
@@ -66,6 +68,7 @@ export const OPENAI_REASONING_EFFORT: Record<ThinkingLevel, string | undefined>
6668
low: "low",
6769
medium: "medium",
6870
high: "high",
71+
xhigh: "xhigh", // Extra High - only supported by gpt-5.1-codex-max
6972
};
7073

7174
/**
@@ -83,6 +86,7 @@ export const GEMINI_THINKING_BUDGETS: Record<ThinkingLevel, number> = {
8386
low: 2048,
8487
medium: 8192,
8588
high: 16384, // Conservative max (some models go to 32k)
89+
xhigh: 16384, // Same as high - Gemini doesn't support xhigh
8690
} as const;
8791
export const OPENROUTER_REASONING_EFFORT: Record<
8892
ThinkingLevel,
@@ -92,4 +96,5 @@ export const OPENROUTER_REASONING_EFFORT: Record<
9296
low: "low",
9397
medium: "medium",
9498
high: "high",
99+
xhigh: "high", // Fallback to high - OpenRouter doesn't support xhigh
95100
};

src/common/utils/ai/providerOptions.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ export function buildProviderOptions(
254254
};
255255

256256
if (isGemini3) {
257-
// Gemini 3 uses thinkingLevel (low/high)
258-
thinkingConfig.thinkingLevel = effectiveThinking === "medium" ? "low" : effectiveThinking;
257+
// Gemini 3 uses thinkingLevel (low/high) - map medium/xhigh to supported values
258+
thinkingConfig.thinkingLevel =
259+
effectiveThinking === "medium" || effectiveThinking === "xhigh"
260+
? "high"
261+
: effectiveThinking;
259262
} else {
260263
// Gemini 2.5 uses thinkingBudget
261264
const budget = GEMINI_THINKING_BUDGETS[effectiveThinking];

src/common/utils/tokens/models-extra.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,22 @@ export const modelsExtra: Record<string, ModelData> = {
8888
supports_reasoning: true,
8989
supports_response_schema: true,
9090
},
91+
92+
// GPT-5.1-Codex-Max - Extended reasoning model with xhigh support
93+
// Pricing TBD - using estimated values based on Codex pricing pattern
94+
// Supports 5 reasoning levels: off, low, medium, high, xhigh
95+
"gpt-5.1-codex-max": {
96+
max_input_tokens: 400000, // Estimated based on compaction capability
97+
max_output_tokens: 272000, // Same as gpt-5-pro
98+
input_cost_per_token: 0.00002, // $20/M - placeholder estimate
99+
output_cost_per_token: 0.00008, // $80/M - placeholder estimate
100+
litellm_provider: "openai",
101+
mode: "chat",
102+
supports_function_calling: true,
103+
supports_vision: true,
104+
supports_reasoning: true,
105+
supports_response_schema: true,
106+
knowledge_cutoff: "2025-06-30", // Estimated
107+
supported_endpoints: ["/v1/responses"],
108+
},
91109
};

0 commit comments

Comments
 (0)