Skip to content

.NET: bug fix for duplicate output on GitHubCopilotAgent#3981

Merged
alliscode merged 6 commits intomicrosoft:mainfrom
normalian:feature/githubcopilotbugfix
Mar 4, 2026
Merged

.NET: bug fix for duplicate output on GitHubCopilotAgent#3981
alliscode merged 6 commits intomicrosoft:mainfrom
normalian:feature/githubcopilotbugfix

Conversation

@normalian
Copy link
Contributor

Motivation and Context

When using GitHubCopilotAgent, the final assistant message output was duplicated. The AssistantMessageDeltaEvent handlers already stream text content incrementally via TextContent, but the AssistantMessageEvent handler was also emitting a TextContent with the full message. This caused downstream consumers to render the same text twice.

Description

Changed the ConvertToAgentResponseUpdate(AssistantMessageEvent) method in GitHubCopilotAgent.cs to emit a plain AIContent instead of a TextContent. The AssistantMessageEvent is a completion signal that carries metadata (message ID, timestamp, raw representation) — it should not re-emit the text content that was already streamed through AssistantMessageDeltaEvent. By using AIContent instead of TextContent, the event still preserves its RawRepresentation for inspection without producing duplicate text output.

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

Copilot AI review requested due to automatic review settings February 17, 2026 02:50
@github-actions github-actions bot changed the title bug fix for duplicate output on GitHubCopilotAgent .NET: bug fix for duplicate output on GitHubCopilotAgent Feb 17, 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

This PR fixes a bug in GitHubCopilotAgent where the final assistant message output was duplicated during streaming. The issue occurred because both AssistantMessageDeltaEvent (streaming incremental text) and AssistantMessageEvent (completion signal) were emitting text content, causing downstream consumers to render the same text twice.

Changes:

  • Modified ConvertToAgentResponseUpdate(AssistantMessageEvent) to emit AIContent instead of TextContent, preserving metadata without duplicating text output.

@markwallace-microsoft
Copy link
Member

Copilot is handing this issue microsoft/semantic-kernel#13570 to fix the PR build

@dmytrostruk
Copy link
Member

@normalian Thanks for your contribution, wondering if you would be able to add some tests to verify this behavior? Please let me know, thanks!

@normalian
Copy link
Contributor Author

HI @dmytrostruk, thanks for your reply. I just created the test code and push here. Please review it.

@normalian
Copy link
Contributor Author

Thanks for your review, @dmytrostruk. I just update the source code files by following your suggestion. Please check again.

@dmytrostruk dmytrostruk added this pull request to the merge queue Mar 4, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2026
@alliscode alliscode added this pull request to the merge queue Mar 4, 2026
Merged via the queue into microsoft:main with commit 23644ac Mar 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants