Skip to content

AgentPrismContentBlockedException

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

Thrown when an IContentGuard blocks content.

public sealed class AgentPrismContentBlockedException : AgentPrismException, ISerializable

objectExceptionAgentPrismExceptionAgentPrismContentBlockedException

ISerializable

AgentPrismException.ErrorType, Exception.GetBaseException(), Exception.ToString(), Exception.GetType(), Exception.TargetSite, Exception.Message, Exception.Data, Exception.InnerException, Exception.HelpLink, Exception.Source, Exception.HResult, Exception.StackTrace, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This is separate from AgentPrismContentFilteredException and must stay separate: that one reports that the provider cut the response, this one reports that AgentPrism’s own policy did not let the content through. Writing both to the same stable identity would cost the operator the difference between “the model refused” and “we refused”.

Neither the message nor the fields carry the blocked content. The message can reach the client in a 422 body; putting sensitive text there would spread the problem.

Creates a new error.

public AgentPrismContentBlockedException()

AgentPrismContentBlockedException(string)

Section titled “ AgentPrismContentBlockedException(string)”

Creates a new error.

public AgentPrismContentBlockedException(string message)

message string

The error message. MUST not carry the blocked text.

AgentPrismContentBlockedException(string, Exception)

Section titled “ AgentPrismContentBlockedException(string, Exception)”

Creates a new error.

public AgentPrismContentBlockedException(string message, Exception innerException)

message string

The error message. MUST not carry the blocked text.

innerException Exception

The underlying error.

The stable value written to AgentPrismException.ErrorType.

public const string ContentBlockedErrorType = "content_blocked"

string

Gets the direction that was inspected.

public ContentGuardDirection Direction { get; init; }

ContentGuardDirection

Gets the stable error type name written to the run record.

public override string ErrorType { get; }

string

Defaults to the full name of the exception type, so today’s behaviour does not change. A derived type overrides this member when the record has to be machine readable — for example AgentPrismContentFilteredException writes content_filtered. Reports and alert rules can rely on this stable name instead of an assembly name.

The value is written to RunError.Type and carries no secret.

Gets the name of the guard that made the decision.

public string? GuardName { get; init; }

string?

Gets the matched rule name, or null when the guard reports none.

public string? RuleName { get; init; }

string?