mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
fixup: PR comments
This commit is contained in:
@@ -37,39 +37,41 @@ public static class Program
|
||||
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
switch (evt)
|
||||
{
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
}
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
break;
|
||||
|
||||
if (evt is SuperStepCompletedEvent superStepCompletedEvt)
|
||||
{
|
||||
// Checkpoints are automatically created at the end of each super step when a
|
||||
// checkpoint manager is provided. You can store the checkpoint info for later use.
|
||||
CheckpointInfo? checkpoint = superStepCompletedEvt.CompletionInfo!.Checkpoint;
|
||||
if (checkpoint is not null)
|
||||
case SuperStepCompletedEvent superStepCompletedEvt:
|
||||
{
|
||||
checkpoints.Add(checkpoint);
|
||||
Console.WriteLine($"** Checkpoint created at step {checkpoints.Count}.");
|
||||
// Checkpoints are automatically created at the end of each super step when a
|
||||
// checkpoint manager is provided. You can store the checkpoint info for later use.
|
||||
CheckpointInfo? checkpoint = superStepCompletedEvt.CompletionInfo!.Checkpoint;
|
||||
if (checkpoint is not null)
|
||||
{
|
||||
checkpoints.Add(checkpoint);
|
||||
Console.WriteLine($"** Checkpoint created at step {checkpoints.Count}.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt is WorkflowOutputEvent outputEvent)
|
||||
{
|
||||
Console.WriteLine($"Workflow completed with result: {outputEvent.Data}");
|
||||
}
|
||||
case WorkflowOutputEvent outputEvent:
|
||||
Console.WriteLine($"Workflow completed with result: {outputEvent.Data}");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowErrorEvent workflowError)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else if (evt is ExecutorFailedEvent executorFailed)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
case WorkflowErrorEvent workflowError:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
|
||||
case ExecutorFailedEvent executorFailed:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,27 +92,27 @@ public static class Program
|
||||
|
||||
await foreach (WorkflowEvent evt in newCheckpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
switch (evt)
|
||||
{
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
}
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowOutputEvent workflowOutputEvt)
|
||||
{
|
||||
Console.WriteLine($"Workflow completed with result: {workflowOutputEvt.Data}");
|
||||
}
|
||||
case WorkflowOutputEvent workflowOutputEvt:
|
||||
Console.WriteLine($"Workflow completed with result: {workflowOutputEvt.Data}");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowErrorEvent workflowError)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else if (evt is ExecutorFailedEvent executorFailed)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
case WorkflowErrorEvent workflowError:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
|
||||
case ExecutorFailedEvent executorFailed:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,39 +34,41 @@ public static class Program
|
||||
await using StreamingRun checkpointedRun = await InProcessExecution.RunStreamingAsync(workflow, NumberSignal.Init, checkpointManager);
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
switch (evt)
|
||||
{
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
}
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
break;
|
||||
|
||||
if (evt is SuperStepCompletedEvent superStepCompletedEvt)
|
||||
{
|
||||
// Checkpoints are automatically created at the end of each super step when a
|
||||
// checkpoint manager is provided. You can store the checkpoint info for later use.
|
||||
CheckpointInfo? checkpoint = superStepCompletedEvt.CompletionInfo!.Checkpoint;
|
||||
if (checkpoint is not null)
|
||||
case SuperStepCompletedEvent superStepCompletedEvt:
|
||||
{
|
||||
checkpoints.Add(checkpoint);
|
||||
Console.WriteLine($"** Checkpoint created at step {checkpoints.Count}.");
|
||||
// Checkpoints are automatically created at the end of each super step when a
|
||||
// checkpoint manager is provided. You can store the checkpoint info for later use.
|
||||
CheckpointInfo? checkpoint = superStepCompletedEvt.CompletionInfo!.Checkpoint;
|
||||
if (checkpoint is not null)
|
||||
{
|
||||
checkpoints.Add(checkpoint);
|
||||
Console.WriteLine($"** Checkpoint created at step {checkpoints.Count}.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt is WorkflowOutputEvent workflowOutputEvt)
|
||||
{
|
||||
Console.WriteLine($"Workflow completed with result: {workflowOutputEvt.Data}");
|
||||
}
|
||||
case WorkflowOutputEvent outputEvent:
|
||||
Console.WriteLine($"Workflow completed with result: {outputEvent.Data}");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowErrorEvent workflowError)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else if (evt is ExecutorFailedEvent executorFailed)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
case WorkflowErrorEvent workflowError:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
|
||||
case ExecutorFailedEvent executorFailed:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,27 +86,27 @@ public static class Program
|
||||
await checkpointedRun.RestoreCheckpointAsync(savedCheckpoint, CancellationToken.None);
|
||||
await foreach (WorkflowEvent evt in checkpointedRun.WatchStreamAsync())
|
||||
{
|
||||
if (evt is ExecutorCompletedEvent executorCompletedEvt)
|
||||
switch (evt)
|
||||
{
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
}
|
||||
case ExecutorCompletedEvent executorCompletedEvt:
|
||||
Console.WriteLine($"* Executor {executorCompletedEvt.ExecutorId} completed.");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowOutputEvent workflowOutputEvt)
|
||||
{
|
||||
Console.WriteLine($"Workflow completed with result: {workflowOutputEvt.Data}");
|
||||
}
|
||||
case WorkflowOutputEvent workflowOutputEvt:
|
||||
Console.WriteLine($"Workflow completed with result: {workflowOutputEvt.Data}");
|
||||
break;
|
||||
|
||||
if (evt is WorkflowErrorEvent workflowError)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else if (evt is ExecutorFailedEvent executorFailed)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
case WorkflowErrorEvent workflowError:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine(workflowError.Exception?.ToString() ?? "Unknown workflow error occurred.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
|
||||
case ExecutorFailedEvent executorFailed:
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Executor '{executorFailed.ExecutorId}' failed with {(executorFailed.Data == null ? "unknown error" : $"exception {executorFailed.Data}")}.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user