mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* feat: Implement Polymorphic Routing * feat: Add support for Send/Yield annotations with basic Executor * Adds annotations to Declarative workflow executors * fix: Address PR Comments * Implicit filter in collection loops * Remove debug / usused / superfluous code * Fix ProtocolBuilder implicit output registrations * Fix logic error in ExecuteRouteGeneratorTests.ClassWithManualConfigureProtocol_DoesNotGenerate * fix: Solidify type checks and send/yield type registrations * fix: Suppress generation of TurnTokens out of AggregateTurnMessagesExecutor * Fixes an issue where ConcurrentEndExecutor is not expecting TurnTokens. * fix: Add ProtocolBuilder support for chained-delegation * Updates Declarative pacakge to rely on chained-delegation Send/Yield registration * Renames DeclarativeActionExectuor's new ExecuteAsync to ExecuteActionAsync to avoid colliding with Executor.ExecutoeAsync * fix: Address PR Comments * Fixes type mapping in FanInEdgeRunner * Fixes and expalins send/yield type registration in FunctionExecutor * fixup: build-break * fix: Add missing SendsMesage declaration to InvokeAzureAgentExecutor
56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Agents.AI.Workflows.Observability;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Execution;
|
|
|
|
internal sealed class DirectEdgeRunner(IRunnerContext runContext, DirectEdgeData edgeData) :
|
|
EdgeRunner<DirectEdgeData>(runContext, edgeData)
|
|
{
|
|
protected internal override async ValueTask<DeliveryMapping?> ChaseEdgeAsync(MessageEnvelope envelope, IStepTracer? stepTracer, CancellationToken cancellationToken)
|
|
{
|
|
using var activity = this.StartActivity();
|
|
activity?
|
|
.SetTag(Tags.EdgeGroupType, nameof(DirectEdgeRunner))
|
|
.SetTag(Tags.MessageSourceId, this.EdgeData.SourceId)
|
|
.SetTag(Tags.MessageTargetId, this.EdgeData.SinkId);
|
|
|
|
if (envelope.TargetId is not null && this.EdgeData.SinkId != envelope.TargetId)
|
|
{
|
|
activity?.SetEdgeRunnerDeliveryStatus(EdgeRunnerDeliveryStatus.DroppedTargetMismatch);
|
|
return null;
|
|
}
|
|
|
|
object message = envelope.Message;
|
|
try
|
|
{
|
|
if (this.EdgeData.Condition is not null && !this.EdgeData.Condition(message))
|
|
{
|
|
activity?.SetEdgeRunnerDeliveryStatus(EdgeRunnerDeliveryStatus.DroppedConditionFalse);
|
|
return null;
|
|
}
|
|
|
|
Type? messageType = await this.GetMessageRuntimeTypeAsync(envelope, stepTracer, cancellationToken)
|
|
.ConfigureAwait(false);
|
|
|
|
Executor target = await this.RunContext.EnsureExecutorAsync(this.EdgeData.SinkId, stepTracer, cancellationToken).ConfigureAwait(false);
|
|
if (CanHandle(target, messageType))
|
|
{
|
|
activity?.SetEdgeRunnerDeliveryStatus(EdgeRunnerDeliveryStatus.Delivered);
|
|
return new DeliveryMapping(envelope, target);
|
|
}
|
|
}
|
|
catch (Exception) when (activity is not null)
|
|
{
|
|
activity.SetEdgeRunnerDeliveryStatus(EdgeRunnerDeliveryStatus.Exception);
|
|
throw;
|
|
}
|
|
|
|
activity?.SetEdgeRunnerDeliveryStatus(EdgeRunnerDeliveryStatus.DroppedTypeMismatch);
|
|
return null;
|
|
}
|
|
}
|