@@ -218,6 +218,51 @@ public async Task OpenAIResponseAgentInvokeStreamingWithThreadAsync(bool isOpenA
218218 Assert . Contains ( "Computer says no" , responseText ) ;
219219 }
220220
221+
222+ /// <summary>
223+ /// Integration test for <see cref="OpenAIResponseAgent"/> with existing chat history.
224+ /// </summary>
225+ [ RetryTheory ( typeof ( HttpOperationException ) ) ]
226+ [ InlineData ( false , false ) ]
227+ [ InlineData ( false , true ) ]
228+ [ InlineData ( true , false ) ]
229+ [ InlineData ( true , true ) ]
230+ public async Task OpenAIResponseAgentInvokeStreamingWithChatHistoryAsync ( bool isOpenAI , bool storeEnabled )
231+ {
232+ // Arrange
233+ OpenAIResponseClient client = this . CreateClient ( isOpenAI ) ;
234+ OpenAIResponseAgent agent = new ( client )
235+ {
236+ StoreEnabled = storeEnabled ,
237+ Instructions = "Answer all queries in English and French."
238+ } ;
239+
240+ var chatHistory = new ChatHistory ( ) ;
241+ chatHistory . AddUserMessage ( "Hello my name is John" ) ;
242+ chatHistory . AddAssistantMessage ( "Hello John, how can I help you today?" ) ;
243+ chatHistory . AddUserMessage ( "What is my Name?" ) ;
244+
245+ AgentThread agentThread = storeEnabled ? new OpenAIResponseAgentThread ( client ) : new ChatHistoryAgentThread ( ) ;
246+
247+ // Act
248+ string ? responseText = null ;
249+ try
250+ {
251+ var responseMessages = await agent . InvokeStreamingAsync ( chatHistory , agentThread ) . ToArrayAsync ( ) ;
252+ responseText = string . Join ( string . Empty , responseMessages . Select ( ri => ri . Message . Content ) ) ;
253+ }
254+ finally
255+ {
256+ if ( agentThread . Id is not null )
257+ {
258+ await agentThread . DeleteAsync ( ) ;
259+ }
260+ }
261+
262+ // Assert
263+ Assert . NotNull ( responseText ) ;
264+ }
265+
221266 /// <summary>
222267 /// Integration test for <see cref="OpenAIResponseAgent"/> adding override instructions to a thread on invocation via custom options.
223268 /// </summary>
0 commit comments