Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Motivation and Context

SessionMaintainsHistoryAsync streaming tests fail consistently because RunCoreStreamingAsync passes inputMessagesForProviders (current input only) to GetStreamingResponseAsync instead of inputMessagesForChatClient (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: swap inputMessagesForProvidersinputMessagesForChatClient in the GetStreamingResponseAsync call, matching the non-streaming path.

- responseUpdatesEnumerator = chatClient.GetStreamingResponseAsync(inputMessagesForProviders, chatOptions, cancellationToken)
+ responseUpdatesEnumerator = chatClient.GetStreamingResponseAsync(inputMessagesForChatClient, chatOptions, cancellationToken)

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

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: [Bug]: OpenAIChatCompletion.IntegrationTests fail in merge queue</issue_title>
<issue_description>Failing test: OpenAIChatCompletion.IntegrationTests.OpenAIChatCompletionReasoningRunStreamingTests.SessionMaintainsHistoryAsync

Error:

[xUnit.net 00:00:43.37] OpenAIChatCompletion.IntegrationTests.OpenAIChatCompletionReasoningRunStreamingTests.SessionMaintainsHistoryAsync [FAIL]
[xUnit.net 00:00:43.37] Assert.Contains() Failure: Sub-string not found
[xUnit.net 00:00:43.37] String: "Could you clarify what you’d like to know"···
[xUnit.net 00:00:43.37] Not found: "Vienna"
[xUnit.net 00:00:43.37] Stack Trace:
[xUnit.net 00:00:43.37] /home/runner/work/agent-framework/agent-framework/dotnet/tests/AgentConformance.IntegrationTests/RunStreamingTests.cs(107,0): at AgentConformance.IntegrationTests.RunStreamingTests1.SessionMaintainsHistoryAsync() [xUnit.net 00:00:43.37] /home/runner/work/agent-framework/agent-framework/dotnet/tests/AgentConformance.IntegrationTests/RunStreamingTests.cs(116,0): at AgentConformance.IntegrationTests.RunStreamingTests1.SessionMaintainsHistoryAsync()
[xUnit.net 00:00:43.37] --- End of stack trace from previous location ---
Failed OpenAIChatCompletion.IntegrationTests.OpenAIChatCompletionReasoningRunStreamingTests.SessionMaintainsHistoryAsync [6 s]
Error Message:
Assert.Contains() Failure: Sub-string not found
String: "Could you clarify what you’d like to know"···
Not found: "Vienna"
Stack Trace:
at AgentConformance.IntegrationTests.RunStreamingTests1.SessionMaintainsHistoryAsync() in /home/runner/work/agent-framework/agent-framework/dotnet/tests/AgentConformance.IntegrationTests/RunStreamingTests.cs:line 107 at AgentConformance.IntegrationTests.RunStreamingTests1.SessionMaintainsHistoryAsync() in /home/runner/work/agent-framework/agent-framework/dotnet/tests/AgentConformance.IntegrationTests/RunStreamingTests.cs:line 116</issue_description>

<agent_instructions>This test fails consistently with the same error message each time.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI changed the title [WIP] Fix OpenAIChatCompletion integration test failure Fix RunStreamingAsync not including chat history in messages sent to chat client Feb 10, 2026
Copilot AI requested a review from lokitoth February 10, 2026 10:58
@github-actions github-actions bot changed the title Fix RunStreamingAsync not including chat history in messages sent to chat client .NET: Fix RunStreamingAsync not including chat history in messages sent to chat client Feb 10, 2026
…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]>
@lokitoth lokitoth force-pushed the copilot/fix-integration-test-failure branch from 6572440 to a76f2e2 Compare February 10, 2026 13:13
@lokitoth lokitoth marked this pull request as ready for review February 10, 2026 13:36
Copilot AI review requested due to automatic review settings February 10, 2026 13:36
@lokitoth lokitoth moved this to In Review in Agent Framework Feb 10, 2026
Copy link
Contributor

Copilot AI left a 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.RunCoreStreamingAsync to pass inputMessagesForChatClient into GetStreamingResponseAsync.
  • 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.

@lokitoth lokitoth added this pull request to the merge queue Feb 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 10, 2026
@lokitoth lokitoth added this pull request to the merge queue Feb 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 10, 2026
@lokitoth lokitoth added this pull request to the merge queue Feb 10, 2026
@lokitoth lokitoth removed this pull request from the merge queue due to a manual request Feb 10, 2026
@lokitoth lokitoth added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit 6c37ce8 Feb 10, 2026
20 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

5 participants