Merge pull request #2390 from acamq/fix/think-variant-switcher
fix(think-mode): remove modelID modification, only set variant
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const ENGLISH_PATTERNS = [/\bultrathink\b/i, /\bthink\b/i]
|
const ENGLISH_PATTERNS = [/\bultrathink\b/i, /\bthink\b/i]
|
||||||
|
|
||||||
const MULTILINGUAL_KEYWORDS = [
|
const MULTILINGUAL_KEYWORDS = [
|
||||||
"생각", "고민", "검토", "제대로",
|
"생각", "검토", "제대로",
|
||||||
"思考", "考虑", "考慮",
|
"思考", "考虑", "考慮",
|
||||||
"思考", "考え", "熟考",
|
"思考", "考え", "熟考",
|
||||||
"सोच", "विचार",
|
"सोच", "विचार",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { detectThinkKeyword, extractPromptText } from "./detector"
|
import { detectThinkKeyword, extractPromptText } from "./detector"
|
||||||
import { getHighVariant, isAlreadyHighVariant } from "./switcher"
|
import { isAlreadyHighVariant } from "./switcher"
|
||||||
import type { ThinkModeState } from "./types"
|
import type { ThinkModeState } from "./types"
|
||||||
import { log } from "../../shared"
|
import { log } from "../../shared"
|
||||||
|
|
||||||
@@ -56,22 +56,10 @@ export function createThinkModeHook() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const highVariant = getHighVariant(currentModel.modelID)
|
output.message.variant = "high"
|
||||||
|
state.modelSwitched = false
|
||||||
if (highVariant) {
|
state.variantSet = true
|
||||||
output.message.model = {
|
log("Think mode: variant set to high", { sessionID })
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
thinkModeState.set(sessionID, state)
|
thinkModeState.set(sessionID, state)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ describe("createThinkModeHook", () => {
|
|||||||
clearThinkModeState(sessionID)
|
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
|
// given
|
||||||
const hook = createThinkModeHook()
|
const hook = createThinkModeHook()
|
||||||
const input = createHookInput({
|
const input = createHookInput({
|
||||||
@@ -58,13 +58,10 @@ describe("createThinkModeHook", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
expect(output.message.variant).toBe("high")
|
expect(output.message.variant).toBe("high")
|
||||||
expect(output.message.model).toEqual({
|
expect(output.message.model).toBeUndefined()
|
||||||
providerID: "github-copilot",
|
|
||||||
modelID: "claude-opus-4-6-high",
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("supports dotted model IDs by switching to normalized high variant", async () => {
|
it("sets high variant for dotted model IDs", async () => {
|
||||||
// given
|
// given
|
||||||
const hook = createThinkModeHook()
|
const hook = createThinkModeHook()
|
||||||
const input = createHookInput({
|
const input = createHookInput({
|
||||||
@@ -79,10 +76,7 @@ describe("createThinkModeHook", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
expect(output.message.variant).toBe("high")
|
expect(output.message.variant).toBe("high")
|
||||||
expect(output.message.model).toEqual({
|
expect(output.message.model).toBeUndefined()
|
||||||
providerID: "github-copilot",
|
|
||||||
modelID: "gpt-5-4-high",
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("skips when message variant is already set", async () => {
|
it("skips when message variant is already set", async () => {
|
||||||
|
|||||||
@@ -4,6 +4,20 @@ import {
|
|||||||
isAlreadyHighVariant,
|
isAlreadyHighVariant,
|
||||||
} from "./switcher"
|
} 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("think-mode switcher", () => {
|
||||||
describe("Model ID normalization", () => {
|
describe("Model ID normalization", () => {
|
||||||
describe("getHighVariant with dots vs hyphens", () => {
|
describe("getHighVariant with dots vs hyphens", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user