Observing before enforcing#
Guards act on Enkrypt’s findings, and Enkrypt’s findings depend on your text; see Choosing entity types. Before guards refuse, raise or redact for real users, watch what they would do.
Turn enforcement off#
enkrypt = Enkrypt(enforce=False)
Every guard from this object then calls Enkrypt as usual, logs what it would have done, and lets the value through. Nothing is blocked, raised, retried or redacted, and Enkrypt failures are allowed whatever on_error says. The agent behaves as if it had no guards.
The log, on the pydantic_ai_enkrypt logger at WARNING:
WARNING pydantic_ai_enkrypt: Enkrypt AI would block the prompt (run 01a1d13a-..., not enforced): Your message was blocked because it was identified as a potential security threat. (injection_attack)
WARNING pydantic_ai_enkrypt: Enkrypt AI would redact the prompt (run 01a1d13a-..., not enforced): Enkrypt AI blocked the prompt (person; ip_address).
These two lines came from one prompt checked by injection_attack() and pii(entities=["person", "ip_address"]): the injection guard would have blocked it, so the PII guard would never have run when enforcing; observing, both run and both are logged.
Tune, then enforce#
Run with
enforce=Falseon real or representative traffic.Read what each guard would have done: findings you did not expect, and findings missing that you did expect.
Adjust: entity types, rules, actions, or moving checks into a saved guardrail.
Switch to
Enkrypt(), which enforces.
For a single guard, on_violation="audit" does the same while the others act.