From 81280cfff355d73616a94c13feeaead1184fd142 Mon Sep 17 00:00:00 2001 From: Daichi Isami Date: Mon, 16 Feb 2026 18:46:16 -0800 Subject: [PATCH 1/3] bug fix for duplicate output on GitHubCopilotAgent --- .../Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index f0533c8461..331346ec40 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -348,12 +348,12 @@ private AgentResponseUpdate ConvertToAgentResponseUpdate(AssistantMessageDeltaEv private AgentResponseUpdate ConvertToAgentResponseUpdate(AssistantMessageEvent assistantMessage) { - TextContent textContent = new(assistantMessage.Data?.Content ?? string.Empty) + AIContent content = new() { RawRepresentation = assistantMessage }; - return new AgentResponseUpdate(ChatRole.Assistant, [textContent]) + return new AgentResponseUpdate(ChatRole.Assistant, [content]) { AgentId = this.Id, ResponseId = assistantMessage.Data?.MessageId, From fa60bd4c4fc8ee8a90c5618e781448c139779137 Mon Sep 17 00:00:00 2001 From: Daichi Isami Date: Wed, 25 Feb 2026 12:26:55 -0800 Subject: [PATCH 2/3] Add Test code for bug fix of duplicate output on GitHubCopilotAgenttT --- .../GitHubCopilotAgentTests.cs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs index 8a4d3c1068..d6a75bdc7a 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Threading.Tasks; using GitHub.Copilot.SDK; using Microsoft.Extensions.AI; @@ -221,4 +222,33 @@ public void CopyResumeSessionConfig_WithNullSource_ReturnsDefaults() Assert.Null(result.ConfigDir); Assert.True(result.Streaming); } -} + + [Fact] + public void ConvertToAgentResponseUpdate_AssistantMessageEvent_DoesNotEmitTextContent() + { + var assistantMessage = new AssistantMessageEvent + { + Data = new AssistantMessageData + { + MessageId = "msg-456", + Content = "Some streamed content that was already delivered via delta events" + } + }; + CopilotClient copilotClient = new(new CopilotClientOptions { AutoStart = false }); + const string TestId = "agent-id"; + var agent = new GitHubCopilotAgent(copilotClient, ownsClient: false, id: TestId, tools: null); + MethodInfo method = typeof(GitHubCopilotAgent).GetMethod( + "ConvertToAgentResponseUpdate", + BindingFlags.NonPublic | BindingFlags.Instance, + binder: null, + types: [typeof(AssistantMessageEvent)], + modifiers: null)!; + + var result = (AgentResponseUpdate)method.Invoke(agent, [assistantMessage])!; + + // result.Text need to be empty because the content was already delivered via delta events, and we want to avoid emitting duplicate content in the response update. + // The content should be delivered through TextContent in the Contents collection instead. + Assert.Empty(result.Text); + Assert.DoesNotContain(result.Contents, c => c is TextContent); + } +} \ No newline at end of file From f6b46bf1634c45ea327b3f5c7d4d087f65637001 Mon Sep 17 00:00:00 2001 From: Daichi Isami Date: Wed, 25 Feb 2026 12:34:09 -0800 Subject: [PATCH 3/3] update Test code for bug fix of duplicate output on GitHubCopilotAgenttT --- .../GitHubCopilotAgentTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs index d6a75bdc7a..dfd6a629cc 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -251,4 +251,4 @@ public void ConvertToAgentResponseUpdate_AssistantMessageEvent_DoesNotEmitTextCo Assert.Empty(result.Text); Assert.DoesNotContain(result.Contents, c => c is TextContent); } -} \ No newline at end of file +}