DurableAgentsOptionsExtensions.AddAIAgentFactory Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| AddAIAgentFactory(DurableAgentsOptions, String, Func<IServiceProvider,AIAgent>, Action<FunctionsAgentOptions>) |
Registers an AI agent factory with the specified name and optional configuration in the provided DurableAgentsOptions instance. |
| AddAIAgentFactory(DurableAgentsOptions, String, Func<IServiceProvider,AIAgent>, Boolean, Boolean) |
Registers an AI agent factory with the specified name and configures trigger options for the agent. |
AddAIAgentFactory(DurableAgentsOptions, String, Func<IServiceProvider,AIAgent>, Action<FunctionsAgentOptions>)
Registers an AI agent factory with the specified name and optional configuration in the provided DurableAgentsOptions instance.
public static Microsoft.Agents.AI.DurableTask.DurableAgentsOptions AddAIAgentFactory(this Microsoft.Agents.AI.DurableTask.DurableAgentsOptions options, string name, Func<IServiceProvider,Microsoft.Agents.AI.AIAgent> factory, Action<Microsoft.Agents.AI.Hosting.AzureFunctions.FunctionsAgentOptions>? configure);
static member AddAIAgentFactory : Microsoft.Agents.AI.DurableTask.DurableAgentsOptions * string * Func<IServiceProvider, Microsoft.Agents.AI.AIAgent> * Action<Microsoft.Agents.AI.Hosting.AzureFunctions.FunctionsAgentOptions> -> Microsoft.Agents.AI.DurableTask.DurableAgentsOptions
<Extension()>
Public Function AddAIAgentFactory (options As DurableAgentsOptions, name As String, factory As Func(Of IServiceProvider, AIAgent), configure As Action(Of FunctionsAgentOptions)) As DurableAgentsOptions
Parameters
- options
- DurableAgentsOptions
The DurableAgentsOptions instance to which the AI agent factory will be added. Cannot be null.
- name
- String
The unique name used to identify the AI agent factory. Cannot be null.
- factory
- Func<IServiceProvider,AIAgent>
A delegate that creates an AIAgent instance using the provided IServiceProvider. Cannot be null.
- configure
- Action<FunctionsAgentOptions>
An optional action to configure FunctionsAgentOptions for the agent factory. If null, default options are used.
Returns
The updated DurableAgentsOptions instance containing the registered AI agent factory.
Remarks
If an agent factory with the same name already exists, its configuration will be replaced. This method enables custom agent registration and configuration for use in durable agent scenarios.
Applies to
AddAIAgentFactory(DurableAgentsOptions, String, Func<IServiceProvider,AIAgent>, Boolean, Boolean)
Registers an AI agent factory with the specified name and configures trigger options for the agent.
public static Microsoft.Agents.AI.DurableTask.DurableAgentsOptions AddAIAgentFactory(this Microsoft.Agents.AI.DurableTask.DurableAgentsOptions options, string name, Func<IServiceProvider,Microsoft.Agents.AI.AIAgent> factory, bool enableHttpTrigger, bool enableMcpToolTrigger);
static member AddAIAgentFactory : Microsoft.Agents.AI.DurableTask.DurableAgentsOptions * string * Func<IServiceProvider, Microsoft.Agents.AI.AIAgent> * bool * bool -> Microsoft.Agents.AI.DurableTask.DurableAgentsOptions
<Extension()>
Public Function AddAIAgentFactory (options As DurableAgentsOptions, name As String, factory As Func(Of IServiceProvider, AIAgent), enableHttpTrigger As Boolean, enableMcpToolTrigger As Boolean) As DurableAgentsOptions
Parameters
- options
- DurableAgentsOptions
The options object to which the AI agent factory will be added. Cannot be null.
- name
- String
The unique name used to identify the AI agent factory. Cannot be null.
- factory
- Func<IServiceProvider,AIAgent>
A delegate that creates an instance of the AI agent using the provided service provider. Cannot be null.
- enableHttpTrigger
- Boolean
true to enable the HTTP trigger for the agent; otherwise, false.
- enableMcpToolTrigger
- Boolean
true to enable the MCP tool trigger for the agent; otherwise, false.
Returns
The same DurableAgentsOptions instance, allowing for method chaining.
Remarks
If both triggers are disabled, the agent will not be accessible via HTTP or MCP tool endpoints. This method can be used to register multiple agent factories with different configurations.