Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<Func<object?, bool>> _workflowModel;
private readonly DeclarativeWorkflowOptions _workflowOptions;
Expand All @@ -37,6 +39,7 @@ public WorkflowActionVisitor(
WorkflowFormulaState state,
DeclarativeWorkflowOptions options)
{
this._logger = options.LoggerFactory.CreateLogger<WorkflowActionVisitor>();
this._rootAction = rootAction;
this._workflowModel = new WorkflowModel<Func<object?, bool>>((IModeledAction)rootAction);
this._workflowOptions = options;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ResponseAgentProvider> mockAgentProvider = CreateMockProvider("1");
CapturingLoggerFactory loggerFactory = new();
DeclarativeWorkflowOptions options = new(mockAgentProvider.Object) { LoggerFactory = loggerFactory };
WorkflowActionVisitor visitor = new(new DeclarativeWorkflowExecutor<string>(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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<InjectSharedIntegrationTestCode>true</InjectSharedIntegrationTestCode>
<InjectSharedUnitTestCode>true</InjectSharedUnitTestCode>
<InjectIsExternalInitOnLegacy>true</InjectIsExternalInitOnLegacy>
</PropertyGroup>

Expand Down
Loading