From 859ac0939dfc3c77c8475e6f04e2285b0e9ee2fc Mon Sep 17 00:00:00 2001 From: Shyju Krishnankutty Date: Fri, 23 Jan 2026 07:48:31 -0800 Subject: [PATCH] Minor cleanup --- ...urrentStartExecutor.cs => PrepareQuery.cs} | 14 +--- .../10_WorkflowConcurrent/Program.cs | 4 +- .../ResponseRouterExecutor.cs | 27 ------ .../SurveyResponseParserExecutor.cs | 82 ------------------- .../OrderIdParserExecutor.cs | 1 - 5 files changed, 5 insertions(+), 123 deletions(-) rename dotnet/samples/AzureFunctions/10_WorkflowConcurrent/{ConcurrentStartExecutor.cs => PrepareQuery.cs} (53%) delete mode 100644 dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ResponseRouterExecutor.cs delete mode 100644 dotnet/samples/AzureFunctions/10_WorkflowConcurrent/SurveyResponseParserExecutor.cs diff --git a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ConcurrentStartExecutor.cs b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/PrepareQuery.cs similarity index 53% rename from dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ConcurrentStartExecutor.cs rename to dotnet/samples/AzureFunctions/10_WorkflowConcurrent/PrepareQuery.cs index de233d60a6..4fd9c9acef 100644 --- a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ConcurrentStartExecutor.cs +++ b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/PrepareQuery.cs @@ -4,7 +4,7 @@ using Microsoft.Agents.AI.Workflows; namespace SingleAgent; -internal sealed class ConcurrentStartExecutor() : Executor("ConcurrentStartExecutor") +internal sealed class PrepareQuery() : Executor("PrepareQuery") { public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default) { @@ -19,19 +19,11 @@ internal sealed class ConcurrentStartExecutor() : Executor("Conc } } -internal sealed class ResultAggregationExecutor() : Executor("ResultAggregationExecutor") +internal sealed class ResultAggregator() : Executor("ResultAggregator") { - /// - /// Handles incoming messages from the agents and aggregates their responses. - /// - /// The messages from the parallel agents. - /// Workflow context for accessing workflow services and adding events. - /// The to monitor for cancellation requests. - /// The default is . - /// A task representing the asynchronous operation. public override ValueTask HandleAsync(string[] message, IWorkflowContext context, CancellationToken cancellationToken = default) { - // Aggregate all responses from parallel executors + // Aggregate all responses from parallel executors. string aggregatedResponse = string.Join("\n---\n", message); return ValueTask.FromResult($"Aggregated {message.Length} responses:\n{aggregatedResponse}"); } diff --git a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/Program.cs b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/Program.cs index a1435fd39d..8518e7673a 100644 --- a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/Program.cs +++ b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/Program.cs @@ -27,8 +27,8 @@ AzureOpenAIClient client = !string.IsNullOrEmpty(azureOpenAiKey) AIAgent physicist = client.GetChatClient(deploymentName).CreateAIAgent("You are an expert in physics. You answer questions from a physics perspective.", "Physicist"); AIAgent chemist = client.GetChatClient(deploymentName).CreateAIAgent("You are an expert in chemistry. You answer questions from a chemistry perspective.", "Chemist"); -var startExecutor = new ConcurrentStartExecutor(); -var aggregationExecutor = new ResultAggregationExecutor(); +var startExecutor = new PrepareQuery(); +var aggregationExecutor = new ResultAggregator(); var workflow = new WorkflowBuilder(startExecutor) .WithName("ExpertReview") diff --git a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ResponseRouterExecutor.cs b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ResponseRouterExecutor.cs deleted file mode 100644 index c4c58c5a60..0000000000 --- a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/ResponseRouterExecutor.cs +++ /dev/null @@ -1,27 +0,0 @@ -//// Copyright (c) Microsoft. All rights reserved. - -//using Microsoft.Agents.AI.Workflows; - -//namespace SingleAgent; - -///// -///// Routes survey responses to appropriate teams based on rating and category. -///// -//public sealed class ResponseRouterExecutor() : Executor("ResponseRouterExecutor") -//{ -// public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default) -// { -// if (message.Contains("billing", StringComparison.OrdinalIgnoreCase)) -// { -// return ValueTask.FromResult("Routed to Billing Team"); -// } -// else if (message.Contains("technical", StringComparison.OrdinalIgnoreCase)) -// { -// return ValueTask.FromResult("Routed to Technical Support Team"); -// } -// else -// { -// return ValueTask.FromResult("Routed to General Support Team"); -// } -// } -//} diff --git a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/SurveyResponseParserExecutor.cs b/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/SurveyResponseParserExecutor.cs deleted file mode 100644 index 4b3344a8c1..0000000000 --- a/dotnet/samples/AzureFunctions/10_WorkflowConcurrent/SurveyResponseParserExecutor.cs +++ /dev/null @@ -1,82 +0,0 @@ -//// Copyright (c) Microsoft. All rights reserved. - -//using System.Text.Json; -//using System.Text.RegularExpressions; -//using Microsoft.Agents.AI.Workflows; - -//namespace SingleAgent; - -///// -///// This executor parses survey responses and produces structured output. -///// Example input: "Rating: 8. The app is good but checkout process is confusing." -///// -//[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1812:Avoid uninstantiated internal classes", Justification = "Instantiated by workflow framework")] -//internal sealed partial class SurveyResponseParserExecutor() : Executor("SurveyResponseParserExecutor") -//{ -// private static readonly JsonSerializerOptions s_jsonOptions = new() -// { -// WriteIndented = true -// }; - -// [GeneratedRegex(@"Rating:\s*(\d+)", RegexOptions.IgnoreCase)] -// private static partial Regex RatingRegex(); - -// public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default) -// { -// SurveyResponse response = this.ParseSurveyResponse(message); -// string jsonResult = JsonSerializer.Serialize(response, s_jsonOptions); -// return ValueTask.FromResult(jsonResult); -// } - -// private SurveyResponse ParseSurveyResponse(string message) -// { -// // Parse the message to extract rating and comment -// int? rating = null; -// string comment = message; - -// // Try to extract rating using pattern "Rating: {number}" -// Match ratingMatch = RatingRegex().Match(message); -// if (ratingMatch.Success && int.TryParse(ratingMatch.Groups[1].Value, out int parsedRating)) -// { -// rating = parsedRating; - -// // Remove the rating part from the message to get the comment -// // Find the position after the rating number -// int ratingEndIndex = ratingMatch.Index + ratingMatch.Length; - -// // Skip any separators (period, comma, dash, etc.) and whitespace -// while (ratingEndIndex < message.Length && -// (char.IsWhiteSpace(message[ratingEndIndex]) || -// message[ratingEndIndex] == '.' || -// message[ratingEndIndex] == ',' || -// message[ratingEndIndex] == '-')) -// { -// ratingEndIndex++; -// } - -// if (ratingEndIndex < message.Length) -// { -// comment = message[ratingEndIndex..].Trim(); -// } -// else -// { -// comment = string.Empty; -// } -// } - -// // Create and return the structured response -// return new SurveyResponse -// { -// Rating = rating, -// Comment = comment, -// OriginalMessage = message -// }; -// } - -// private sealed class SurveyResponse -// { -// public int? Rating { get; set; } -// public string Comment { get; set; } = string.Empty; -// public string OriginalMessage { get; set; } = string.Empty; -// } -//} diff --git a/dotnet/samples/AzureFunctions/11_WorkflowSharedState/OrderIdParserExecutor.cs b/dotnet/samples/AzureFunctions/11_WorkflowSharedState/OrderIdParserExecutor.cs index d79455ff0d..a53e64b73c 100644 --- a/dotnet/samples/AzureFunctions/11_WorkflowSharedState/OrderIdParserExecutor.cs +++ b/dotnet/samples/AzureFunctions/11_WorkflowSharedState/OrderIdParserExecutor.cs @@ -69,7 +69,6 @@ internal sealed class EmailSenderExecutor() : Executor("EmailSend SharedStateConstants.MessageScope, cancellationToken); - // Combine with the input message return storedMessage is not null ? $"From state: [{storedMessage}] | Input: [{message.Id}]" : $"No state found | Input: [{message.Id}]";