Pattern 36 · Trust & safety

Agent audit trail for compliance

When an auditor or a customer asks who authorised an agent’s action, a debugging trace is not an answer.

By Alex StepikinUpdated December 20264 min readLive demo
In short

An audit trail is an append-only record of decisions and effects: who or what acted, under which authority, on which object, with the outcome and before and after values. Chain each entry to the previous one with a hash so edits show up, offer a verify button in the interface, and provide a scoped export for auditors. It is separate from the debugging history of runs.

Live demo · try it

An interactive mock built in plain HTML, CSS and JavaScript. Data is fictional; no model is called.

FitWhen to use it — and when not

Use it when

  • Agents that touch money, customer data, access rights or regulated records
  • B2B products where customers’ security teams ask for exportable logs
  • Any workflow with an approval step that someone may later have to prove

Skip it when

  • Debugging and replaying runs: use run history, which is allowed to be verbose and editable
  • Consumer features with no regulated data and no shared accountability
  • Logging full prompts and personal data "just in case"; that creates a privacy problem

AnatomyThe parts of the pattern

  1. EntrySequence number, time, actor, action, object, outcome, and the authority it ran under.
  2. Actor and authorityThe human who started or approved it, the agent, and the permission that allowed it.
  3. ChainEach entry holds a hash of the previous one, so edits and deletions break the chain.
  4. VerifyA button that checks the chain and says where it breaks.
  5. ExportA scoped file (CSV or JSON) with a manifest and a checksum, for an auditor.
  6. RetentionHow long entries are kept, who can read them and what is redacted.

GuidelinesDo & don’t

Do

  • Log decisions and effects, such as approvals, permission changes, sends and deletes, with before and after values.
  • Store references to sensitive content rather than the content itself.
  • Show verification status on the page, not in a separate admin tool.
  • Make exports filterable by actor, date and object, and say what the file does not contain.

Don’t

  • Let the agent, or any admin, edit or delete entries.
  • Treat the audit trail and the debug trace as the same store.
  • Log the model’s reasoning text as evidence; it is not a record of what happened.
  • Promise tamper-proof. A chain is tamper-evident; say that.

In the wildReal-world examples

AWS CloudTrail (log file integrity validation)GitHub (audit log export)Google Workspace (admin audit logs)Salesforce (Setup Audit Trail)

Products named for reference only — no affiliation, and the demo above is an original illustration, not a copy of their UI.

For engineersImplementation notes

  • Write entries append-only with entry_hash = H(prev_hash + canonical entry); store the latest hash outside the main database, for example in a separate service or signed daily.
  • Capture the actor from the authenticated session and the grant that allowed the action, not from fields the agent supplies.
  • Keep a retention and legal-hold policy per workspace; redact at export, not at write, when rules differ per recipient.
  • Include a manifest in each export: range, filters, entry count, first and last hash, checksum of the file.

Q&ACommon questions

What is the difference between an audit trail and run history?

Run history is for debugging: verbose, inspectable, re-runnable and allowed to change. An audit trail is for accountability: minimal, append-only, tied to identities and permissions, and built so that nobody, including admins and the agent, can alter it without being detected.

How do you make an AI agent log tamper-evident?

Hash each entry together with the previous entry’s hash, and keep the latest hash somewhere the main database cannot rewrite, such as a separate service or a daily signature. Editing or deleting an entry then breaks the chain from that point on, and verification can say where.

Should an audit log store the full prompts and model outputs?

Usually not. Store what happened and references to the content, because prompts often contain personal data. Keep the full text in run history with its own retention period, and redact at export when different recipients may see different fields.

See alsoRelated patterns

All 40 LLM UX patterns

Does this pattern work in your product?

The AI Trust Audit checks how your product handles this pattern and the other moments where people decide whether to trust the AI. You get 10+ fixes ranked by impact and effort, and your key flow redesigned. 5 working days, $990, credited to a build if we continue. Related case: Atlas, a control room for a fleet of AI agents.

Get the audit · $990Ask a question first

Create bold.
Deliver better.

See our workGet in touch