diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs index 3fa17a34bb..7b9b428871 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs @@ -206,6 +206,14 @@ internal sealed class TurnTrackingStartExecutor : ChatProtocolExecutor } } +public class NonChatProtocolExecutor() : Executor(nameof(NonChatProtocolExecutor)) +{ + public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default) + { + return default; + } +} + public class WorkflowHostSmokeTests : AIAgentHostingExecutorTestsBase { private sealed class AlwaysFailsAIAgent(bool failByThrowing) : AIAgent @@ -732,6 +740,25 @@ public class WorkflowHostSmokeTests : AIAgentHostingExecutorTestsBase .BeEmpty(); } + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task Test_AsAgent_FailsWhenNotChatProtocolAsync(bool runAsync) + { + // Arrange + NonChatProtocolExecutor executor = new(); + executor.DescribeProtocol().IsChatProtocol().Should().BeFalse(); + + Workflow workflow = new WorkflowBuilder(executor).Build(); + AIAgent workflowAsAgent = workflow.AsAIAgent(); + + Func action = runAsync + ? () => workflowAsAgent.RunStreamingAsync().ToAgentResponseAsync() + : () => workflowAsAgent.RunAsync(); + + await action.Should().ThrowAsync(); + } + private async Task Run_AsAgent_OutgoingMessagesInHistoryAsync(Workflow workflow, bool runAsync) { // Arrange