Files
agent-framework/dotnet/src/Microsoft.Agents.Workflows/Execution/InputEdgeRunner.cs
T
Jacob Alber baaa9c0aee .NET: feat: Improve Support for AIAgent-as-Executor (#432)
* feat: Support Executor-targeted messages

This adds support for only sending a message to a given executor. Messages will still only route through connected edges.

* feat: Support sending all valid input types after starting a run

* feat: Normalize AIAgent-as-Executor Message Protocol to use MEAI types
2025-08-19 20:04:03 +00:00

42 lines
1.4 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.Workflows.Execution;
internal class InputEdgeRunner(IRunnerContext runContext, string sinkId)
: EdgeRunner<string>(runContext, sinkId)
{
public IWorkflowContext WorkflowContext { get; } = runContext.Bind(sinkId);
public static InputEdgeRunner ForPort(IRunnerContext runContext, InputPort port)
{
Throw.IfNull(port);
// The port is an input port, so we can use the port's ID as the sink ID.
return new InputEdgeRunner(runContext, port.Id);
}
private async ValueTask<Executor> FindExecutorAsync()
{
return await this.RunContext.EnsureExecutorAsync(this.EdgeData).ConfigureAwait(false);
}
public async ValueTask<object?> ChaseAsync(MessageEnvelope envelope)
{
Executor target = await this.FindExecutorAsync().ConfigureAwait(false);
if (target.CanHandle(envelope.MessageType))
{
return await target.ExecuteAsync(envelope.Message, envelope.MessageType, this.WorkflowContext)
.ConfigureAwait(false);
}
// TODO: Throw instead? / Log
Debug.WriteLine($"Executor {target.Id} cannot handle message of type {envelope.MessageType.FullName}. Dropping.");
return null;
}
}