redact_text finds text matching a regular expression and redacts it, saving a redacted copy. This is the core tool: email addresses, national IDs, phone numbers, account numbers, names — anything you can express as a pattern. Example prompt: “Redact every email address in case-file.pdf”.
Tool description (as the AI agent sees it):
Redacts text matching a regex pattern from a document and saves the redacted file to storage. Use to permanently hide sensitive data like SSNs, emails, phone numbers, or any custom pattern. Call this tool immediately whenever the user asks to redact, hide, remove, or black out text in a document. Do NOT pre-check whether files exist — just pass the filename the user provided. The tool resolves files from storage and returns an error with available files if a name is not found. On failure, the response text starts with ‘Text redaction failed for’ followed by the underlying exception type, message, and inner-exception chain.
The matched text is replaced in the document, not covered with a drawn rectangle — which is what makes this redaction rather than obscuring. replacement controls what appears in its place; a consistent marker like [REDACTED] makes the result reviewable.
Two things to be deliberate about: a pattern that is too loose removes more than you meant, and a pattern that is too tight leaves data behind. Ask the agent to report the match count, and verify afterwards.
On failure the text starts with Text redaction failed for, followed by the exception type and message.