@@ -6647,7 +6647,7 @@ Update and merge these partial structured summaries.`,
66476647 const toolUseBlock = body . content . find ( ( block ) => block . type === "tool_use" ) as
66486648 | { id : string ; name : string ; input : Record < string , unknown > }
66496649 | undefined ;
6650- expect ( toolUseBlock ?. id ) . toMatch ( / ^ t o o l u _ [ A - Z a - z 0 - 9 _ ] + $ / ) ;
6650+ expect ( toolUseBlock ?. id ) . toMatch ( / ^ t o o l u [ a - f 0 - 9 ] { 35 } $ / ) ;
66516651 expect ( toolUseBlock ?. id . length ) . toBeLessThanOrEqual ( 64 ) ;
66526652 expect ( toolUseBlock ?. name ) . toBe ( "read" ) ;
66536653 expect ( toolUseBlock ?. input ) . toEqual ( { path : "repo/docs/help/testing.md" } ) ;
@@ -6665,6 +6665,7 @@ Update and merge these partial structured summaries.`,
66656665 it ( "preserves already-native Anthropic tool IDs while adapting shared generated IDs" , ( ) => {
66666666 const nativeId = "toolu_native_123" ;
66676667 const generatedId = "call_mock_read_generated_1" ;
6668+ const secondGeneratedId = "call_mock_read_generated_2" ;
66686669 const events : StreamEvent [ ] = [
66696670 {
66706671 type : "response.output_item.added" ,
@@ -6690,6 +6691,7 @@ Update and merge these partial structured summaries.`,
66906691 output : [
66916692 { type : "function_call" , name : "read" , call_id : nativeId , arguments : "{}" } ,
66926693 { type : "function_call" , name : "read" , call_id : generatedId , arguments : "{}" } ,
6694+ { type : "function_call" , name : "read" , call_id : secondGeneratedId , arguments : "{}" } ,
66936695 ] ,
66946696 usage : { input_tokens : 1 , output_tokens : 1 , total_tokens : 2 } ,
66956697 } ,
@@ -6730,9 +6732,13 @@ Update and merge these partial structured summaries.`,
67306732 } ) ;
67316733
67326734 expect ( callIds . filter ( ( id ) => id === nativeId ) ) . toHaveLength ( 3 ) ;
6733- expect ( new Set ( adaptedGeneratedIds ) . size ) . toBe ( 1 ) ;
6735+ expect ( adaptedGeneratedIds . slice ( 0 , 3 ) ) . toEqual (
6736+ Array . from ( { length : 3 } , ( ) => "toolu51ca7fb8ca8ab1910ae2815b4e69a38ac71" ) ,
6737+ ) ;
6738+ expect ( adaptedGeneratedIds [ 3 ] ) . toMatch ( / ^ t o o l u [ a - f 0 - 9 ] { 35 } $ / ) ;
6739+ expect ( adaptedGeneratedIds [ 3 ] ) . not . toBe ( adaptedGeneratedIds [ 0 ] ) ;
67346740 expect ( repeatedGeneratedIds ) . toEqual ( adaptedGeneratedIds ) ;
6735- expect ( adaptedGeneratedIds [ 0 ] ) . toMatch ( / ^ t o o l u _ [ A - Z a - z 0 - 9 _ ] + $ / ) ;
6741+ expect ( adaptedGeneratedIds [ 0 ] ) . toMatch ( / ^ t o o l u [ a - f 0 - 9 ] { 35 } $ / ) ;
67366742 expect ( adaptedGeneratedIds [ 0 ] ?. length ) . toBeLessThanOrEqual ( 64 ) ;
67376743 } ) ;
67386744
@@ -6790,7 +6796,7 @@ Update and merge these partial structured summaries.`,
67906796 if ( ! toolUse || typeof toolUse . id !== "string" || typeof toolUse . name !== "string" ) {
67916797 throw new Error ( "Expected Anthropic tool_use block" ) ;
67926798 }
6793- expect ( toolUse . id ) . toMatch ( / ^ t o o l u _ [ A - Z a - z 0 - 9 _ ] + $ / ) ;
6799+ expect ( toolUse . id ) . toMatch ( / ^ t o o l u [ a - f 0 - 9 ] { 35 } $ / ) ;
67946800 expect ( toolUse . id . length ) . toBeLessThanOrEqual ( 64 ) ;
67956801 emittedToolUseIds . push ( toolUse . id ) ;
67966802 return toolUse ;
@@ -7838,7 +7844,7 @@ Update and merge these partial structured summaries.`,
78387844 toolUseStart ?. content_block ,
78397845 "Anthropic SSE tool_use content block" ,
78407846 ) ;
7841- expect ( toolUse . id ) . toMatch ( / ^ t o o l u _ [ A - Z a - z 0 - 9 _ ] + $ / ) ;
7847+ expect ( toolUse . id ) . toMatch ( / ^ t o o l u [ a - f 0 - 9 ] { 35 } $ / ) ;
78427848 expect ( String ( toolUse . id ) . length ) . toBeLessThanOrEqual ( 64 ) ;
78437849 const debug = requireRecord ( await getJson ( server , "/debug/last-request" ) , "debug request" ) ;
78447850 expect ( debug . plannedToolCallId ) . toBe ( toolUse . id ) ;
0 commit comments