@@ -22,14 +22,24 @@ class TestProvider extends BaseProvider {
2222 }
2323 }
2424
25- // Expose protected method for testing
25+ // Expose protected method for testing (schema rewrite used when enableStrict: true)
2626 public testConvertToolSchemaForOpenAI ( schema : any ) : any {
27- return this . convertToolsForOpenAI ( schema )
27+ return this . convertToolSchemaForOpenAI ( schema )
2828 }
2929
3030 // Expose protected method for testing
31- public testConvertToolsForOpenAI ( tools : any [ ] | undefined ) : any [ ] | undefined {
32- return this . convertToolsForOpenAI ( tools )
31+ public testConvertToolsForOpenAI (
32+ tools : any [ ] | undefined ,
33+ options ?: { enableStrict ?: boolean } ,
34+ ) : any [ ] | undefined {
35+ return this . convertToolsForOpenAI ( tools , options )
36+ }
37+
38+ public convertToolsForOpenAIPublic (
39+ tools : any [ ] | undefined ,
40+ options ?: { enableStrict ?: boolean } ,
41+ ) : any [ ] | undefined {
42+ return this . convertToolsForOpenAI ( tools , options )
3343 }
3444
3545 // Expose private method for testing via any cast (private methods cannot be overridden)
@@ -166,21 +176,56 @@ describe("BaseProvider", () => {
166176 expect ( result ) . toBeUndefined ( )
167177 } )
168178
169- it ( "should set strict: true for non-MCP tools" , ( ) => {
179+ it ( "defaults to strict: false for non-MCP tools (third-party gateway safe) " , ( ) => {
170180 const tools = [
171181 {
172182 type : "function" ,
173183 function : {
174184 name : "read_file" ,
175185 description : "Read a file" ,
176- parameters : { type : "object" , properties : { } } ,
186+ parameters : {
187+ type : "object" ,
188+ properties : {
189+ path : { type : "string" } ,
190+ limit : { type : "number" } ,
191+ } ,
192+ required : [ "path" ] ,
193+ } ,
177194 } ,
178195 } ,
179196 ]
180197
181198 const result = provider . testConvertToolsForOpenAI ( tools )
182199
200+ expect ( result ?. [ 0 ] . function . strict ) . toBe ( false )
201+ // Optional params must stay optional (not rewritten to required: all keys)
202+ expect ( result ?. [ 0 ] . function . parameters . required ) . toEqual ( [ "path" ] )
203+ } )
204+
205+ it ( "should set strict: true when enableStrict is true" , ( ) => {
206+ const tools = [
207+ {
208+ type : "function" ,
209+ function : {
210+ name : "read_file" ,
211+ description : "Read a file" ,
212+ parameters : {
213+ type : "object" ,
214+ properties : {
215+ path : { type : "string" } ,
216+ limit : { type : "number" } ,
217+ } ,
218+ required : [ "path" ] ,
219+ } ,
220+ } ,
221+ } ,
222+ ]
223+
224+ const result = provider . convertToolsForOpenAIPublic ( tools , { enableStrict : true } )
225+
183226 expect ( result ?. [ 0 ] . function . strict ) . toBe ( true )
227+ expect ( result ?. [ 0 ] . function . parameters . required ) . toEqual ( [ "path" , "limit" ] )
228+ expect ( result ?. [ 0 ] . function . parameters . additionalProperties ) . toBe ( false )
184229 } )
185230
186231 it ( "should set strict: false for MCP tools (mcp-- prefix)" , ( ) => {
0 commit comments