ToolApprovalAgentBuilderExtensions.UseToolApproval Method

Definition

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

public static Microsoft.Agents.AI.AIAgentBuilder UseToolApproval(this Microsoft.Agents.AI.AIAgentBuilder builder, Microsoft.Agents.AI.ToolApprovalAgentOptions? options = default);
static member UseToolApproval : Microsoft.Agents.AI.AIAgentBuilder * Microsoft.Agents.AI.ToolApprovalAgentOptions -> Microsoft.Agents.AI.AIAgentBuilder
<Extension()>
Public Function UseToolApproval (builder As AIAgentBuilder, Optional options As ToolApprovalAgentOptions = Nothing) As AIAgentBuilder

Parameters

builder
AIAgentBuilder

The AIAgentBuilder to which tool approval support will be added.

options
ToolApprovalAgentOptions

Optional ToolApprovalAgentOptions for configuring serialization and auto-approval rules. When null, default settings are used.

Returns

The AIAgentBuilder with tool approval middleware added, enabling method chaining.

Exceptions

builder is null.

Remarks

The ToolApprovalAgent middleware intercepts tool approval flows between the caller and the inner agent. When a caller responds with an AlwaysApproveToolApprovalResponseContent, the middleware records a standing approval rule so that future matching tool calls are auto-approved without user interaction.

Applies to