diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs index eeeaf63bc8..a771f89878 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilderExtensions.cs @@ -114,7 +114,11 @@ public static class WorkflowBuilderExtensions Func predicate = WorkflowBuilder.CreateConditionFunc((Func)IsAllowedType)!; +#if NET6_0_OR_GREATER if (targets.TryGetNonEnumeratedCount(out int count) && count == 1) +#else + if (targets is ICollection { Count: 1 }) +#endif { return builder.AddEdge(source, Throw.IfNull(targets.First(), nameof(targets)), predicate); }