mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
b25b0af49b
* refactor: Unify ExecutorIsh and ExecutorRegistration => ExecutorBinding * Switch to more modern Record type-tree for Sum Types * Unify APIs for getting ExecutorBinding * Fix an issue where workflows consisting entirely of cross-run shareable executors which are not instance-resettable do not properly clear state when running non-concurrently. * feat: Simplify function-to-executor pattern * refactor: Normalize API naming
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Shared.Diagnostics;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows;
|
|
|
|
/// <summary>
|
|
/// Represents the workflow binding details for a shared executor instance, including configuration options
|
|
/// for event emission.
|
|
/// </summary>
|
|
/// <param name="ExecutorInstance">The executor instance to bind. Cannot be null.</param>
|
|
public record ExecutorInstanceBinding(Executor ExecutorInstance)
|
|
: ExecutorBinding(Throw.IfNull(ExecutorInstance).Id,
|
|
(_) => new(ExecutorInstance),
|
|
ExecutorInstance.GetType(),
|
|
ExecutorInstance)
|
|
{
|
|
/// <inheritdoc/>
|
|
public override bool SupportsConcurrentSharedExecution => this.ExecutorInstance.IsCrossRunShareable;
|
|
|
|
/// <inheritdoc/>
|
|
public override bool SupportsResetting => this.ExecutorInstance is IResettableExecutor;
|
|
|
|
/// <inheritdoc/>
|
|
public override bool IsSharedInstance => true;
|
|
|
|
/// <inheritdoc/>
|
|
protected override async ValueTask<bool> ResetCoreAsync()
|
|
{
|
|
if (this.ExecutorInstance is IResettableExecutor resettable)
|
|
{
|
|
await resettable.ResetAsync().ConfigureAwait(false);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|