@@ -316,6 +316,46 @@ describe("Bedrock Fable contract", () => {
316316 } ) ;
317317 } ) ;
318318
319+ it ( "uses model maxTokens for Fable requests through simple options" , async ( ) => {
320+ const send = vi . spyOn ( BedrockRuntimeClient . prototype , "send" ) . mockResolvedValue ( {
321+ $metadata : { httpStatusCode : 200 } ,
322+ stream : streamEvents ( [
323+ { messageStart : { role : ConversationRole . ASSISTANT } } ,
324+ { messageStop : { stopReason : "end_turn" } } ,
325+ ] ) ,
326+ } as never ) ;
327+
328+ const stream = streamSimpleBedrock ( fableModel ( ) , context ( ) ) ;
329+ await stream . result ( ) ;
330+
331+ const command = send . mock . calls [ 0 ] ?. [ 0 ] as { input ?: Record < string , unknown > } ;
332+ expect ( command . input ) . toMatchObject ( {
333+ inferenceConfig : { maxTokens : 128_000 } ,
334+ additionalModelRequestFields : {
335+ thinking : { type : "adaptive" , display : "summarized" } ,
336+ output_config : { effort : "high" } ,
337+ } ,
338+ } ) ;
339+ } ) ;
340+
341+ it ( "preserves explicit caller maxTokens for Fable simple options" , async ( ) => {
342+ const send = vi . spyOn ( BedrockRuntimeClient . prototype , "send" ) . mockResolvedValue ( {
343+ $metadata : { httpStatusCode : 200 } ,
344+ stream : streamEvents ( [
345+ { messageStart : { role : ConversationRole . ASSISTANT } } ,
346+ { messageStop : { stopReason : "end_turn" } } ,
347+ ] ) ,
348+ } as never ) ;
349+
350+ const stream = streamSimpleBedrock ( fableModel ( ) , context ( ) , {
351+ maxTokens : 12_000 ,
352+ } ) ;
353+ await stream . result ( ) ;
354+
355+ const command = send . mock . calls [ 0 ] ?. [ 0 ] as { input ?: Record < string , unknown > } ;
356+ expect ( command . input ?. inferenceConfig ) . toEqual ( { maxTokens : 12_000 } ) ;
357+ } ) ;
358+
319359 it ( "preserves explicit tool disabling" , async ( ) => {
320360 const send = vi . spyOn ( BedrockRuntimeClient . prototype , "send" ) . mockResolvedValue ( {
321361 $metadata : { httpStatusCode : 200 } ,
@@ -477,6 +517,7 @@ describe("Bedrock canonical Claude aliases", () => {
477517 name : "Production Claude" ,
478518 reasoning : false ,
479519 params : { canonicalModelId } ,
520+ maxTokens : 128_000 ,
480521 thinkingLevelMap,
481522 } ) ;
482523
@@ -492,12 +533,48 @@ describe("Bedrock canonical Claude aliases", () => {
492533 const command = send . mock . calls [ 0 ] ?. [ 0 ] as { input ?: Record < string , unknown > } ;
493534 expect ( command . input ) . toMatchObject ( {
494535 modelId : "production-claude" ,
495- inferenceConfig : { } ,
536+ inferenceConfig : { maxTokens : 128_000 } ,
496537 additionalModelRequestFields : {
497538 thinking : { type : "adaptive" , display : "summarized" } ,
498539 output_config : { effort : expectedEffort } ,
499540 } ,
500541 } ) ;
501542 } ,
502543 ) ;
544+
545+ it ( "preserves explicit caller maxTokens for adaptive Claude aliases" , async ( ) => {
546+ const send = vi . spyOn ( BedrockRuntimeClient . prototype , "send" ) . mockResolvedValue ( {
547+ $metadata : { httpStatusCode : 200 } ,
548+ stream : streamEvents ( [
549+ { messageStart : { role : ConversationRole . ASSISTANT } } ,
550+ { messageStop : { stopReason : "end_turn" } } ,
551+ ] ) ,
552+ } as never ) ;
553+ const model = bedrockModel ( {
554+ id : "production-claude" ,
555+ name : "Production Claude" ,
556+ reasoning : false ,
557+ params : { canonicalModelId : "claude-opus-4-8" } ,
558+ maxTokens : 128_000 ,
559+ thinkingLevelMap : { xhigh : "xhigh" , max : "max" } ,
560+ } ) ;
561+
562+ await streamSimpleBedrock (
563+ model ,
564+ { messages : [ { role : "user" , content : "Reply briefly." , timestamp : 0 } ] } as never ,
565+ {
566+ reasoning : "xhigh" ,
567+ maxTokens : 12_000 ,
568+ } ,
569+ ) . result ( ) ;
570+
571+ const command = send . mock . calls [ 0 ] ?. [ 0 ] as { input ?: Record < string , unknown > } ;
572+ expect ( command . input ) . toMatchObject ( {
573+ inferenceConfig : { maxTokens : 12_000 } ,
574+ additionalModelRequestFields : {
575+ thinking : { type : "adaptive" , display : "summarized" } ,
576+ output_config : { effort : "xhigh" } ,
577+ } ,
578+ } ) ;
579+ } ) ;
503580} ) ;
0 commit comments