Fix race in realtime tool-result unit test - #42
Merged
Conversation
The test waited only for the toolResult event before asserting that the trailing contentEnd event had been captured. Since events are drained asynchronously by the background writer, contentEnd could still be in flight, causing an intermittent Assert.NotNull failure (observed on the arm64 pipeline runner). Wait for contentEnd as well to close the race.
dscpinheiro
approved these changes
Aug 10, 2026
AlexDaines
approved these changes
Aug 10, 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.
Problem
The
Tests-arm64action in theaws-dotnet-aipipeline (Validation stage) failed with a single test failure:Root cause
This is a flaky test, not a product bug.
BedrockNovaRealtimeSession.SendToolResultAsyncwrites three events in order to an unbounded channel —contentStart(TOOL) →toolResult→contentEnd— which a background single-reader task drains asynchronously into the test'scapturedEventslist.The test blocked only on the
toolResultevent, then immediately asserted that acontentEndevent also existed. BecausecontentEndis written aftertoolResultand captured asynchronously, there is a window wheretoolResultis present butcontentEndis still in flight. On the arm64 runner that race was lost and the assertion sawnull.Fix
Wait for the trailing
contentEndevent in addition totoolResultbefore running the assertions, closing the race. The session update in this test supplies noInstructions, so no earlier system-promptcontentEndexists to match spuriously.Testing
dotnet testfor the affected test passes locally on net8.0 (the target that runs in the pipeline).