diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs index a045c6de8a..8041429a47 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs @@ -159,7 +159,7 @@ internal sealed class WorkflowSession : AgentSession .ConfigureAwait(false); // Process messages: convert response content to ExternalResponse, send regular messages as-is - await this.SendMessagesWithResponseConversionAsync(run, messages, cancellationToken).ConfigureAwait(false); + await this.SendMessagesWithResponseConversionAsync(run, messages).ConfigureAwait(false); return run; } @@ -175,7 +175,7 @@ internal sealed class WorkflowSession : AgentSession /// Sends messages to the run, converting FunctionResultContent and UserInputResponseContent /// to ExternalResponse when there's a matching pending request. /// - private async ValueTask SendMessagesWithResponseConversionAsync(StreamingRun run, List messages, CancellationToken cancellationToken) + private async ValueTask SendMessagesWithResponseConversionAsync(StreamingRun run, List messages) { List regularMessages = []; @@ -202,12 +202,9 @@ internal sealed class WorkflowSession : AgentSession if (regularContents.Count > 0) { - regularMessages.Add(new ChatMessage(message.Role, regularContents) - { - AuthorName = message.AuthorName, - MessageId = message.MessageId, - CreatedAt = message.CreatedAt - }); + ChatMessage cloned = message.Clone(); + cloned.Contents = regularContents; + regularMessages.Add(cloned); } } diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs index 8f1c5f1c89..35db39b963 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs @@ -194,8 +194,8 @@ public class WorkflowHostSmokeTests { // Arrange const string RequestId = "test-request-id"; - McpServerToolCallContent mcpCalll = new("call-id", "testToolName", "http://localhost"); - UserInputRequestContent originalContent = new McpServerToolApprovalRequestContent(RequestId, mcpCalll); + McpServerToolCallContent mcpCall = new("call-id", "testToolName", "http://localhost"); + UserInputRequestContent originalContent = new McpServerToolApprovalRequestContent(RequestId, mcpCall); RequestEmittingAgent requestAgent = new(originalContent); ExecutorBinding agentBinding = requestAgent.BindAsExecutor( new AIAgentHostOptions { InterceptUserInputRequests = false, EmitAgentUpdateEvents = true });