Skip to content
Tracon

IContentGuard

Namespace Tracon · Assembly Tracon.Abstractions.dll

The extension point that inspects content going to and coming from the model.

public interface IContentGuard

A guard is opt-in: AddTracon 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 directly above the provider’s own chat client, which places it inside the tool-call loop: a blocked request never reaches the network (no money is spent), blocking does not trip the circuit breaker (repeatedly blocked requests do not shut down the provider), and — the reason for this exact position — every turn of the loop is inspected. A tool result re-enters the model on the second turn, and that is the most common path for prompt injection; a guard placed outside the loop would never see it.

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.

The guard’s name. This name is written to the audit trail and the run event.

string Name { get; }

string

InspectAsync(ContentGuardContext, CancellationToken)

Section titled “ InspectAsync(ContentGuardContext, CancellationToken)”

Inspects the content.

ValueTask<ContentGuardResult> InspectAsync(ContentGuardContext context, CancellationToken cancellationToken = default)

context ContentGuardContext

The inspection context.

cancellationToken CancellationToken

The cancellation token.

ValueTask<ContentGuardResult>

The decision. Returns ContentGuardResult.Allow when the content passes unchanged; this path allocates nothing.