Skip to content

InMemoryToolApprovalRuleStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

A store that keeps persistent approval rules in process memory.

public sealed class InMemoryToolApprovalRuleStore : IToolApprovalRuleStore

objectInMemoryToolApprovalRuleStore

IToolApprovalRuleStore

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Limits: process lifetime and a single node. When the application restarts, “do not ask again” rules are lost and approval is requested again. This is the safe behavior. Use AgentPrism.PostgreSql in production.

public InMemoryToolApprovalRuleStore()

AddAsync(ToolApprovalRule, CancellationToken)

Section titled “ AddAsync(ToolApprovalRule, CancellationToken)”

Adds a rule. When the same triple and argument fingerprint is already stored, the existing rule is returned and no new record is opened.

public ValueTask<ToolApprovalRule> AddAsync(ToolApprovalRule rule, CancellationToken cancellationToken = default)

rule ToolApprovalRule

The rule to add.

cancellationToken CancellationToken

The cancellation token.

ValueTask<ToolApprovalRule>

The persisted rule.

DeleteAsync(string, Guid, CancellationToken)

Section titled “ DeleteAsync(string, Guid, CancellationToken)”

Deletes a rule.

public ValueTask<bool> DeleteAsync(string tenantId, Guid ruleId, CancellationToken cancellationToken = default)

tenantId string

The tenant id. The rule of another tenant cannot be deleted.

ruleId Guid

The rule id.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true when the rule was deleted.

Lists the rules of a tenant.

public ValueTask<IReadOnlyList<ToolApprovalRule>> ListAsync(string tenantId, CancellationToken cancellationToken = default)

tenantId string

The tenant id.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<ToolApprovalRule>>

The rules, newest first.