New Tool Radar

AI Agents & Automation

How to Keep an Audit Trail of an Agent Write Actions

Keep an audit trail of every agent write action with who approved it, what changed and when it ran.

Schematic with three steps: List the write actions to audit; Log each write with approver, change and; Test the trail by finding one write.

A trace shows what the agent did, but an audit trail shows who is responsible for it: who approved each write, what changed, and when it ran. That is the record you need when a customer asks why a record changed, or when a write turns out to be wrong. LangSmith traces already record each run as a tree of tool calls with inputs and outputs; build the audit trail from that, plus the approval decision, by logging each write action with its approver, the before and after values, and the run id. A trace you cannot search by write action is a log, not an audit trail.

What you need

  • An agent that writes to at least one external system
  • Tracing on, so each run has a recorded tree
  • A place to store audit records: a sheet, a table, or the trace metadata

Step 1: List the write actions to audit

Write down every action that changes something outside the agent: database writes, messages sent, records created. Reads are not audited; writes are.

Step 2: Log each write with approver, change and run id

For each write, record who approved it, what changed from what to what, when it ran, and the run id that links back to the trace. A record without the approver is incomplete.

Step 3: Test the trail by finding one write

Pick a write from last week and find it in the trail by its run id alone. If you cannot find it, or the approver is missing, the trail has a gap to close.

Worked example: synthetic audit trail

The table below is a synthetic example. It shows the expected result of the audit trail; no writes were logged.

Write action Approver logged? Before and after?
Update invoice status Yes Yes
Send customer email Yes Yes
Create support ticket Yes Yes
Found by run id alone Yes Pass

Expected result (UNTESTED). every write action is logged with its approver, its before and after values, and a run id that finds it. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A trace records the run, but the approver is only in the trail if your code writes it there.
  • Audit records must not contain secrets or whole personal records; log the change, not the data.
  • A trail that nobody can search by run id is a pile, not a trail.
  • Retention matters: a trail that is deleted with old executions loses the record.

Sources

See all