@@ -6,6 +6,7 @@ import { describe, expect, it } from 'vitest'
66import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
77import {
88 buildResponsesInputFromMessages ,
9+ convertToolsToResponses ,
910 parseResponsesUsage ,
1011 toOpenAIModelUsage ,
1112} from '@/providers/openai/utils'
@@ -155,3 +156,28 @@ describe('buildResponsesInputFromMessages', () => {
155156 ] )
156157 } )
157158} )
159+
160+ describe ( 'convertToolsToResponses' , ( ) => {
161+ it . each ( [ 'wrapped' , 'flat' ] as const ) (
162+ 'preserves optional inputs on %s tool definitions without implicit strict normalization' ,
163+ ( shape ) => {
164+ const parameters = {
165+ type : 'object' ,
166+ properties : {
167+ fileId : { type : 'string' } ,
168+ folderPaths : { type : 'array' , items : { type : 'string' } } ,
169+ offset : { type : 'number' } ,
170+ } ,
171+ required : [ 'fileId' ] ,
172+ }
173+ const tool = { name : 'file_get_content' , description : 'Read selected file text' , parameters }
174+ const converted = convertToolsToResponses ( [
175+ shape === 'wrapped' ? { type : 'function' , function : tool } : tool ,
176+ ] )
177+
178+ expect ( converted ) . toEqual ( [ { type : 'function' , strict : false , ...tool } ] )
179+ expect ( converted [ 0 ] . parameters ) . toBe ( parameters )
180+ expect ( parameters . required ) . toEqual ( [ 'fileId' ] )
181+ }
182+ )
183+ } )
0 commit comments