Scrub Pii Text • AI Agent SDK

scrub_pii_text: Redact API keys, passwords, SSNs, credit cards, and emails from free text.

scrub_pii_text

Function

</div>

This function is defined in the redact module.

Redact API keys, passwords, SSNs, credit cards, and emails from free text.

Reuses REDACT_KEYS for `key=value` pairs and adds value-pattern rules for naked secrets. Zero dependency (stdlib re only).

Signature

python
def scrub_pii_text(text: str) -> str

Parameters

ParamField str

Input string — returned unchanged if empty or None.

Returns

ResponseField str

Scrubbed string with literal secrets replaced by `[REDACTED*]`.

Uses

  • redact_string
  • pat.sub

Source

View on GitHub

praisonaiagents/trace/redact.py at line 152