Merge pull request #2390 from acamq/fix/think-variant-switcher

fix(think-mode): remove modelID modification, only set variant
This commit is contained in:
acamq
2026-03-08 20:01:36 -06:00
committed by GitHub
4 changed files with 24 additions and 28 deletions

View File

@@ -1,7 +1,7 @@
const ENGLISH_PATTERNS = [/\bultrathink\b/i, /\bthink\b/i]
const MULTILINGUAL_KEYWORDS = [
"생각", "고민", "검토", "제대로",
"생각", "검토", "제대로",
"思考", "考虑", "考慮",
"思考", "考え", "熟考",
"सोच", "विचार",

View File

@@ -1,5 +1,5 @@
import { detectThinkKeyword, extractPromptText } from "./detector"
import { getHighVariant, isAlreadyHighVariant } from "./switcher"
import { isAlreadyHighVariant } from "./switcher"
import type { ThinkModeState } from "./types"
import { log } from "../../shared"
@@ -56,22 +56,10 @@ export function createThinkModeHook() {
return
}
const highVariant = getHighVariant(currentModel.modelID)
if (highVariant) {
output.message.model = {
providerID: currentModel.providerID,
modelID: highVariant,
}
output.message.variant = "high"
state.modelSwitched = true
state.variantSet = true
log("Think mode: model switched to high variant", {
sessionID,
from: currentModel.modelID,
to: highVariant,
})
}
output.message.variant = "high"
state.modelSwitched = false
state.variantSet = true
log("Think mode: variant set to high", { sessionID })
thinkModeState.set(sessionID, state)
},

View File

@@ -43,7 +43,7 @@ describe("createThinkModeHook", () => {
clearThinkModeState(sessionID)
})
it("sets high variant and switches model when think keyword is present", async () => {
it("sets high variant when think keyword is present", async () => {
// given
const hook = createThinkModeHook()
const input = createHookInput({
@@ -58,13 +58,10 @@ describe("createThinkModeHook", () => {
// then
expect(output.message.variant).toBe("high")
expect(output.message.model).toEqual({
providerID: "github-copilot",
modelID: "claude-opus-4-6-high",
})
expect(output.message.model).toBeUndefined()
})
it("supports dotted model IDs by switching to normalized high variant", async () => {
it("sets high variant for dotted model IDs", async () => {
// given
const hook = createThinkModeHook()
const input = createHookInput({
@@ -79,10 +76,7 @@ describe("createThinkModeHook", () => {
// then
expect(output.message.variant).toBe("high")
expect(output.message.model).toEqual({
providerID: "github-copilot",
modelID: "gpt-5-4-high",
})
expect(output.message.model).toBeUndefined()
})
it("skips when message variant is already set", async () => {

View File

@@ -4,6 +4,20 @@ import {
isAlreadyHighVariant,
} from "./switcher"
/**
* DEPRECATION NOTICE:
*
* getHighVariant() is no longer used by the think-mode hook.
* The hook now only sets output.message.variant = "high" and lets
* OpenCode's native variant system handle the transformation.
*
* This function is kept for:
* - Potential future validation use
* - Backward compatibility for external consumers
*
* Tests verify the function still works correctly.
*/
describe("think-mode switcher", () => {
describe("Model ID normalization", () => {
describe("getHighVariant with dots vs hyphens", () => {