@@ -74,6 +74,36 @@ describe('OpenAIResponsesModel', () => {
7474 } ) ;
7575 } ) ;
7676
77+ it ( 'still sends an empty tools array when no prompt is provided' , async ( ) => {
78+ await withTrace ( 'test' , async ( ) => {
79+ const fakeResponse = { id : 'res-no-prompt' , usage : { } , output : [ ] } ;
80+ const createMock = vi . fn ( ) . mockResolvedValue ( fakeResponse ) ;
81+ const fakeClient = {
82+ responses : { create : createMock } ,
83+ } as unknown as OpenAI ;
84+ const model = new OpenAIResponsesModel ( fakeClient , 'gpt-default' ) ;
85+
86+ const request = {
87+ systemInstructions : undefined ,
88+ input : 'hello' ,
89+ modelSettings : { } ,
90+ tools : [ ] ,
91+ toolsExplicitlyProvided : false ,
92+ outputType : 'text' ,
93+ handoffs : [ ] ,
94+ tracing : false ,
95+ signal : undefined ,
96+ } ;
97+
98+ await model . getResponse ( request as any ) ;
99+
100+ expect ( createMock ) . toHaveBeenCalledTimes ( 1 ) ;
101+ const [ args ] = createMock . mock . calls [ 0 ] ;
102+ expect ( args . tools ) . toEqual ( [ ] ) ;
103+ expect ( args . prompt ) . toBeUndefined ( ) ;
104+ } ) ;
105+ } ) ;
106+
77107 it ( 'omits model when a prompt is provided' , async ( ) => {
78108 await withTrace ( 'test' , async ( ) => {
79109 const fakeResponse = { id : 'res-prompt' , usage : { } , output : [ ] } ;
@@ -135,6 +165,68 @@ describe('OpenAIResponsesModel', () => {
135165 } ) ;
136166 } ) ;
137167
168+ it ( 'omits tools when agent did not configure any and prompt should supply them' , async ( ) => {
169+ await withTrace ( 'test' , async ( ) => {
170+ const fakeResponse = { id : 'res-no-tools' , usage : { } , output : [ ] } ;
171+ const createMock = vi . fn ( ) . mockResolvedValue ( fakeResponse ) ;
172+ const fakeClient = {
173+ responses : { create : createMock } ,
174+ } as unknown as OpenAI ;
175+ const model = new OpenAIResponsesModel ( fakeClient , 'gpt-default' ) ;
176+
177+ const request = {
178+ systemInstructions : undefined ,
179+ prompt : { promptId : 'pmpt_789' } ,
180+ input : 'hello' ,
181+ modelSettings : { } ,
182+ tools : [ ] ,
183+ toolsExplicitlyProvided : false ,
184+ outputType : 'text' ,
185+ handoffs : [ ] ,
186+ tracing : false ,
187+ signal : undefined ,
188+ } ;
189+
190+ await model . getResponse ( request as any ) ;
191+
192+ expect ( createMock ) . toHaveBeenCalledTimes ( 1 ) ;
193+ const [ args ] = createMock . mock . calls [ 0 ] ;
194+ expect ( 'tools' in args ) . toBe ( false ) ;
195+ expect ( args . prompt ) . toMatchObject ( { id : 'pmpt_789' } ) ;
196+ } ) ;
197+ } ) ;
198+
199+ it ( 'sends an explicit empty tools array when the agent intentionally disabled tools' , async ( ) => {
200+ await withTrace ( 'test' , async ( ) => {
201+ const fakeResponse = { id : 'res-empty-tools' , usage : { } , output : [ ] } ;
202+ const createMock = vi . fn ( ) . mockResolvedValue ( fakeResponse ) ;
203+ const fakeClient = {
204+ responses : { create : createMock } ,
205+ } as unknown as OpenAI ;
206+ const model = new OpenAIResponsesModel ( fakeClient , 'gpt-default' ) ;
207+
208+ const request = {
209+ systemInstructions : undefined ,
210+ prompt : { promptId : 'pmpt_999' } ,
211+ input : 'hello' ,
212+ modelSettings : { } ,
213+ tools : [ ] ,
214+ toolsExplicitlyProvided : true ,
215+ outputType : 'text' ,
216+ handoffs : [ ] ,
217+ tracing : false ,
218+ signal : undefined ,
219+ } ;
220+
221+ await model . getResponse ( request as any ) ;
222+
223+ expect ( createMock ) . toHaveBeenCalledTimes ( 1 ) ;
224+ const [ args ] = createMock . mock . calls [ 0 ] ;
225+ expect ( args . tools ) . toEqual ( [ ] ) ;
226+ expect ( args . prompt ) . toMatchObject ( { id : 'pmpt_999' } ) ;
227+ } ) ;
228+ } ) ;
229+
138230 it ( 'normalizes systemInstructions so empty strings are omitted' , async ( ) => {
139231 await withTrace ( 'test' , async ( ) => {
140232 const fakeResponse = {
0 commit comments