Fix MCP E2E send wait race#1556
Open
stephentoub wants to merge 1 commit into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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(...)withSendAndWaitAsync(...)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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.idleevent 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 --nologoGenerated by Copilot