@@ -282,6 +282,66 @@ describe("AwsBedrockHandler - Extended Thinking", () => {
282282 expect ( reasoningChunks [ 1 ] . text ) . toBe ( " about this problem." )
283283 } )
284284
285+ it ( "should use adaptive thinking for Opus 4.7 instead of enabled with budget_tokens" , async ( ) => {
286+ handler = new AwsBedrockHandler ( {
287+ apiProvider : "bedrock" ,
288+ apiModelId : "anthropic.claude-opus-4-7" ,
289+ awsRegion : "us-east-1" ,
290+ enableReasoningEffort : true ,
291+ modelMaxTokens : 8192 ,
292+ modelMaxThinkingTokens : 4096 ,
293+ } )
294+
295+ mockSend . mockResolvedValue ( {
296+ stream : ( async function * ( ) {
297+ yield { messageStart : { role : "assistant" } }
298+ yield {
299+ contentBlockStart : {
300+ content_block : { type : "thinking" , thinking : "Adaptive thinking..." } ,
301+ contentBlockIndex : 0 ,
302+ } ,
303+ }
304+ yield {
305+ contentBlockDelta : {
306+ delta : { type : "thinking_delta" , thinking : " reasoning complete." } ,
307+ } ,
308+ }
309+ yield {
310+ contentBlockStart : {
311+ start : { text : "Here is the answer." } ,
312+ contentBlockIndex : 1 ,
313+ } ,
314+ }
315+ yield { metadata : { usage : { inputTokens : 100 , outputTokens : 50 } } }
316+ } ) ( ) ,
317+ } )
318+
319+ const messages = [ { role : "user" as const , content : "Test message" } ]
320+ const stream = handler . createMessage ( "System prompt" , messages )
321+
322+ const chunks = [ ]
323+ for await ( const chunk of stream ) {
324+ chunks . push ( chunk )
325+ }
326+
327+ // Verify Opus 4.7 uses adaptive thinking (not enabled with budget_tokens)
328+ expect ( mockSend ) . toHaveBeenCalledTimes ( 1 )
329+ expect ( capturedPayload ) . toBeDefined ( )
330+ expect ( capturedPayload . additionalModelRequestFields ) . toBeDefined ( )
331+ expect ( capturedPayload . additionalModelRequestFields . thinking ) . toEqual ( {
332+ type : "adaptive" ,
333+ } )
334+ expect ( capturedPayload . additionalModelRequestFields . output_config ) . toEqual ( {
335+ effort : "high" ,
336+ } )
337+
338+ // Verify reasoning chunks were yielded
339+ const reasoningChunks = chunks . filter ( ( c ) => c . type === "reasoning" )
340+ expect ( reasoningChunks ) . toHaveLength ( 2 )
341+ expect ( ( reasoningChunks [ 0 ] as any ) . text ) . toBe ( "Adaptive thinking..." )
342+ expect ( ( reasoningChunks [ 1 ] as any ) . text ) . toBe ( " reasoning complete." )
343+ } )
344+
285345 it ( "should support API key authentication" , async ( ) => {
286346 handler = new AwsBedrockHandler ( {
287347 apiProvider : "bedrock" ,
0 commit comments