New Tool Radar

AI Agents & Automation

How to Redact Personal Data From Agent Logs Before Storage

Redact personal data from agent logs before they are stored, so logs never hold secrets.

Schematic with three steps: List the data types to redact; Redact at the point of writing, before; Test with a sample log line and.

Agent logs record what the run did, and what the run did often includes personal data: names, email addresses, order numbers, and sometimes keys pasted into a message. Once that data is in a stored log, it stays there, readable by anyone with log access. Redaction is the fix: before a log line is stored, replace personal data with a marker, such as an email address becoming a redacted label. LangSmith traces are the record of what agents did in production, which makes them exactly the place where this matters. Redact at the point of writing, not in a later cleanup, because a cleanup that never runs is the same as no redaction.

What you need

  • A list of the personal data types your runs handle: emails, names, ids, keys
  • A redaction step that runs before any log line is stored
  • One sample log line with personal data, to test the redaction on

Step 1: List the data types to redact

Write down the personal data your runs handle: email addresses, phone numbers, account ids, and any secret that could appear in a message. A type not on the list will not be redacted.

Step 2: Redact at the point of writing, before storage

Add the redaction step where log lines are written, so every line is cleaned before it reaches storage. Redacting later, in a cleanup job, leaves the raw data stored in between.

Step 3: Test with a sample log line and read the stored result

Write a sample log line containing personal data, store it, then read it back and confirm the data is replaced by a marker. If the raw data is still there, the redaction is not in the write path.

Worked example: synthetic log redaction check

The table below is a synthetic example. It shows the expected result of redaction; no log was stored.

Log content Redacted? Stored as
Email address in a message Yes Marker
Order number in a result Yes Marker
API key in an error Yes Marker
No personal data stored Yes Pass

Expected result (UNTESTED). every personal data item in the sample log is replaced by a marker before storage, and no raw personal data is stored. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Redaction only catches the patterns it knows; a new data type needs a new pattern.
  • Over-redaction hides useful debugging detail, so keep enough context to diagnose failures.
  • Redaction at write time does not clean logs that were already stored.
  • A marker must not leak the data: a partial email is still an email.

Sources

See all