@@ -249,9 +249,14 @@ Deno.test("openai: normalize function-style tools for codex compatibility", asyn
249249 name : "legacy_tool" ,
250250 description : "Already top-level tool name." ,
251251 parameters : { type : "object" , properties : { } } ,
252+ function : { strict : true } ,
252253 } ,
253254 ] ,
254- tool_choice : { type : "function" , function : { name : "fetch_weather" } } ,
255+ tool_choice : {
256+ type : "function" ,
257+ name : "forced_choice" ,
258+ function : { name : "fetch_weather" , strict : true } ,
259+ } ,
255260 } ) ,
256261 } ) ,
257262 ) ,
@@ -265,11 +270,19 @@ Deno.test("openai: normalize function-style tools for codex compatibility", asyn
265270 assert . equal ( recordedTools . length , 2 ) ;
266271 assert . equal ( recordedTools [ 0 ] ?. name , "fetch_weather" ) ;
267272 assert . equal ( recordedTools [ 1 ] ?. name , "legacy_tool" ) ;
273+ assert . equal ( recordedTools [ 0 ] ?. description , "Fetch weather for a city." ) ;
274+ assert . deepEqual ( recordedTools [ 0 ] ?. parameters , {
275+ type : "object" ,
276+ properties : { city : { type : "string" } } ,
277+ } ) ;
278+ assert . equal ( recordedTools [ 1 ] ?. strict , true ) ;
268279 assert . equal ( Object . prototype . hasOwnProperty . call ( recordedTools [ 0 ] , "function" ) , false ) ;
280+ assert . equal ( Object . prototype . hasOwnProperty . call ( recordedTools [ 1 ] , "function" ) , false ) ;
269281 const recordedToolChoice = recorded [ "tool_choice" ] as Record < string , unknown > | undefined ;
270282 assert . ok ( recordedToolChoice ) ;
271283 assert . equal ( recordedToolChoice . type , "function" ) ;
272- assert . equal ( recordedToolChoice [ "name" ] , "fetch_weather" ) ;
284+ assert . equal ( recordedToolChoice [ "name" ] , "forced_choice" ) ;
285+ assert . equal ( Object . prototype . hasOwnProperty . call ( recordedToolChoice , "strict" ) , false ) ;
273286 assert . equal ( Object . prototype . hasOwnProperty . call ( recordedToolChoice , "function" ) , false ) ;
274287 } ) ;
275288
@@ -310,6 +323,8 @@ Deno.test("openai: normalize function-style tools for codex compatibility", asyn
310323 assert . ok ( Array . isArray ( recordedTools ) ) ;
311324 assert . equal ( recordedTools . length , 1 ) ;
312325 assert . equal ( recordedTools [ 0 ] ?. name , "fetch_weather" ) ;
326+ assert . equal ( recordedTools [ 0 ] ?. description , "Fetch weather for a city." ) ;
327+ assert . deepEqual ( recordedTools [ 0 ] ?. parameters , { type : "object" , properties : { city : { type : "string" } } } ) ;
313328 assert . equal ( Object . prototype . hasOwnProperty . call ( recordedTools [ 0 ] , "function" ) , false ) ;
314329 } ) ;
315330} ) ;
0 commit comments