refactor: [BREAKING] Remove generic Workflow<T> (#1551)

Remove input type checking in favour of explicit `.DescribeProtocolAsync()` flow. Also removes `.AsAgentAsync()` as the validation happens at workflow run time. This makes it easier to use Workflows with DI without resorting to async-over-sync.
This commit is contained in:
Jacob Alber
2025-10-21 00:13:41 +00:00
committed by GitHub
parent 7c1e3db846
commit 0ef4e739d5
43 changed files with 284 additions and 461 deletions
@@ -25,7 +25,7 @@ public static class Program
private static async Task Main()
{
// Create the workflow
var workflow = await WorkflowHelper.GetWorkflowAsync();
var workflow = WorkflowHelper.GetWorkflow();
// Create checkpoint manager
var checkpointManager = CheckpointManager.Default;
@@ -67,7 +67,7 @@ public static class Program
Console.WriteLine($"Number of checkpoints created: {checkpoints.Count}");
// Rehydrate a new workflow instance from a saved checkpoint and continue execution
var newWorkflow = await WorkflowHelper.GetWorkflowAsync();
var newWorkflow = WorkflowHelper.GetWorkflow();
const int CheckpointIndex = 5;
Console.WriteLine($"\n\nHydrating a new workflow instance from the {CheckpointIndex + 1}th checkpoint.");
CheckpointInfo savedCheckpoint = checkpoints[CheckpointIndex];
@@ -13,7 +13,7 @@ internal static class WorkflowHelper
/// 2. JudgeExecutor: Evaluates the guess and provides feedback.
/// The workflow continues until the correct number is guessed.
/// </summary>
internal static ValueTask<Workflow<NumberSignal>> GetWorkflowAsync()
internal static Workflow GetWorkflow()
{
// Create the executors
GuessNumberExecutor guessNumberExecutor = new(1, 100);
@@ -24,7 +24,7 @@ internal static class WorkflowHelper
.AddEdge(guessNumberExecutor, judgeExecutor)
.AddEdge(judgeExecutor, guessNumberExecutor)
.WithOutputFrom(judgeExecutor)
.BuildAsync<NumberSignal>();
.Build();
}
}
@@ -24,7 +24,7 @@ public static class Program
private static async Task Main()
{
// Create the workflow
var workflow = await WorkflowHelper.GetWorkflowAsync();
var workflow = WorkflowHelper.GetWorkflow();
// Create checkpoint manager
var checkpointManager = CheckpointManager.Default;
@@ -13,7 +13,7 @@ internal static class WorkflowHelper
/// 2. JudgeExecutor: Evaluates the guess and provides feedback.
/// The workflow continues until the correct number is guessed.
/// </summary>
internal static ValueTask<Workflow<NumberSignal>> GetWorkflowAsync()
internal static Workflow GetWorkflow()
{
// Create the executors
GuessNumberExecutor guessNumberExecutor = new(1, 100);
@@ -24,7 +24,7 @@ internal static class WorkflowHelper
.AddEdge(guessNumberExecutor, judgeExecutor)
.AddEdge(judgeExecutor, guessNumberExecutor)
.WithOutputFrom(judgeExecutor)
.BuildAsync<NumberSignal>();
.Build();
}
}
@@ -27,7 +27,7 @@ public static class Program
private static async Task Main()
{
// Create the workflow
var workflow = await WorkflowHelper.GetWorkflowAsync();
var workflow = WorkflowHelper.GetWorkflow();
// Create checkpoint manager
var checkpointManager = CheckpointManager.Default;
@@ -10,7 +10,7 @@ internal static class WorkflowHelper
/// Get a workflow that plays a number guessing game with human-in-the-loop interaction.
/// An input port allows the external world to provide inputs to the workflow upon requests.
/// </summary>
internal static ValueTask<Workflow<SignalWithNumber>> GetWorkflowAsync()
internal static Workflow GetWorkflow()
{
// Create the executors
RequestPort numberRequest = RequestPort.Create<SignalWithNumber, int>("GuessNumber");
@@ -21,7 +21,7 @@ internal static class WorkflowHelper
.AddEdge(numberRequest, judgeExecutor)
.AddEdge(judgeExecutor, numberRequest)
.WithOutputFrom(judgeExecutor)
.BuildAsync<SignalWithNumber>();
.Build();
}
}