From b6ddb10b17cdbad01a6bbf99c96ad8a64dff0452 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Tue, 2 Jun 2026 12:32:42 -0400 Subject: [PATCH] Fix MCP E2E send wait race Use SendAndWaitAsync in MCP and custom agent configuration tests so the session idle subscription is registered before sending the prompt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs b/dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs index 18a8835a6..796c02121 100644 --- a/dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs +++ b/dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs @@ -23,9 +23,7 @@ public async Task Should_Accept_MCP_Server_Configuration_On_Session_Create() await WaitForMcpServerStatusAsync(session, "test-server", McpServerStatus.Connected); // Simple interaction to verify session works - await session.SendAsync(new MessageOptions { Prompt = "What is 2+2?" }); - - var message = await TestHelper.GetFinalAssistantMessageAsync(session); + var message = await session.SendAndWaitAsync(new MessageOptions { Prompt = "What is 2+2?" }); Assert.NotNull(message); Assert.Contains("4", message!.Data.Content); @@ -112,9 +110,7 @@ public async Task Should_Accept_Custom_Agent_Configuration_On_Session_Create() Assert.Matches(@"^[a-f0-9-]+$", session.SessionId); // Simple interaction to verify session works - await session.SendAsync(new MessageOptions { Prompt = "What is 5+5?" }); - - var message = await TestHelper.GetFinalAssistantMessageAsync(session); + var message = await session.SendAndWaitAsync(new MessageOptions { Prompt = "What is 5+5?" }); Assert.NotNull(message); Assert.Contains("10", message!.Data.Content);