diff --git a/src/hooks/think-mode/index.ts b/src/hooks/think-mode/index.ts index 078e530..b8d7966 100644 --- a/src/hooks/think-mode/index.ts +++ b/src/hooks/think-mode/index.ts @@ -1,6 +1,7 @@ import { detectThinkKeyword, extractPromptText } from "./detector" -import { getHighVariant, isAlreadyHighVariant } from "./switcher" +import { getHighVariant, isAlreadyHighVariant, getThinkingConfig } from "./switcher" import type { ThinkModeState, ThinkModeInput } from "./types" +import { log } from "../../shared" export * from "./detector" export * from "./switcher" @@ -23,6 +24,7 @@ export function createThinkModeHook() { const state: ThinkModeState = { requested: false, modelSwitched: false, + thinkingConfigInjected: false, } if (!detectThinkKeyword(promptText)) { @@ -47,17 +49,31 @@ export function createThinkModeHook() { } const highVariant = getHighVariant(currentModel.modelID) + const thinkingConfig = getThinkingConfig(currentModel.providerID, currentModel.modelID) - if (!highVariant) { - thinkModeState.set(sessionID, state) - return + if (highVariant) { + output.message.model = { + providerID: currentModel.providerID, + modelID: highVariant, + } + state.modelSwitched = true + log("Think mode: model switched to high variant", { + sessionID, + from: currentModel.modelID, + to: highVariant, + }) } - output.message.model = { - providerID: currentModel.providerID, - modelID: highVariant, + if (thinkingConfig) { + Object.assign(output.message, thinkingConfig) + state.thinkingConfigInjected = true + log("Think mode: thinking config injected", { + sessionID, + provider: currentModel.providerID, + config: thinkingConfig, + }) } - state.modelSwitched = true + thinkModeState.set(sessionID, state) }, diff --git a/src/hooks/think-mode/switcher.ts b/src/hooks/think-mode/switcher.ts index 5bea88b..cf94e30 100644 --- a/src/hooks/think-mode/switcher.ts +++ b/src/hooks/think-mode/switcher.ts @@ -55,12 +55,14 @@ export const THINKING_CONFIGS: Record> = { type: "enabled", budgetTokens: 64000, }, + maxTokens: 128000, }, "amazon-bedrock": { reasoningConfig: { type: "enabled", budgetTokens: 32000, }, + maxTokens: 64000, }, google: { providerOptions: { diff --git a/src/hooks/think-mode/types.ts b/src/hooks/think-mode/types.ts index c36d523..b17d654 100644 --- a/src/hooks/think-mode/types.ts +++ b/src/hooks/think-mode/types.ts @@ -1,6 +1,7 @@ export interface ThinkModeState { requested: boolean modelSwitched: boolean + thinkingConfigInjected: boolean providerID?: string modelID?: string }