mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: Update Workflow Input/Output Redesign (#881)
* feat: Make Executor id field mandatory When checkpointing is involved, it is critical to keep executor ids consistent between runs, even when recreating a new object tree for the workflow. The default id-setting mechanism generated a guid for part of the id, making it not work when restoring from a checkpoint. This change prevents this situation from arising. * feat: Enable running untyped Workflows With the change to enable delay-instantiation of executors and support for async Executor factory methods, we must instantiate the starting executor to know what are the valid input types for the workflow. To avoid forcing instantiation every time, and to better support workflows with multiple input types, we enable support for build and interacting with the base Workflow type without type annotations, and remove the requirement to know a valid input type when initiating a run. * feat: Support Output from any executor and multiple outputs.
This commit is contained in:
@@ -8,7 +8,7 @@ using Moq;
|
||||
|
||||
namespace Microsoft.Agents.Workflows.UnitTests;
|
||||
|
||||
public class BaseTestExecutor<TActual> : ReflectingExecutor<TActual> where TActual : ReflectingExecutor<TActual>
|
||||
public class BaseTestExecutor<TActual>(string id) : ReflectingExecutor<TActual>(id) where TActual : ReflectingExecutor<TActual>
|
||||
{
|
||||
protected void OnInvokedHandler() => this.InvokedHandler = true;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BaseTestExecutor<TActual> : ReflectingExecutor<TActual> where TActu
|
||||
}
|
||||
}
|
||||
|
||||
public class DefaultHandler : BaseTestExecutor<DefaultHandler>, IMessageHandler<object>
|
||||
public class DefaultHandler() : BaseTestExecutor<DefaultHandler>(nameof(DefaultHandler)), IMessageHandler<object>
|
||||
{
|
||||
public ValueTask HandleAsync(object message, IWorkflowContext context)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ public class DefaultHandler : BaseTestExecutor<DefaultHandler>, IMessageHandler<
|
||||
} = (message, context) => default;
|
||||
}
|
||||
|
||||
public class TypedHandler<TInput> : BaseTestExecutor<TypedHandler<TInput>>, IMessageHandler<TInput>
|
||||
public class TypedHandler<TInput>() : BaseTestExecutor<TypedHandler<TInput>>(nameof(TypedHandler<TInput>)), IMessageHandler<TInput>
|
||||
{
|
||||
public ValueTask HandleAsync(TInput message, IWorkflowContext context)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ public class TypedHandler<TInput> : BaseTestExecutor<TypedHandler<TInput>>, IMes
|
||||
} = (message, context) => default;
|
||||
}
|
||||
|
||||
public class TypedHandlerWithOutput<TInput, TResult> : BaseTestExecutor<TypedHandlerWithOutput<TInput, TResult>>, IMessageHandler<TInput, TResult>
|
||||
public class TypedHandlerWithOutput<TInput, TResult>() : BaseTestExecutor<TypedHandlerWithOutput<TInput, TResult>>(nameof(TypedHandlerWithOutput<TInput, TResult>)), IMessageHandler<TInput, TResult>
|
||||
{
|
||||
public ValueTask<TResult> HandleAsync(TInput message, IWorkflowContext context)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user