Skip to main content
DLP (Data Loss Prevention) runs before policy evaluation. It scans the tool call’s arguments for secrets, PII, or PHI and surfaces detections as first-class policy fields. Policies can then say “deny if dlp_severity is high” — a one-liner that catches an entire class of issues no rule-by-rule list could anticipate.

Modes

Enable via the dlp= kwarg on Governance.bootstrap() or the AG_DLP env var.

What gets scanned

The input, args, and kwargs fields on the EvaluationMetadata you pass to evaluate(). Strings nested arbitrarily deep are walked. Non-string values are ignored. If none of those fields are populated, the scan is skipped (no false positives on empty input).

Detected types

The detector returns:
These flow into the audit event’s metadata.dlp and into the policy evaluator’s request as:

Severity tiers

The default tier mapping (override per-detector if needed):

Example policy

That’s the whole policy. Drop it in, publish, and any evaluate() whose arguments contain an SSN or AWS key returns deny with denyCode: high-severity-deny.

Custom detector

Pass any object with a detect(payload: dict) -> DlpDetection | None method:
Useful for company-specific patterns (internal IDs, customer secret formats, proprietary tokens) the built-in detectors don’t know about.

Failures fail-soft

If the detector raises, the SDK logs and treats the call as dlp_detected: false. Your agent doesn’t break because a regex compiled wrong. Fix the detector and you’re back in business.