Skip to content

AgentPrismContentGuardBuilderExtensions

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Chain extensions that turn on content inspection.

public static class AgentPrismContentGuardBuilderExtensions

objectAgentPrismContentGuardBuilderExtensions

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

This is an extension method, not a member of IAgentPrismBuilder: adding a member to the interface is a breaking change after release; adding an extension method is not.

AddContentGuard<TGuard>(IAgentPrismBuilder)

Section titled “ AddContentGuard<TGuard>(IAgentPrismBuilder)”

Registers your own IContentGuard implementation.

public static IAgentPrismBuilder AddContentGuard<TGuard>(this IAgentPrismBuilder builder) where TGuard : class, IContentGuard

builder IAgentPrismBuilder

The configuration chain.

IAgentPrismBuilder

The chain, for further configuration.

TGuard

The guard type.

Multiple guards can be registered; all of them run in sequence and the strictest decision wins.

builder.AddAgentPrism()
.AddPatternContentGuard()
.AddContentGuard<CustomerNameGuard>();

ArgumentNullException

builder is null.

AddPatternContentGuard(IAgentPrismBuilder, Action<PatternContentGuardOptions>?)

Section titled “ AddPatternContentGuard(IAgentPrismBuilder, Action<PatternContentGuardOptions>?)”

Registers AgentPrism’s built-in pattern-based content guard.

public static IAgentPrismBuilder AddPatternContentGuard(this IAgentPrismBuilder builder, Action<PatternContentGuardOptions>? configure = null)

builder IAgentPrismBuilder

The configuration chain.

configure Action<PatternContentGuardOptions>?

Pattern and denied-term settings.

IAgentPrismBuilder

The chain, for further configuration.

This call is the no-surprises rule’s gate. AddAgentPrism alone registers no guard, and the inspection wrapper is never added to the model pipeline. Without this call no prompt is inspected, no response is inspected, and no cost is paid.

The built-in guard carries no rules by default: PatternContentGuardOptions.MaskedPii is PiiPatterns.None and PatternContentGuardOptions.DeniedTerms is empty. Which pattern family to turn on is an explicit choice; turning them all on at once compounds the false-positive risk.

The same settings are also read from the AgentPrism:ContentGuard:Pattern configuration section; if that section is present the guard is already registered by AddAgentPrism and this call is redundant (the registration uses TryAddEnumerable, so it is never added twice).

builder.AddAgentPrism()
.AddPatternContentGuard(options =>
{
options.MaskedPii = PiiPatterns.CreditCard | PiiPatterns.Email;
options.DeniedTerms.Add("secret-project");
});

ArgumentNullException

builder is null.