Fix race condition in AutomaticInputRequiredStatusTests polling logic#1223
Merged
stephentoub merged 5 commits intomainfrom Jan 30, 2026
Merged
Fix race condition in AutomaticInputRequiredStatusTests polling logic#1223stephentoub merged 5 commits intomainfrom
stephentoub merged 5 commits intomainfrom
Conversation
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix intermittent failure in TaskStatus transitions test
Fix race condition in AutomaticInputRequiredStatusTests polling logic
Jan 30, 2026
ericstj
approved these changes
Jan 30, 2026
stephentoub
reviewed
Jan 30, 2026
tests/ModelContextProtocol.Tests/Server/AutomaticInputRequiredStatusTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
ericstj
reviewed
Jan 30, 2026
tests/ModelContextProtocol.Tests/Server/AutomaticInputRequiredStatusTests.cs
Show resolved
Hide resolved
stephentoub
approved these changes
Jan 30, 2026
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.
Fix intermittent test failure in AutomaticInputRequiredStatusTests
Root Cause
The test
TaskStatus_TransitionsToInputRequired_DuringElicitAsync(and its siblingTaskStatus_TransitionsToInputRequired_DuringSampleAsync) has a race condition in its polling loop. The loop continues only while the task status isWorking, but the expected behavior is that the status should transition fromWorking→InputRequired→Working→Completed.When the test polls the task store while the status is temporarily in the
InputRequiredstate, the loop exits early and the test fails because it expectsCompletedbut findsInputRequired.Solution
Updated the polling condition in both tests to continue while the status is not
Completed. This allows the tests to correctly wait for the task to reach completion regardless of the timing of the polling.Changes Made
TaskStatus_TransitionsToInputRequired_DuringSampleAsyncpolling loop condition (line 122)TaskStatus_TransitionsToInputRequired_DuringElicitAsyncpolling loop condition (line 221)finalStatus?.Status is not McpTaskStatus.CompletedVerification
Original prompt
AutomaticInputRequiredStatusTests.TaskStatus_TransitionsToInputRequired_DuringElicitAsyncintermittently fails (timing/race) #1222💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.