// Copyright (c) Microsoft. All rights reserved. using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.Agents.AI.Workflows.Declarative.Extensions; using Microsoft.Extensions.AI; namespace Microsoft.Agents.AI.Workflows.Declarative.Kit; /// /// Base class for agent invokcation. /// /// The executor id /// Session to support formula expressions. /// Provider for accessing and manipulating agents and conversations. public abstract class AgentExecutor(string id, FormulaSession session, ResponseAgentProvider agentProvider) : ActionExecutor(id, session) { /// /// Invokes an agent using the provided . /// /// The workflow execution context providing messaging and state services. /// The name or identifier of the agent. /// The identifier of the conversation. /// Send the agent's response as workflow output. (default: true). /// Optional messages to add to the conversation prior to invocation. /// A token that can be used to observe cancellation. /// protected ValueTask InvokeAgentAsync( IWorkflowContext context, string agentName, string? conversationId, bool autoSend, IEnumerable? inputMessages = null, CancellationToken cancellationToken = default) => agentProvider.InvokeAgentAsync(this.Id, context, agentName, conversationId, autoSend, inputMessages, inputArguments: null, cancellationToken); }