IContentGuard
AgentPrism.Abstractions.dllThe extension point that inspects content going to and coming from the model.
public interface IContentGuardRemarks
Section titled “Remarks”A guard is opt-in: AddAgentPrism alone registers no
IContentGuard. If no guard is registered, the inspection
wrapper is not added to the model pipeline, and the cost
is exactly zero — not even a single flag check runs.
Registration uses TryAddEnumerable; multiple guards run in sequence
and the strictest decision wins
(ContentGuardAction.Block >
ContentGuardAction.Mask > ContentGuardAction.Allow).
A “first decision wins” rule tied to registration order was not chosen:
TryAddEnumerable order is not guaranteed, and a security decision
must not change based on order.
A guard runs at the OUTERMOST edge of the model pipeline: a blocked request never reaches the network (no money is spent), and blocking does not trip the circuit breaker (repeatedly blocked requests do not shut down the provider).
A guard is a control, not an observability tool. The “observability must not break functionality” rule does not apply here: if this method throws, the run fails. Content that cannot be inspected is never let through.
The implementation is on the hot path and runs on every model call. It is expected not to allocate a new string when there is no match.
Properties
Section titled “Properties”The guard’s name. This name is written to the audit trail and the run event.
string Name { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”InspectAsync(ContentGuardContext, CancellationToken)
Section titled “ InspectAsync(ContentGuardContext, CancellationToken)”Inspects the content.
ValueTask<ContentGuardResult> InspectAsync(ContentGuardContext context, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”context ContentGuardContext
The inspection context.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The decision. Returns ContentGuardResult.Allow when the content passes unchanged; this path allocates nothing.