Skip to content

agentix.guards.pii

pii

PII guards.

PiiUrlGuard (before_call) refuses a tool call whose URL/query-like arguments contain PII — personal data must never end up in query strings, where it leaks into logs and referrers.

PiiRedactionGuard (on_answer) masks PII in the model's final answer to the user — a last-line DLP filter on what leaves the loop. It uses its own, tighter pattern set (the URL patterns are tuned for detection, which is too loose for redacting free text without false positives).

PiiRedactionGuard

PiiRedactionGuard(
    patterns: Sequence[str] | None = None,
    *,
    mask: str = "[REDACTED]",
)

Bases: Guard

Masks PII in the final answer before the user sees it.

Opt-in (not in :func:secure_defaults) because redacting user-facing text is an application/compliance choice and can mask data the user legitimately asked for. Configure patterns and mask for your domain.