diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs index 3399356295d..5c745721ee2 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs @@ -9,6 +9,7 @@ using Microsoft.Agents.AI.Workflows.Declarative.ObjectModel; using Microsoft.Agents.AI.Workflows.Declarative.PowerFx; using Microsoft.Agents.ObjectModel; +using Microsoft.Extensions.Logging; namespace Microsoft.Agents.AI.Workflows.Declarative.Interpreter; @@ -27,6 +28,7 @@ internal static class Steps public static string Restart(string actionId) => $"{actionId}_{nameof(Restart)}"; } + private readonly ILogger _logger; private readonly Executor _rootAction; private readonly WorkflowModel> _workflowModel; private readonly DeclarativeWorkflowOptions _workflowOptions; @@ -37,6 +39,7 @@ public WorkflowActionVisitor( WorkflowFormulaState state, DeclarativeWorkflowOptions options) { + this._logger = options.LoggerFactory.CreateLogger(); this._rootAction = rootAction; this._workflowModel = new WorkflowModel>((IModeledAction)rootAction); this._workflowOptions = options; @@ -650,6 +653,7 @@ private static string GetParentId(BotElement item) => private void NotSupported(DialogAction item) { Debug.WriteLine($"> UNKNOWN: {new string('\t', this._workflowModel.GetDepth(item.GetParentId()))}{FormatItem(item)} => {FormatParent(item)}"); + this._logger.LogWarning("Unsupported action skipped: {ActionType} ({ActionId}).", item.GetType().Name, item.GetId()); this.HasUnsupportedActions = true; } diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs index f9789c7f49d..8f9fbf34cf4 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs @@ -13,8 +13,10 @@ using Microsoft.Agents.ObjectModel; using Microsoft.Extensions.AI; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using Microsoft.PowerFx.Types; using Moq; +using Shared.UnitTests; using Xunit.Sdk; namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests; @@ -524,6 +526,36 @@ public void UnsupportedAction(Type type) Assert.True(visitor.HasUnsupportedActions); } + [Fact] + public void UnsupportedActionLogsWarning() + { + SearchKnowledgeSources.Builder unsupportedAction = new() { Id = "action_bad" }; + AdaptiveDialog.Builder dialogBuilder = + new() + { + BeginDialog = + new OnActivity.Builder() + { + Id = "anything", + Actions = [unsupportedAction] + } + }; + AdaptiveDialog dialog = dialogBuilder.Build(); + + WorkflowFormulaState state = new(RecalcEngineFactory.Create()); + Mock mockAgentProvider = CreateMockProvider("1"); + CapturingLoggerFactory loggerFactory = new(); + DeclarativeWorkflowOptions options = new(mockAgentProvider.Object) { LoggerFactory = loggerFactory }; + WorkflowActionVisitor visitor = new(new DeclarativeWorkflowExecutor(WorkflowActionVisitor.Steps.Root("anything"), options, state, (message) => DeclarativeWorkflowBuilder.DefaultTransform(message)), state, options); + WorkflowElementWalker walker = new(visitor); + walker.Visit(dialog); + + Assert.True(visitor.HasUnsupportedActions); + (LogLevel Level, string Message) warning = Assert.Single(loggerFactory.Entries, entry => entry.Level == LogLevel.Warning); + Assert.Contains(nameof(SearchKnowledgeSources), warning.Message, StringComparison.Ordinal); + Assert.Contains("action_bad", warning.Message, StringComparison.Ordinal); + } + [Theory] [InlineData("CaseInsensitive.yaml", "end_when_match")] [InlineData("ClearAllVariables.yaml", "clear_all")] diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj index 3057430a034..0569a4fa3ea 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj @@ -2,6 +2,7 @@ true + true true