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
@@ -28,7 +28,7 @@ public static class Program
var workflow = builder.Build();
// Execute the workflow in streaming mode
await using StreamingRun run = await InProcessExecution.StreamAsync(workflow, "Hello, World!");
await using StreamingRun run = await InProcessExecution.StreamAsync(workflow, input: "Hello, World!");
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
if (evt is ExecutorCompletedEvent executorCompleted)
@@ -57,8 +57,7 @@ AIAgent reporter = new ChatClientAgent(anthropic,
description: "Summarize the researcher's essay into a single paragraph, focusing only on the fact checker's confirmed facts.");
// Build a sequential workflow: Researcher -> Fact-Checker -> Reporter
AIAgent workflowAgent = await AgentWorkflowBuilder.BuildSequential(researcher, factChecker, reporter)
.AsAgentAsync();
AIAgent workflowAgent = AgentWorkflowBuilder.BuildSequential(researcher, factChecker, reporter).AsAgent();
// Run the workflow, streaming the output as it arrives.
string? lastAuthor = null;