@@ -22,6 +22,7 @@ import type { Options, CanUseTool } from '@anthropic-ai/claude-agent-sdk/sdk';
2222import type {
2323 Session ,
2424 ThinkingLevel ,
25+ ThinkingConfig ,
2526 SystemPromptConfig ,
2627 ClaudeCodePreset ,
2728 AgentDefinition ,
@@ -244,12 +245,27 @@ export class QueryOptionsBuilder {
244245 return cleanedOptions ;
245246 }
246247
248+ /**
249+ * Convert ThinkingLevel enum to new thinking option
250+ * Maps the UI-friendly enum to SDK's new thinking API
251+ */
252+ private thinkingLevelToThinkingConfig ( level : ThinkingLevel ) : ThinkingConfig {
253+ const tokens = THINKING_LEVEL_TOKENS [ level ] ;
254+
255+ if ( tokens === undefined ) {
256+ // 'auto' mode
257+ return { type : 'adaptive' } ;
258+ }
259+
260+ return { type : 'enabled' , budgetTokens : tokens } ;
261+ }
262+
247263 /**
248264 * Add resume and thinking tokens to options
249265 * Called separately since these depend on session state at query time
250266 */
251267 addSessionStateOptions ( options : Options ) : Options {
252- const result = { ...options } ;
268+ const result = { ...options } as Options & { thinking ?: ThinkingConfig } ;
253269
254270 // Add resume parameter if SDK session ID exists (session resumption)
255271 if ( this . ctx . session . sdkSessionId ) {
@@ -262,14 +278,11 @@ export class QueryOptionsBuilder {
262278 result . resumeSessionAt = this . ctx . session . metadata . resumeSessionAt ;
263279 }
264280
265- // Add thinking token budget based on thinkingLevel config
281+ // Add thinking configuration based on thinkingLevel config
266282 const thinkingLevel = ( this . ctx . session . config . thinkingLevel || 'auto' ) as ThinkingLevel ;
267- const maxThinkingTokens = THINKING_LEVEL_TOKENS [ thinkingLevel ] ;
268- if ( maxThinkingTokens !== undefined ) {
269- result . maxThinkingTokens = maxThinkingTokens ;
270- }
283+ result . thinking = this . thinkingLevelToThinkingConfig ( thinkingLevel ) ;
271284
272- return result ;
285+ return result as Options ;
273286 }
274287
275288 /**
0 commit comments