Skip to content

Fix MCP E2E send wait race#1556

Open
stephentoub wants to merge 1 commit into
mainfrom
stephentoub/investigate-shutdown-test-failures
Open

Fix MCP E2E send wait race#1556
stephentoub wants to merge 1 commit into
mainfrom
stephentoub/investigate-shutdown-test-failures

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

Fixes a race in the MCP and custom-agent configuration E2E coverage where the test sent a prompt and only then waited for the final assistant message. If the replayed turn completed quickly, the ephemeral session.idle event could be missed and the test would time out.

This switches those simple verification prompts to SendAndWaitAsync, which registers its event handler before sending.

Tests:

  • dotnet build dotnet\test\GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore --nologo

Generated by Copilot

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>
@stephentoub stephentoub requested a review from a team as a code owner June 2, 2026 16:33
Copilot AI review requested due to automatic review settings June 2, 2026 16:33
Copy link
Copy Markdown
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 updates a couple of MCP/custom-agent E2E test interactions to avoid a race where the test could miss the transient session.idle event if the replayed turn completes very quickly. It does so by using SendAndWaitAsync, which registers the event handler before sending the prompt, making these verification steps more reliable within the broader .NET E2E suite.

Changes:

  • Replace SendAsync(...) + TestHelper.GetFinalAssistantMessageAsync(...) with SendAndWaitAsync(...) in two “simple interaction” verification steps.
  • Ensure the final assistant message is awaited via the session’s built-in idle-waiting mechanism to prevent timeouts caused by missed idle events.
Show a summary per file
File Description
dotnet/test/E2E/SessionMcpAndAgentConfigE2ETests.cs Switches two simple verification prompts to SendAndWaitAsync to eliminate an idle-event timing race in E2E tests.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants