Table of Contents

Class ToolApprovalRequestEventArgs

Namespace
LMKit.TextGeneration.Events
Assembly
LM-Kit.NET.dll

Raised when a tool invocation requires user approval before execution.

public sealed class ToolApprovalRequestEventArgs : EventArgs
Inheritance
ToolApprovalRequestEventArgs
Inherited Members

Examples

agent.ToolApprovalRequired += (sender, args) =>
{
    Console.WriteLine($"Tool '{args.ToolCall.Name}' requires approval.");
    Console.WriteLine($"Risk: {args.RiskLevel}, Side effect: {args.SideEffect}");
    Console.Write("Allow? (y/n): ");
    args.Approved = Console.ReadLine()?.Trim().ToLower() == "y";
};

Remarks

This event is raised when the ToolPermissionPolicy evaluates a tool call and determines that approval is required (either via Always, RequireApproval(params string[]), or category-level approval rules).

The handler must set Approved to true to allow execution, or leave it as false (default) to deny the tool call.

Properties

Approved

Gets or sets whether the tool call is approved for execution. Default is false. Set to true to allow the tool to execute.

DenialReason

Gets or sets an optional denial reason to include in the result returned to the model when the tool call is not approved.

RiskLevel

Gets the risk level of the tool, or null if the tool does not implement IToolMetadata.

SideEffect

Gets the side effect classification of the tool, or null if the tool does not implement IToolMetadata.

Tool

Gets the tool instance that would be invoked.

ToolCall

Gets the tool call that requires approval.