redact_directory_tool
Scan a directory for PII and secrets, then write a redacted copy to a new location without altering the original. Use to sanitize data before sharing or publishing.
Instructions
Scan a directory for PII/secrets with Presidio, then write a redacted copy to a new location.
Call this once you already know (or expect) a directory contains
PII and want a sanitized copy you can hand off or publish, without
touching the original. It runs its own internal scan first (same
detector as scan_directory_tool), so you do not need to call
scan_directory_tool beforehand unless you want to inspect
findings before deciding to redact. Skip it if you only need a
report (use scan_directory_tool) or if you also want the Hugging
Face card and EU AI Act summary generated (use
package_release_tool, which redacts as one step of a larger
bundle).
path must exist and be readable. This tool is mutating but scoped
to output only: it never edits, moves, or deletes anything under
path. Writing fails if output already exists and is non-empty,
unless overwrite=True -- pass that deliberately, since it will
silently overwrite prior contents of output. No network calls are
made; everything runs locally. Not idempotent across repeated calls
with overwrite=True if the source directory changed between runs
(the redacted copy reflects whatever path contains at call time).
strategy controls how each finding is replaced: "mask" (default,
replaces matched text with a placeholder like <EMAIL_ADDRESS>),
"hash" (replaces with a deterministic hash of the original value),
or "remove" (deletes the matched span entirely). Example calls:
redact_directory_tool(path="./data", output="./data-redacted"),
redact_directory_tool(path="./data", output="./data-redacted", strategy="hash"),
redact_directory_tool(path="./data", output="./data-redacted", overwrite=True).
Returns a JSON object with source_root, output_root, strategy,
files_written (list of paths under output), entities_redacted
(per-entity-type counts), and total_redacted. On a missing path,
an invalid strategy, or a non-empty output without
overwrite=True, it returns {"error": ..., "error_type": ...}
instead of raising. See releaseguard redact --help for the
CLI-equivalent flag reference.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| output | Yes | ||
| strategy | No | mask | |
| overwrite | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||