AIAgentBuilder Class

Definition

Provides a builder for creating pipelines of AIAgents.

public sealed class AIAgentBuilder
type AIAgentBuilder = class
Public NotInheritable Class AIAgentBuilder
Inheritance
AIAgentBuilder

Constructors

Name Description
AIAgentBuilder(AIAgent)

Initializes a new instance of the AIAgentBuilder class.

AIAgentBuilder(Func<IServiceProvider,AIAgent>)

Initializes a new instance of the AIAgentBuilder class.

Methods

Name Description
Build(IServiceProvider)

Builds an AIAgent that represents the entire pipeline.

Use(Func<AIAgent,AIAgent>)

Adds a factory for an intermediate agent to the agent pipeline.

Use(Func<AIAgent,IServiceProvider,AIAgent>)

Adds a factory for an intermediate agent to the agent pipeline.

Use(Func<IEnumerable<ChatMessage>,AgentSession,AgentRunOptions, AIAgent,CancellationToken,Task<AgentResponse>>, Func<IEnumerable<ChatMessage>, AgentSession,AgentRunOptions,AIAgent,CancellationToken,IAsyncEnumerable<AgentResponseUpdate>>)

Adds to the agent pipeline an anonymous delegating agent based on a delegate that provides an implementation for both RunAsync(IEnumerable<ChatMessage>, AgentSession, AgentRunOptions, CancellationToken) and RunStreamingAsync(IEnumerable<ChatMessage>, AgentSession, AgentRunOptions, CancellationToken).

Use(Func<IEnumerable<ChatMessage>,AgentSession,AgentRunOptions, Func<IEnumerable<ChatMessage>,AgentSession,AgentRunOptions,CancellationToken, Task>,CancellationToken,Task>)

Adds to the agent pipeline an anonymous delegating agent based on a delegate that provides an implementation for both RunAsync(IEnumerable<ChatMessage>, AgentSession, AgentRunOptions, CancellationToken) and RunStreamingAsync(IEnumerable<ChatMessage>, AgentSession, AgentRunOptions, CancellationToken).

UseAIContextProviders(MessageAIContextProvider[])

Adds one or more MessageAIContextProvider instances to the agent pipeline, enabling message enrichment for any AIAgent.

Extension Methods

Name Description
Use(AIAgentBuilder, Func<AIAgent,FunctionInvocationContext,Func<FunctionInvocationContext, CancellationToken,ValueTask<Object>>,CancellationToken,ValueTask<Object>>)

Adds function invocation callbacks to the AIAgent pipeline that intercepts and processes AIFunction calls.

UseLogging(AIAgentBuilder, ILoggerFactory, Action<LoggingAgent>)

Adds logging to the agent pipeline, enabling detailed observability of agent operations.

UseOpenTelemetry(AIAgentBuilder, String, Action<OpenTelemetryAgent>)

Adds OpenTelemetry instrumentation to the agent pipeline, enabling comprehensive observability for agent operations.

UseToolApproval(AIAgentBuilder, ToolApprovalAgentOptions)

Adds tool approval middleware to the agent pipeline, enabling "don't ask again" approval behavior.

WithPurview(AIAgentBuilder, TokenCredential, PurviewSettings, ILogger, IDistributedCache)

Adds Purview capabilities to an AIAgentBuilder.

Applies to