Share via


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

AIAgentBuilder(AIAgent)

Initializes a new instance of the AIAgentBuilder class.

AIAgentBuilder(Func<IServiceProvider,AIAgent>)

Initializes a new instance of the AIAgentBuilder class.

Methods

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>,AgentThread,AgentRunOptions, AIAgent,CancellationToken,Task<AgentRunResponse>>, Func<IEnumerable<ChatMessage>, AgentThread,AgentRunOptions,AIAgent,CancellationToken,IAsyncEnumerable<AgentRunResponseUpdate>>)

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

Use(Func<IEnumerable<ChatMessage>,AgentThread,AgentRunOptions, Func<IEnumerable<ChatMessage>,AgentThread,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>, AgentThread, AgentRunOptions, CancellationToken) and RunStreamingAsync(IEnumerable<ChatMessage>, AgentThread, AgentRunOptions, CancellationToken).

Extension Methods

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.

UseOpenTelemetry(AIAgentBuilder, String, Action<OpenTelemetryAgent>)

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

Applies to