diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index bbebd7a312..77f312617d 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -274,8 +274,9 @@ private ResumeSessionConfig CreateResumeConfig() } /// - /// Copies all supported properties from a source into a new instance - /// with set to true. + /// Copies all supported properties from a source into a new instance, + /// preserving the value from when set. + /// When has no explicit value, streaming defaults to true. /// internal static SessionConfig CopySessionConfig(SessionConfig source) { @@ -298,13 +299,14 @@ internal static SessionConfig CopySessionConfig(SessionConfig source) SkillDirectories = source.SkillDirectories, DisabledSkills = source.DisabledSkills, InfiniteSessions = source.InfiniteSessions, - Streaming = true + Streaming = source.Streaming ?? true }; } /// /// Copies all supported properties from a source into a new - /// with set to true. + /// , preserving the value + /// from . When is null, streaming defaults to true. /// internal static ResumeSessionConfig CopyResumeSessionConfig(SessionConfig? source) { @@ -327,7 +329,7 @@ internal static ResumeSessionConfig CopyResumeSessionConfig(SessionConfig? sourc SkillDirectories = source?.SkillDirectories, DisabledSkills = source?.DisabledSkills, InfiniteSessions = source?.InfiniteSessions, - Streaming = true + Streaming = source?.Streaming ?? true }; } 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 52ea0026dc..5fb9c44dd7 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -129,6 +129,7 @@ public void CopySessionConfig_CopiesAllProperties() OnUserInputRequest = userInputHandler, McpServers = mcpServers, DisabledSkills = ["skill1"], + Streaming = true, }; // Act @@ -180,6 +181,7 @@ public void CopyResumeSessionConfig_CopiesAllProperties() OnUserInputRequest = userInputHandler, McpServers = mcpServers, DisabledSkills = ["skill1"], + Streaming = true, }; // Act @@ -222,6 +224,40 @@ public void CopyResumeSessionConfig_WithNullSource_ReturnsDefaults() Assert.True(result.Streaming); } + [Fact] + public void CopySessionConfig_WithStreamingFalse_PreservesStreamingFalse() + { + // Arrange — caller explicitly disables streaming (issue #4732) + var source = new SessionConfig + { + Streaming = false, + SystemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "You are a helpful assistant." }, + }; + + // Act + SessionConfig result = GitHubCopilotAgent.CopySessionConfig(source); + + // Assert + Assert.False(result.Streaming); + } + + [Fact] + public void CopyResumeSessionConfig_WithStreamingFalse_PreservesStreamingFalse() + { + // Arrange — caller explicitly disables streaming (issue #4732) + var source = new SessionConfig + { + Streaming = false, + SystemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "You are a helpful assistant." }, + }; + + // Act + ResumeSessionConfig result = GitHubCopilotAgent.CopyResumeSessionConfig(source); + + // Assert + Assert.False(result.Streaming); + } + [Fact] public void ConvertToAgentResponseUpdate_AssistantMessageEvent_DoesNotEmitTextContent() {