[BREAKING] .NET: Workflow Off-Thread Execution Mode (#1233)

* Updates to async run loop.

* fix: Workflow Onwership can be release by nonowner

* fix: Incorrect handling of blockOnPending in StreamingRun

Depending on whether we are running in streaming on non-streaming mode, we may be using the StreamingRun in different ways. Unfortunately, the only place we can really know what is the actual state of execution is in the RunEventStream implementations.

This resulted in blocking where blocking was unneeded and occasionally not-blocking when blocking was needed.

The fix is to move the logic of handling this blocking into RunEventStream implementations.

* fix: Fix cleanup on error and end run

This ensures we clean up the background resources correctly.

* fix: Ensure we let the run loop proceed when shutting down

* fix: Add timeout for Input Waiting

* fix: Make the samples properly clean up `Run`s and `StreamingRun`s

* fix: Simplify Declarative Workflow Run disposal pattern

* Also fixes missing .Disposal() in Integration tests

---------

Co-authored-by: Ben Thomas <ben.thomas@microsoft.com>
This commit is contained in:
Jacob Alber
2025-10-07 01:07:38 +00:00
committed by GitHub
co-authored by Ben Thomas
parent 0113e0466d
commit 7ebe00ec3d
56 changed files with 1275 additions and 612 deletions
@@ -163,9 +163,25 @@ public class InProcessStateTests
.AddFanOutEdge(forward, targets: [testExecutor, testExecutor2])
.Build();
var act = async () => await InProcessExecution.RunAsync(workflow, new TurnToken());
Run runWithFailure = await InProcessExecution.RunAsync(workflow, new TurnToken());
var result = await act.Should()
.ThrowAsync("multiple writers to the same shared scope key");
bool hadFailure = false;
foreach (WorkflowEvent evt in runWithFailure.NewEvents)
{
if (evt is WorkflowErrorEvent errorEvent)
{
hadFailure.Should().BeFalse("There can be only one!");
hadFailure = true;
errorEvent.Data.Should().BeOfType<InvalidOperationException>()
.Subject.Message.Should().Contain("TestKey");
}
}
hadFailure.Should().BeTrue();
//var act = async () => await InProcessExecution.RunAsync(workflow, new TurnToken());
//var result = await act.Should()
// .ThrowAsync("multiple writers to the same shared scope key");
}
}