mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* [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
40 lines
1.6 KiB
C#
40 lines
1.6 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Execution;
|
|
|
|
internal static class AsyncRunHandleExtensions
|
|
{
|
|
public static async ValueTask<StreamingRun> EnqueueAndStreamAsync<TInput>(this AsyncRunHandle runHandle, TInput input, CancellationToken cancellationToken = default)
|
|
{
|
|
await runHandle.EnqueueMessageAsync(input, cancellationToken).ConfigureAwait(false);
|
|
return new(runHandle);
|
|
}
|
|
|
|
public static async ValueTask<StreamingRun> EnqueueUntypedAndStreamAsync(this AsyncRunHandle runHandle, object input, CancellationToken cancellationToken = default)
|
|
{
|
|
await runHandle.EnqueueMessageUntypedAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
|
return new(runHandle);
|
|
}
|
|
|
|
public static async ValueTask<Run> EnqueueAndRunAsync<TInput>(this AsyncRunHandle runHandle, TInput input, CancellationToken cancellationToken = default)
|
|
{
|
|
await runHandle.EnqueueMessageAsync(input, cancellationToken).ConfigureAwait(false);
|
|
Run run = new(runHandle);
|
|
|
|
await run.RunToNextHaltAsync(cancellationToken).ConfigureAwait(false);
|
|
return run;
|
|
}
|
|
|
|
public static async ValueTask<Run> EnqueueUntypedAndRunAsync(this AsyncRunHandle runHandle, object input, CancellationToken cancellationToken = default)
|
|
{
|
|
await runHandle.EnqueueMessageUntypedAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
|
Run run = new(runHandle);
|
|
|
|
await run.RunToNextHaltAsync(cancellationToken).ConfigureAwait(false);
|
|
return run;
|
|
}
|
|
}
|