Skip to content

Commit b6ae3b7

Browse files
committed
refactor: simplify reasoning policy to minimal checks
Just three simple startsWith/includes checks for special models. No config files, no helper functions, no complexity. - Grok models: binary on/off reasoning - GPT-5 Pro: always high - Gemini 3: limited levels - Everything else: check models.json or default to all levels
1 parent aa45dbe commit b6ae3b7

File tree

3 files changed

+17
-67
lines changed

3 files changed

+17
-67
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ describe("getThinkingPolicyForModel", () => {
5252
expect(getThinkingPolicyForModel("xai:grok-beta")).toEqual(["off", "high"]);
5353
});
5454

55-
test("grok models with version suffixes match config prefix", () => {
55+
test("grok models with version suffixes also get binary policy", () => {
5656
expect(getThinkingPolicyForModel("xai:grok-4-1-fast-v2")).toEqual(["off", "high"]);
5757
});
5858

59-
test("unknown xAI models get default policy", () => {
59+
test("grok-code does not match grok- prefix, gets default policy", () => {
6060
expect(getThinkingPolicyForModel("xai:grok-code-fast-1")).toEqual([
6161
"off",
6262
"low",

src/browser/utils/thinking/policy.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414

1515
import type { ThinkingLevel } from "@/common/types/thinking";
16-
import { getReasoningConfig } from "@/common/constants/reasoning-config";
1716
import modelsData from "@/common/utils/tokens/models.json";
1817

1918
/**
@@ -47,26 +46,30 @@ function getModelMetadata(modelString: string): Record<string, unknown> | null {
4746

4847
/**
4948
* Returns the thinking policy for a given model.
50-
*
51-
* Rules:
52-
* 1. Check reasoning-config.ts for explicit model policies
53-
* 2. Check models.json for supports_reasoning: false → ["off"]
54-
* 3. Default → ["off", "low", "medium", "high"]
5549
*/
5650
export function getThinkingPolicyForModel(modelString: string): ThinkingPolicy {
57-
// Check explicit config first
58-
const config = getReasoningConfig(modelString);
59-
if (config) {
60-
return config;
51+
// GPT-5 Pro: always high
52+
if (modelString.startsWith("openai:gpt-5-pro")) {
53+
return ["high"];
54+
}
55+
56+
// Gemini 3: limited levels
57+
if (modelString.includes("gemini-3")) {
58+
return ["low", "high"];
59+
}
60+
61+
// Grok: binary on/off (but not grok-code)
62+
if (modelString.startsWith("xai:grok-") && !modelString.includes("grok-code")) {
63+
return ["off", "high"];
6164
}
6265

63-
// Check models.json for models that don't support reasoning
66+
// Check models.json for no reasoning support
6467
const metadata = getModelMetadata(modelString);
6568
if (metadata?.supports_reasoning === false) {
6669
return ["off"];
6770
}
6871

69-
// Default: all levels selectable
72+
// Default: all levels
7073
return ["off", "low", "medium", "high"];
7174
}
7275

src/common/constants/reasoning-config.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)