Skip to content

Commit 87c42c1

Browse files
roomote[bot]mrubensroomote-agentdaniel-lxs
authored
fix: respect enableReasoningEffort setting when determining reasoning usage (#7049)
Co-authored-by: Matt Rubens <[email protected]> Co-authored-by: Roo Code <[email protected]> Co-authored-by: Daniel <[email protected]>
1 parent b975ced commit 87c42c1

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/shared/__tests__/api.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,41 @@ describe("shouldUseReasoningEffort", () => {
375375
reasoningEffort: "medium",
376376
}
377377

378-
// Should return true regardless of settings
378+
// Should return true regardless of settings (unless explicitly disabled)
379379
expect(shouldUseReasoningEffort({ model })).toBe(true)
380380
expect(shouldUseReasoningEffort({ model, settings: {} })).toBe(true)
381381
expect(shouldUseReasoningEffort({ model, settings: { reasoningEffort: undefined } })).toBe(true)
382382
})
383383

384+
test("should return false when enableReasoningEffort is false, even if reasoningEffort is set", () => {
385+
const model: ModelInfo = {
386+
contextWindow: 200_000,
387+
supportsPromptCache: true,
388+
supportsReasoningEffort: true,
389+
}
390+
391+
const settings: ProviderSettings = {
392+
enableReasoningEffort: false,
393+
reasoningEffort: "medium",
394+
}
395+
396+
expect(shouldUseReasoningEffort({ model, settings })).toBe(false)
397+
})
398+
399+
test("should return false when enableReasoningEffort is false, even if model has reasoningEffort property", () => {
400+
const model: ModelInfo = {
401+
contextWindow: 200_000,
402+
supportsPromptCache: true,
403+
reasoningEffort: "medium",
404+
}
405+
406+
const settings: ProviderSettings = {
407+
enableReasoningEffort: false,
408+
}
409+
410+
expect(shouldUseReasoningEffort({ model, settings })).toBe(false)
411+
})
412+
384413
test("should return true when model supports reasoning effort and settings provide reasoning effort", () => {
385414
const model: ModelInfo = {
386415
contextWindow: 200_000,

src/shared/api.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ export const shouldUseReasoningEffort = ({
6363
}: {
6464
model: ModelInfo
6565
settings?: ProviderSettings
66-
}): boolean => (!!model.supportsReasoningEffort && !!settings?.reasoningEffort) || !!model.reasoningEffort
66+
}): boolean => {
67+
// If enableReasoningEffort is explicitly set to false, reasoning should be disabled
68+
if (settings?.enableReasoningEffort === false) {
69+
return false
70+
}
71+
72+
// Otherwise, use reasoning if:
73+
// 1. Model supports reasoning effort AND settings provide reasoning effort, OR
74+
// 2. Model itself has a reasoningEffort property
75+
return (!!model.supportsReasoningEffort && !!settings?.reasoningEffort) || !!model.reasoningEffort
76+
}
6777

6878
export const DEFAULT_HYBRID_REASONING_MODEL_MAX_TOKENS = 16_384
6979
export const DEFAULT_HYBRID_REASONING_MODEL_THINKING_TOKENS = 8_192

0 commit comments

Comments
 (0)