mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
[BREAKING] .NET: Decouple Checkpointing from Run/StreamAsync APIs (#4037)
* [BREAKING] refactor: Decouple Checkpointing and Execution APIs With this change, Checkpointing becomes an property of an IWorkflowExecutionEnvironment. This lets environments that are tightly-coupled to their CheckpointManager avoid needing to present APIs that would not work (e.g. taking in an InMemory CheckpointManager for Durable Tasks, for example) * refactor: Normalize IsCheckpointingEnabled naming
This commit is contained in:
committed by
GitHub
Unverified
parent
fd4e6e816c
commit
c73bd87503
+4
-4
@@ -32,10 +32,10 @@ public static class Program
|
||||
var checkpoints = new List<CheckpointInfo>();
|
||||
|
||||
// Execute the workflow and save checkpoints
|
||||
await using Checkpointed<StreamingRun> checkpointedRun = await InProcessExecution
|
||||
await using StreamingRun checkpointedRun = await InProcessExecution
|
||||
.StreamAsync(workflow, NumberSignal.Init, checkpointManager);
|
||||
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
{
|
||||
@@ -72,10 +72,10 @@ public static class Program
|
||||
Console.WriteLine($"\n\nHydrating a new workflow instance from the {CheckpointIndex + 1}th checkpoint.");
|
||||
CheckpointInfo savedCheckpoint = checkpoints[CheckpointIndex];
|
||||
|
||||
await using Checkpointed<StreamingRun> newCheckpointedRun =
|
||||
await using StreamingRun newCheckpointedRun =
|
||||
await InProcessExecution.ResumeStreamAsync(newWorkflow, savedCheckpoint, checkpointManager);
|
||||
|
||||
await foreach (WorkflowEvent evt in newCheckpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in newCheckpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
{
|
||||
|
||||
@@ -31,10 +31,10 @@ public static class Program
|
||||
var checkpoints = new List<CheckpointInfo>();
|
||||
|
||||
// Execute the workflow and save checkpoints
|
||||
await using Checkpointed<StreamingRun> checkpointedRun = await InProcessExecution
|
||||
await using StreamingRun checkpointedRun = await InProcessExecution
|
||||
.StreamAsync(workflow, NumberSignal.Init, checkpointManager)
|
||||
;
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ public static class Program
|
||||
CheckpointInfo savedCheckpoint = checkpoints[CheckpointIndex];
|
||||
// Note that we are restoring the state directly to the same run instance.
|
||||
await checkpointedRun.RestoreCheckpointAsync(savedCheckpoint, CancellationToken.None);
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
{
|
||||
|
||||
+5
-5
@@ -34,17 +34,17 @@ public static class Program
|
||||
var checkpoints = new List<CheckpointInfo>();
|
||||
|
||||
// Execute the workflow and save checkpoints
|
||||
await using Checkpointed<StreamingRun> checkpointedRun = await InProcessExecution
|
||||
await using StreamingRun checkpointedRun = await InProcessExecution
|
||||
.StreamAsync(workflow, new SignalWithNumber(NumberSignal.Init), checkpointManager)
|
||||
;
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
switch (evt)
|
||||
{
|
||||
case RequestInfoEvent requestInputEvt:
|
||||
// Handle `RequestInfoEvent` from the workflow
|
||||
ExternalResponse response = HandleExternalRequest(requestInputEvt.Request);
|
||||
await checkpointedRun.Run.SendResponseAsync(response);
|
||||
await checkpointedRun.SendResponseAsync(response);
|
||||
break;
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
@@ -77,14 +77,14 @@ public static class Program
|
||||
CheckpointInfo savedCheckpoint = checkpoints[CheckpointIndex];
|
||||
// Note that we are restoring the state directly to the same run instance.
|
||||
await checkpointedRun.RestoreCheckpointAsync(savedCheckpoint, CancellationToken.None);
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.Run.WatchStreamAsync())
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
switch (evt)
|
||||
{
|
||||
case RequestInfoEvent requestInputEvt:
|
||||
// Handle `RequestInfoEvent` from the workflow
|
||||
ExternalResponse response = HandleExternalRequest(requestInputEvt.Request);
|
||||
await checkpointedRun.Run.SendResponseAsync(response);
|
||||
await checkpointedRun.SendResponseAsync(response);
|
||||
break;
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
|
||||
Reference in New Issue
Block a user