@@ -43,10 +43,11 @@ public sealed class OpenAIResponseAgentTests(ITestOutputHelper output)
4343 [ InlineData ( "What is the capital of France?" , "Paris" , false , false ) ]
4444 public async Task OpenAIResponseAgentInvokeAsync ( string input , string expectedAnswerContains , bool isOpenAI , bool storeEnabled )
4545 {
46- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
46+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
4747
4848 await this . ExecuteAgentAsync (
4949 client ,
50+ modelId ,
5051 storeEnabled ,
5152 input ,
5253 expectedAnswerContains ) ;
@@ -63,8 +64,8 @@ await this.ExecuteAgentAsync(
6364 public async Task OpenAIResponseAgentInvokeWithThreadAsync ( string input , string expectedAnswerContains , bool isOpenAI , bool storeEnabled )
6465 {
6566 // Arrange
66- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
67- OpenAIResponseAgent agent = new ( client )
67+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
68+ OpenAIResponseAgent agent = new ( client , modelId )
6869 {
6970 StoreEnabled = storeEnabled ,
7071 Instructions = "Answer all queries in English and French."
@@ -112,9 +113,9 @@ public async Task OpenAIResponseAgentInvokeWithThreadAsync(string input, string
112113 public async Task OpenAIResponseAgentInvokeWithFunctionCallingAsync ( string input , string expectedAnswerContains , bool isOpenAI , bool storeEnabled )
113114 {
114115 // Arrange
115- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
116+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
116117 KernelPlugin plugin = KernelPluginFactory . CreateFromType < MenuPlugin > ( ) ;
117- OpenAIResponseAgent agent = new ( client )
118+ OpenAIResponseAgent agent = new ( client , modelId )
118119 {
119120 StoreEnabled = storeEnabled ,
120121 Instructions = "Answer questions about the menu."
@@ -161,10 +162,11 @@ public async Task OpenAIResponseAgentInvokeWithFunctionCallingAsync(string input
161162 [ InlineData ( "What is the capital of France?" , "Paris" , false , false ) ]
162163 public async Task OpenAIResponseAgentInvokeStreamingAsync ( string input , string expectedAnswerContains , bool isOpenAI , bool storeEnabled )
163164 {
164- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
165+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
165166
166167 await this . ExecuteStreamingAgentAsync (
167168 client ,
169+ modelId ,
168170 storeEnabled ,
169171 input ,
170172 expectedAnswerContains ) ;
@@ -181,8 +183,8 @@ await this.ExecuteStreamingAgentAsync(
181183 public async Task OpenAIResponseAgentInvokeStreamingWithThreadAsync ( bool isOpenAI , bool storeEnabled )
182184 {
183185 // Arrange
184- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
185- OpenAIResponseAgent agent = new ( client )
186+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
187+ OpenAIResponseAgent agent = new ( client , modelId )
186188 {
187189 StoreEnabled = storeEnabled ,
188190 Instructions = "Answer all queries in English and French."
@@ -229,9 +231,9 @@ public async Task OpenAIResponseAgentInvokeStreamingWithThreadAsync(bool isOpenA
229231 public async Task OpenAIResponseAgentInvokeStreamingWithFunctionCallingAsync ( string input , string expectedAnswerContains , bool isOpenAI , bool storeEnabled )
230232 {
231233 // Arrange
232- ResponsesClient client = this . CreateClient ( isOpenAI ) ;
234+ var ( client , modelId ) = this . CreateClient ( isOpenAI ) ;
233235 KernelPlugin plugin = KernelPluginFactory . CreateFromType < MenuPlugin > ( ) ;
234- OpenAIResponseAgent agent = new ( client )
236+ OpenAIResponseAgent agent = new ( client , modelId )
235237 {
236238 StoreEnabled = storeEnabled ,
237239 Instructions = "Answer questions about the menu."
@@ -274,12 +276,13 @@ public async Task OpenAIResponseAgentInvokeStreamingWithFunctionCallingAsync(str
274276
275277 private async Task ExecuteAgentAsync (
276278 ResponsesClient client ,
279+ string modelId ,
277280 bool storeEnabled ,
278281 string input ,
279282 string expected )
280283 {
281284 // Arrange
282- OpenAIResponseAgent agent = new ( client )
285+ OpenAIResponseAgent agent = new ( client , modelId )
283286 {
284287 StoreEnabled = storeEnabled ,
285288 Instructions = "Answer all queries in English and French."
@@ -306,12 +309,13 @@ private async Task ExecuteAgentAsync(
306309
307310 private async Task ExecuteStreamingAgentAsync (
308311 ResponsesClient client ,
312+ string modelId ,
309313 bool storeEnabled ,
310314 string input ,
311315 string expected )
312316 {
313317 // Arrange
314- OpenAIResponseAgent agent = new ( client )
318+ OpenAIResponseAgent agent = new ( client , modelId )
315319 {
316320 StoreEnabled = storeEnabled ,
317321 Instructions = "Answer all queries in English and French."
@@ -355,22 +359,19 @@ private OpenAIConfiguration ReadConfiguration()
355359 return configuration ;
356360 }
357361
358- private ResponsesClient CreateClient ( bool isOpenAI )
362+ private ( ResponsesClient Client , string ModelId ) CreateClient ( bool isOpenAI )
359363 {
360- ResponsesClient client ;
361364 if ( isOpenAI )
362365 {
363- client = this . CreateClient ( this . _configuration . GetSection ( "OpenAI" ) . Get < OpenAIConfiguration > ( ) ) ;
366+ return this . CreateClient ( this . _configuration . GetSection ( "OpenAI" ) . Get < OpenAIConfiguration > ( ) ) ;
364367 }
365368 else
366369 {
367- client = this . CreateClient ( this . _configuration . GetSection ( "AzureOpenAI" ) . Get < AzureOpenAIConfiguration > ( ) ) ;
370+ return this . CreateClient ( this . _configuration . GetSection ( "AzureOpenAI" ) . Get < AzureOpenAIConfiguration > ( ) ) ;
368371 }
369-
370- return client ;
371372 }
372373
373- private ResponsesClient CreateClient ( OpenAIConfiguration ? configuration )
374+ private ( ResponsesClient , string ) CreateClient ( OpenAIConfiguration ? configuration )
374375 {
375376 Assert . NotNull ( configuration ) ;
376377
@@ -387,10 +388,10 @@ private ResponsesClient CreateClient(OpenAIConfiguration? configuration)
387388 } ;
388389 }
389390
390- return new ResponsesClient ( configuration . ChatModelId , new ApiKeyCredential ( configuration . ApiKey ) , options ) ;
391+ return ( new ResponsesClient ( new ApiKeyCredential ( configuration . ApiKey ) , options ) , configuration . ChatModelId ) ;
391392 }
392393
393- private ResponsesClient CreateClient ( AzureOpenAIConfiguration ? configuration )
394+ private ( ResponsesClient , string ) CreateClient ( AzureOpenAIConfiguration ? configuration )
394395 {
395396 Assert . NotNull ( configuration ) ;
396397
@@ -408,7 +409,7 @@ private ResponsesClient CreateClient(AzureOpenAIConfiguration? configuration)
408409 }
409410
410411 var azureClient = new AzureOpenAIClient ( new Uri ( configuration . Endpoint ) , new AzureCliCredential ( ) , options ) ;
411- return azureClient . GetResponsesClient ( configuration . ChatDeploymentName ) ;
412+ return ( azureClient . GetResponsesClient ( ) , configuration . ChatDeploymentName ) ;
412413 }
413414
414415 public sealed class MenuPlugin
0 commit comments