@@ -21,6 +21,7 @@ const REFUSAL_CODE = "undeclared_tool_call";
2121const userInput = { role : "user" , content : [ { type : "input_text" , text : "fixture request" } ] } ;
2222const tool = ( name : string ) => ( { type : "function" , name, parameters : { type : "object" , properties : { } } } ) ;
2323const additional = ( names : string [ ] ) => ( { type : "additional_tools" , role : "developer" , tools : names . map ( tool ) } ) ;
24+ const hostedToolSearch = { type : "additional_tools" , role : "developer" , tools : [ { type : "tool_search" } ] } ;
2425
2526let home : ReturnType < typeof createTempHome > ;
2627let releaseHome : ( ( ) => void ) | undefined ;
@@ -162,6 +163,29 @@ describe("explicit empty catalog current-turn and continuation boundaries", () =
162163 }
163164 }
164165
166+ for ( const lane of [ "adapter" , "runTurn" ] as const ) for ( const wire of [ undefined , "chat" ] as const ) {
167+ for ( const current of [ false , true ] ) {
168+ test ( `${ lane } , ${ wire ?? "responses" } : ${ current ? "current" : "replayed" } hosted tool_search ${ current ? "authorizes" : "cannot authorize" } its translated call` , async ( ) => {
169+ const config = setup ( lane ) ;
170+ const prior = await post ( config , wire , false , { input : [ hostedToolSearch , userInput ] } ) ;
171+ expect ( prior . status ) . toBe ( "completed" ) ;
172+ expect ( dispatched [ 0 ] ! . tools ) . toContain ( "tool_search" ) ;
173+ nextCall = "tool_search" ;
174+ const response = await post ( config , wire , false , {
175+ previous_response_id : prior . id , tools : [ ] , input : [ ...( current ? [ hostedToolSearch ] : [ ] ) , userInput ] ,
176+ } ) ;
177+ expect ( dispatched [ 1 ] ! . replayPrefix ) . toBeGreaterThan ( 0 ) ;
178+ expect ( dispatched [ 1 ] ! . tools ) . toContain ( "tool_search" ) ;
179+ if ( ! current ) assertRefusedAndUncached ( response ) ;
180+ else {
181+ expect ( response . status ) . toBe ( "completed" ) ;
182+ expect ( response . error ) . toBeUndefined ( ) ;
183+ expect ( JSON . stringify ( response . output ) ) . toContain ( "tool_search" ) ;
184+ }
185+ } ) ;
186+ }
187+ }
188+
165189 for ( const lane of [ "adapter" , "runTurn" ] as const ) for ( const wire of [ "chat" , "anthropic" ] as const ) {
166190 for ( const stream of [ false , true ] ) {
167191 const label = `${ lane } , ${ wire } , ${ stream ? "SSE" : "JSON" } ` ;
0 commit comments