.NET: Remove timeout from InputWait in OffThread execution#4996
Merged
.NET: Remove timeout from InputWait in OffThread execution#4996
Conversation
583e637 to
9db1bf8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OffThread execution event-stream/run-loop coordination to remove the InputWait timeout (eliminating spurious “empty” steps) and fixes a race where an internal halt signal could be ignored if the consumer starts watching the event stream after the workflow already halted.
Changes:
- Remove the timeout from
StreamingRunEventStream’s wait-for-input behavior. - Fix
TakeEventStreamAsyncepoch selection so a pre-existing halt signal isn’t incorrectly ignored. - Add a unit test that delays stream consumption to validate the “halt before watch starts” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Workflows/Execution/StreamingRunEventStream.cs | Removes input wait timeout and adjusts completion-epoch logic to avoid missing halt signals. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs | Adds a regression test that starts watching the stream after execution has already been triggered. |
alliscode
approved these changes
Mar 31, 2026
peibekwe
reviewed
Mar 31, 2026
peibekwe
approved these changes
Mar 31, 2026
alliscode
pushed a commit
to alliscode/agent-framework
that referenced
this pull request
Apr 3, 2026
…#4996) * fix: Remove Timeout from InputWait in StreamingRunEventStream * fix: Race condition when the workflow executes to halt before TakeEventStream * test: Make the OffThread Delay test more nimble * fix: Remove slight window where runStatus could be stale
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.
Motivation and Context
When we first implemented OffThread running, we added a synchronization construct to avoid spinning a thread while the workflow is waiting on input after having run to Idle. Due to some race conditions we could not initially identify, we could end up with a deadlock, which we resolved by adding a timeout to the input wait. This could result in spurious "empty" steps, and it was long desired to remove it.
Over time we hardened the core of the runtime and removed the likely data races (particularly in the input rework for supporting Polymorphic Message Routing). We have high confidence (three thousand iterations of the unit tests, run locally) that these, along with the epoch fix in this PR, bring us to a good place regarding removing the timeout.
Description
Contribution Checklist
[ ] Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.