// Copyright (c) Microsoft. All rights reserved. using Microsoft.Agents.AI.Workflows; namespace SingleAgent; internal sealed class ConcurrentStartExecutor() : Executor("ConcurrentStartExecutor") { public override ValueTask HandleAsync(string message, IWorkflowContext context, CancellationToken cancellationToken = default) { // do some initial parsing and validation of the message. // Return a polished version ith additional metadta. if (!message.StartsWith("Query for the agent:", StringComparison.OrdinalIgnoreCase)) { message = "Query for the agent: " + message; } return ValueTask.FromResult(message); } } internal sealed class ResultAggregationExecutor() : Executor("ResultAggregationExecutor") { /// /// 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 string aggregatedResponse = string.Join("\n---\n", message); return ValueTask.FromResult($"Aggregated {message.Length} responses:\n{aggregatedResponse}"); } }