mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Clarify edge helper target validation
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/af831ee2-0a99-4427-9ffd-a3b5022c1b3b Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
096381d1c3
commit
24d1effb52
@@ -2,7 +2,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Shared.Diagnostics;
|
||||
|
||||
namespace Microsoft.Agents.AI.Workflows;
|
||||
@@ -58,10 +57,9 @@ public static class WorkflowBuilderExtensions
|
||||
{
|
||||
Throw.IfNull(builder);
|
||||
Throw.IfNull(source);
|
||||
Throw.IfNull(targets);
|
||||
|
||||
Func<object?, bool> predicate = WorkflowBuilder.CreateConditionFunc<TMessage>(IsAllowedTypeAndMatchingCondition)!;
|
||||
List<ExecutorBinding> targetList = targets.Select(target => Throw.IfNull(target, nameof(targets))).ToList();
|
||||
List<ExecutorBinding> targetList = ValidateTargets(targets);
|
||||
|
||||
if (targetList.Count == 1)
|
||||
{
|
||||
@@ -102,10 +100,9 @@ public static class WorkflowBuilderExtensions
|
||||
{
|
||||
Throw.IfNull(builder);
|
||||
Throw.IfNull(source);
|
||||
Throw.IfNull(targets);
|
||||
|
||||
Func<object?, bool> predicate = WorkflowBuilder.CreateConditionFunc<TMessage>((Func<object?, bool>)IsAllowedType)!;
|
||||
List<ExecutorBinding> targetList = targets.Select(target => Throw.IfNull(target, nameof(targets))).ToList();
|
||||
List<ExecutorBinding> targetList = ValidateTargets(targets);
|
||||
|
||||
if (targetList.Count == 1)
|
||||
{
|
||||
@@ -119,6 +116,25 @@ public static class WorkflowBuilderExtensions
|
||||
static bool IsAllowedType(object? message) => message is null;
|
||||
}
|
||||
|
||||
private static List<ExecutorBinding> ValidateTargets(IEnumerable<ExecutorBinding> targets)
|
||||
{
|
||||
Throw.IfNull(targets);
|
||||
|
||||
List<ExecutorBinding> targetList = [];
|
||||
foreach (ExecutorBinding? target in targets)
|
||||
{
|
||||
if (target is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(targets), "Targets collection cannot contain null elements.");
|
||||
}
|
||||
|
||||
targetList.Add(target);
|
||||
}
|
||||
|
||||
Throw.IfNullOrEmpty(targetList, nameof(targets));
|
||||
return targetList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a sequential chain of executors to the workflow, connecting each executor in order so that each is
|
||||
/// executed after the previous one.
|
||||
|
||||
Reference in New Issue
Block a user