@@ -8,7 +8,7 @@ describe('toolsToModelTools', () => {
88 const tools = {
99 weather : tool ( {
1010 description : 'Get the weather' ,
11- parameters : z . object ( { city : z . string ( ) } ) ,
11+ inputSchema : z . object ( { city : z . string ( ) } ) ,
1212 execute : async ( { city } ) => `Weather in ${ city } : sunny` ,
1313 } ) ,
1414 } ;
@@ -61,7 +61,7 @@ describe('toolsToModelTools', () => {
6161 const tools = {
6262 weather : tool ( {
6363 description : 'Get the weather' ,
64- parameters : z . object ( { city : z . string ( ) } ) ,
64+ inputSchema : z . object ( { city : z . string ( ) } ) ,
6565 execute : async ( { city } ) => `Weather in ${ city } : sunny` ,
6666 } ) ,
6767 webSearch : providerTool ,
@@ -103,4 +103,119 @@ describe('toolsToModelTools', () => {
103103 args : { } ,
104104 } ) ;
105105 } ) ;
106+
107+ it ( 'forwards strict: true' , async ( ) => {
108+ const tools = {
109+ weather : tool ( {
110+ description : 'Get weather' ,
111+ inputSchema : z . object ( { location : z . string ( ) } ) ,
112+ execute : async ( ) => 'sunny' ,
113+ strict : true ,
114+ } ) ,
115+ } ;
116+
117+ const result = await toolsToModelTools ( tools ) ;
118+
119+ expect ( result [ 0 ] ) . toMatchObject ( { strict : true } ) ;
120+ } ) ;
121+
122+ it ( 'forwards strict: false' , async ( ) => {
123+ const tools = {
124+ weather : tool ( {
125+ description : 'Get weather' ,
126+ inputSchema : z . object ( { location : z . string ( ) } ) ,
127+ execute : async ( ) => 'sunny' ,
128+ strict : false ,
129+ } ) ,
130+ } ;
131+
132+ const result = await toolsToModelTools ( tools ) ;
133+
134+ expect ( result [ 0 ] ) . toMatchObject ( { strict : false } ) ;
135+ } ) ;
136+
137+ it ( 'omits strict key when not set' , async ( ) => {
138+ const tools = {
139+ weather : tool ( {
140+ description : 'Get weather' ,
141+ inputSchema : z . object ( { location : z . string ( ) } ) ,
142+ execute : async ( ) => 'sunny' ,
143+ } ) ,
144+ } ;
145+
146+ const result = await toolsToModelTools ( tools ) ;
147+
148+ expect ( result [ 0 ] ) . not . toHaveProperty ( 'strict' ) ;
149+ } ) ;
150+
151+ it ( 'forwards inputExamples' , async ( ) => {
152+ const examples = [ { input : { location : 'Tokyo' } } ] ;
153+ const tools = {
154+ weather : tool ( {
155+ description : 'Get weather' ,
156+ inputSchema : z . object ( { location : z . string ( ) } ) ,
157+ execute : async ( ) => 'sunny' ,
158+ inputExamples : examples ,
159+ } ) ,
160+ } ;
161+
162+ const result = await toolsToModelTools ( tools ) ;
163+
164+ expect ( result [ 0 ] ) . toMatchObject ( { inputExamples : examples } ) ;
165+ } ) ;
166+
167+ it ( 'omits inputExamples key when not set' , async ( ) => {
168+ const tools = {
169+ weather : tool ( {
170+ description : 'Get weather' ,
171+ inputSchema : z . object ( { location : z . string ( ) } ) ,
172+ execute : async ( ) => 'sunny' ,
173+ } ) ,
174+ } ;
175+
176+ const result = await toolsToModelTools ( tools ) ;
177+
178+ expect ( result [ 0 ] ) . not . toHaveProperty ( 'inputExamples' ) ;
179+ } ) ;
180+
181+ it ( 'forwards providerOptions' , async ( ) => {
182+ const providerOptions = { openai : { parallel_tool_calls : false } } ;
183+ const tools = {
184+ weather : tool ( {
185+ description : 'Get weather' ,
186+ inputSchema : z . object ( { location : z . string ( ) } ) ,
187+ execute : async ( ) => 'sunny' ,
188+ providerOptions,
189+ } ) ,
190+ } ;
191+
192+ const result = await toolsToModelTools ( tools ) ;
193+
194+ expect ( result [ 0 ] ) . toMatchObject ( { providerOptions } ) ;
195+ } ) ;
196+
197+ it ( 'handles tools with type: "dynamic" as function tools' , async ( ) => {
198+ const tools = {
199+ dynamic : {
200+ type : 'dynamic' as const ,
201+ description : 'A dynamic tool' ,
202+ inputSchema : z . object ( { input : z . string ( ) } ) ,
203+ execute : async ( ) => 'result' ,
204+ } ,
205+ } ;
206+
207+ const result = await toolsToModelTools ( tools as any ) ;
208+
209+ expect ( result ) . toHaveLength ( 1 ) ;
210+ expect ( result [ 0 ] ) . toMatchObject ( {
211+ type : 'function' ,
212+ name : 'dynamic' ,
213+ description : 'A dynamic tool' ,
214+ } ) ;
215+ } ) ;
216+
217+ it ( 'returns empty array for empty tools' , async ( ) => {
218+ const result = await toolsToModelTools ( { } ) ;
219+ expect ( result ) . toEqual ( [ ] ) ;
220+ } ) ;
106221} ) ;
0 commit comments