-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Fix RunStreamingAsync not including chat history in messages sent to chat client #3798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lient RunCoreStreamingAsync was passing inputMessagesForProviders (which lacks chat history) to GetStreamingResponseAsync instead of inputMessagesForChatClient (which includes chat history). This caused streaming runs to lose conversation context on subsequent calls. The non-streaming path (RunCoreAsync) already correctly used inputMessagesForChatClient. This aligns the streaming path to match. Also adds a unit test that validates chat history is included in messages sent to the chat client during streaming on subsequent calls. Co-authored-by: lokitoth <[email protected]>
6572440 to
a76f2e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes a streaming conversation-history bug in ChatClientAgent where the streaming path was sending only the current input to the chat client, instead of chat history + current input (matching the non-streaming path). This restores multi-turn context for streaming runs and addresses the failing SessionMaintainsHistoryAsync streaming scenario.
Changes:
- Update
ChatClientAgent.RunCoreStreamingAsyncto passinputMessagesForChatClientintoGetStreamingResponseAsync. - Add a unit test validating that a second streaming call on the same session includes prior turn history in the messages sent to the chat client.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Fix streaming invocation to send chat-history-inclusive message list to the underlying IChatClient. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs | Add regression test ensuring streaming calls include prior session history on subsequent turns. |
Motivation and Context
SessionMaintainsHistoryAsyncstreaming tests fail consistently becauseRunCoreStreamingAsyncpassesinputMessagesForProviders(current input only) toGetStreamingResponseAsyncinstead ofinputMessagesForChatClient(chat history + current input). The non-streaming path already uses the correct collection. Without chat history, follow-up questions like "And Austria?" after "What is the capital of France?" lack context and the model can't infer intent.Description
One-line fix in
ChatClientAgent.RunCoreStreamingAsync: swapinputMessagesForProviders→inputMessagesForChatClientin theGetStreamingResponseAsynccall, matching the non-streaming path.Added a unit test that makes two streaming calls on the same session and asserts the second call's messages include prior chat history (3 messages: original user message, assistant response, follow-up).
Contribution Checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.