When to reach for it
- Compliance or debugging demands traceability.
- Agents trigger external actions.
- Quality or security analyzes must be possible.
Every step, signed and timestamped.
Decisions, tool calls, inputs, outputs, and approvals are written to an append-only, tamper-evident record, so every action a run took can be reconstructed and attributed after the fact.
In practiceAfter a disputed wire transfer, a bank's audit trail surfaces the exact tool call and reasoning that approved it, letting the security team trace accountability and close the gap.
Without itWithout an audit trail, a post-incident investigation has no record of which agent took which action, making root-cause analysis and compliance reporting impossible.
Every decision, tool call and approval is appended to a record that cannot be changed afterwards without the change being noticed. What happened in a run can then be reconstructed and attributed.
1 · Write
2 · Read
| No. | Actor | Entry |
|---|---|---|
| 1 | Customer | Message: “send 4,800 EUR to the supplier as usual” |
| 2 | Payment agent | Looked up the usual supplier: an account ending in 4471 |
| 3 | Payment agent | Decision: the amount is below the approval threshold of 5,000 EUR |
| 4 | Payment agent | Tool call: transfer 4,800 EUR to the account ending in 4471 |
| 5 | Bank API | Result: executed |
import hashlib, json, time
def append(log, actor, action, detail):
previous = log[-1]["hash"] if log else "0" * 64
entry = {"time": time.time(), "actor": actor, "action": action,
"detail": detail, "previous": previous}
entry["hash"] = hashlib.sha256(json.dumps(entry, sort_keys=True).encode()).hexdigest()
log.append(entry) # append only: no update, no delete
def verify(log):
previous = "0" * 64
for entry in log:
body = {k: v for k, v in entry.items() if k != "hash"}
digest = hashlib.sha256(json.dumps(body, sort_keys=True).encode()).hexdigest()
if entry["previous"] != previous or entry["hash"] != digest:
return False # an entry was changed or removed
previous = entry["hash"]
return TrueWhen to reach for it
When it backfires
The audit trail logs the tool call and response but not the prompt that triggered it. Root-cause analysis is impossible.
Countermeasure
Log the full prompt, model config, and system instructions alongside every action. Treat the prompt as part of the decision record.
The audit trail captures API keys or user PII in plain text. Compliance review becomes a data breach.
Countermeasure
Redact secrets and PII at ingestion. Store raw inputs in a separate secure vault with access controls.
EU law
Duties from EU law that this pattern helps meet, or that land on it. A reading aid, not legal advice.
An engineer's reading aid, not legal advice. The legal texts and their interpretation are authoritative.
Next pattern
Search patterns, frameworks, and pages.