Skip to content

Commit 5f692ac

Browse files
committed
🤖 fix: enable visible reasoning for Opus 4.5 by adding thinking parameter
Opus 4.5 requires both parameters to show reasoning traces in the UI: - thinking: { type: 'enabled', budgetTokens } - enables visible reasoning - effort: controls how tokens are spent across all output Previously we only passed effort, which controls token spend but doesn't enable the reasoning traces to be returned from the API. _Generated with mux_ Change-Id: I3aa6492d8028fd6ddebaac2123cedd07ae32d4f9 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent f8e7690 commit 5f692ac

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

‎src/common/utils/ai/providerOptions.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,33 @@ void mock.module("@/browser/utils/thinking/policy", () => ({
2323

2424
describe("buildProviderOptions - Anthropic", () => {
2525
describe("Opus 4.5 (effort parameter)", () => {
26-
test("should use effort parameter for claude-opus-4-5", () => {
26+
test("should use effort and thinking parameters for claude-opus-4-5", () => {
2727
const result = buildProviderOptions("anthropic:claude-opus-4-5", "medium");
2828

2929
expect(result).toEqual({
3030
anthropic: {
3131
disableParallelToolUse: false,
3232
sendReasoning: true,
33+
thinking: {
34+
type: "enabled",
35+
budgetTokens: 10000, // ANTHROPIC_THINKING_BUDGETS.medium
36+
},
3337
effort: "medium",
3438
},
3539
});
3640
});
3741

38-
test("should use effort parameter for claude-opus-4-5-20251101", () => {
42+
test("should use effort and thinking parameters for claude-opus-4-5-20251101", () => {
3943
const result = buildProviderOptions("anthropic:claude-opus-4-5-20251101", "high");
4044

4145
expect(result).toEqual({
4246
anthropic: {
4347
disableParallelToolUse: false,
4448
sendReasoning: true,
49+
thinking: {
50+
type: "enabled",
51+
budgetTokens: 20000, // ANTHROPIC_THINKING_BUDGETS.high
52+
},
4553
effort: "high",
4654
},
4755
});

‎src/common/utils/ai/providerOptions.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,29 @@ export function buildProviderOptions(
9393
const isOpus45 = modelName?.includes("opus-4-5") ?? false;
9494

9595
if (isOpus45) {
96-
// Opus 4.5: Use effort parameter for reasoning control
96+
// Opus 4.5: Use effort parameter AND thinking to enable visible reasoning
97+
// effort controls HOW MUCH thinking happens (token spend)
98+
// thinking enables the reasoning traces to be returned
9799
const effort = ANTHROPIC_EFFORT[effectiveThinking];
100+
const budgetTokens = ANTHROPIC_THINKING_BUDGETS[effectiveThinking];
98101
log.debug("buildProviderOptions: Anthropic Opus 4.5 config", {
99102
effort,
103+
budgetTokens,
100104
thinkingLevel: effectiveThinking,
101105
});
102106

103107
const options: ProviderOptions = {
104108
anthropic: {
105109
disableParallelToolUse: false, // Always enable concurrent tool execution
106110
sendReasoning: true, // Include reasoning traces in requests sent to the model
111+
// Enable thinking to get visible reasoning traces
112+
// budgetTokens sets the ceiling; effort controls how eagerly tokens are spent
113+
...(budgetTokens > 0 && {
114+
thinking: {
115+
type: "enabled",
116+
budgetTokens,
117+
},
118+
}),
107119
// Use effort parameter (Opus 4.5 only) to control token spend
108120
// SDK auto-adds beta header "effort-2025-11-24" when effort is set
109121
...(effort && { effort }),

0 commit comments

Comments
 (0)