fix: respect enableReasoningEffort setting when determining reasoning usage (#7049)

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
This commit is contained in:
roomote[bot] 2025-08-18 15:07:06 -07:00 committed by GitHub
parent b975ced81b
commit 87c42c1f26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions

View file

@ -375,12 +375,41 @@ describe("shouldUseReasoningEffort", () => {
reasoningEffort: "medium",
}
// Should return true regardless of settings
// Should return true regardless of settings (unless explicitly disabled)
expect(shouldUseReasoningEffort({ model })).toBe(true)
expect(shouldUseReasoningEffort({ model, settings: {} })).toBe(true)
expect(shouldUseReasoningEffort({ model, settings: { reasoningEffort: undefined } })).toBe(true)
})
test("should return false when enableReasoningEffort is false, even if reasoningEffort is set", () => {
const model: ModelInfo = {
contextWindow: 200_000,
supportsPromptCache: true,
supportsReasoningEffort: true,
}
const settings: ProviderSettings = {
enableReasoningEffort: false,
reasoningEffort: "medium",
}
expect(shouldUseReasoningEffort({ model, settings })).toBe(false)
})
test("should return false when enableReasoningEffort is false, even if model has reasoningEffort property", () => {
const model: ModelInfo = {
contextWindow: 200_000,
supportsPromptCache: true,
reasoningEffort: "medium",
}
const settings: ProviderSettings = {
enableReasoningEffort: false,
}
expect(shouldUseReasoningEffort({ model, settings })).toBe(false)
})
test("should return true when model supports reasoning effort and settings provide reasoning effort", () => {
const model: ModelInfo = {
contextWindow: 200_000,

View file

@ -63,7 +63,17 @@ export const shouldUseReasoningEffort = ({
}: {
model: ModelInfo
settings?: ProviderSettings
}): boolean => (!!model.supportsReasoningEffort && !!settings?.reasoningEffort) || !!model.reasoningEffort
}): boolean => {
// If enableReasoningEffort is explicitly set to false, reasoning should be disabled
if (settings?.enableReasoningEffort === false) {
return false
}
// Otherwise, use reasoning if:
// 1. Model supports reasoning effort AND settings provide reasoning effort, OR
// 2. Model itself has a reasoningEffort property
return (!!model.supportsReasoningEffort && !!settings?.reasoningEffort) || !!model.reasoningEffort
}
export const DEFAULT_HYBRID_REASONING_MODEL_MAX_TOKENS = 16_384
export const DEFAULT_HYBRID_REASONING_MODEL_THINKING_TOKENS = 8_192