ToolApprovalRuleEvaluator
AgentPrism.Core.dllApplies persistent approval rules to a tool call.
public sealed class ToolApprovalRuleEvaluatorInheritance
Section titled “Inheritance”object ← ToolApprovalRuleEvaluator
Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Integrates with Microsoft Agent Framework’s ToolApprovalAgentOptions.AutoApprovalRules
API. When a rule matches, the call runs without asking the user.
This class protects the tenant boundary. It always reads rules with ITenantContext.TenantId. An approval from one tenant cannot run a call for another tenant.
A store error does not grant approval. If a rule cannot be read, the call is not automatically approved and the system asks the user. This is the safe default.
A code-defined policy runs before the data rules and can
override them. Code is a security boundary; data — writable from the
UI — is not allowed to loosen it. See ToolApprovalContext and
IAgentPrismBuilder.AddToolApprovalPolicy(...).
Constructors
Section titled “Constructors”ToolApprovalRuleEvaluator(IToolApprovalRuleStore, ToolApprovalPolicyRegistry, ITenantContext, ILogger<ToolApprovalRuleEvaluator>)
Section titled “ ToolApprovalRuleEvaluator(IToolApprovalRuleStore, ToolApprovalPolicyRegistry, ITenantContext, ILogger<ToolApprovalRuleEvaluator>)”Initializes a new evaluator.
public ToolApprovalRuleEvaluator(IToolApprovalRuleStore rules, ToolApprovalPolicyRegistry policies, ITenantContext tenantContext, ILogger<ToolApprovalRuleEvaluator> logger)Parameters
Section titled “Parameters”rules IToolApprovalRuleStore
The rule store.
policies ToolApprovalPolicyRegistry
The code-defined policy registry.
tenantContext ITenantContext
The tenant context.
logger ILogger<ToolApprovalRuleEvaluator>
The logger.
Exceptions
Section titled “Exceptions”A dependency is null.
Methods
Section titled “Methods”ComputeArgumentsHash(IDictionary<string, object?>?)
Section titled “ ComputeArgumentsHash(IDictionary<string, object?>?)”Produces a deterministic fingerprint from tool arguments.
public static string ComputeArgumentsHash(IDictionary<string, object?>? arguments)Parameters
Section titled “Parameters”arguments IDictionary<string, object?>?
The call arguments.
Returns
Section titled “Returns”The hexadecimal fingerprint, or an empty string when there are no arguments.
Remarks
Section titled “Remarks”Keys are sorted. Dictionary order can change between runs, and a different fingerprint for the same call would prevent a “do not ask again” rule from matching.
This method does not use JSON serialization. Reflection-based serialization
produces IL2026, and AgentPrism.Core is marked as AOT-compatible.
IsAutoApprovedAsync(string, FunctionCallContent, CancellationToken)
Section titled “ IsAutoApprovedAsync(string, FunctionCallContent, CancellationToken)”Determines whether a call is auto-approved: either a code-defined policy decides so, or — when the policy is silent — a persistent data rule matches.
public ValueTask<bool> IsAutoApprovedAsync(string agentName, FunctionCallContent call, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”agentName string
The agent that makes the call.
call FunctionCallContent
The tool call.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the call is automatically approved.
Remarks
Section titled “Remarks”Code runs first and can override data in both directions: a ToolApprovalPolicyDecision.Required policy forces approval even if a data rule would otherwise auto-approve the call, and ToolApprovalPolicyDecision.NotRequired auto-approves even with no matching data rule. Only ToolApprovalPolicyDecision.Undecided (or no registered policy) falls through to the data rules.