Audit Trail

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.

Level
04 · Production
Subdomain
Governance & Safety
Also known as
Execution Log, Decision Log, Trace Log
Trade-off
Traceability is achieved against privacy, storage, and governance overhead.
Native in
OpenAI Agents SDK, LangSmith, Microsoft Agent Framework, Google ADK, Amazon Bedrock AgentCore Observability
The mechanism

How it works.

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

  1. Something happensA decision, a tool call, an approval
  2. Build the entryWho, what, when, with which input
  3. Chain itInclude the hash of the entry before
  4. AppendNever update, never delete

2 · Read

  1. Someone asksA dispute, an incident, an audit
  2. Filter by runAll entries of one run, in order
  3. Verify the chainRecompute the hashes
  4. ReconstructWhich step led to the action
Append-only
Entries are added at the end. Nothing that was written is edited or removed.
Hash chain
Each entry stores the hash of the one before. Changing an old entry breaks every hash after it.
Attribution
Each entry names the actor: which agent, which tool, which person approved.
Walk it through

A real run, step by step.

TaskA customer disputes a transfer of 4,800 EUR. The audit trail of that run holds five entries:
Illustrative run.
No.ActorEntry
1CustomerMessage: “send 4,800 EUR to the supplier as usual”
2Payment agentLooked up the usual supplier: an account ending in 4471
3Payment agentDecision: the amount is below the approval threshold of 5,000 EUR
4Payment agentTool call: transfer 4,800 EUR to the account ending in 4471
5Bank APIResult: executed
What this shows: the trail answers what the dispute is about. No person approved the transfer; the rule in entry 3 made it automatic, and entry 2 shows how “the usual supplier” became one particular account. Two limits remain. The trail holds customer data and needs its own access and retention rules, and a recorded reason is what the agent wrote down, not proof of why it acted.
In code

The pattern in code.

Plain Pythonpython
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 True
Fit

Use it, or not.

When to reach for it

  • Compliance or debugging demands traceability.
  • Agents trigger external actions.
  • Quality or security analyzes must be possible.

When it backfires

  • Logs would store sensitive data without protection.
  • Retention rules are unresolved.
  • Logging only generates unused noise.
Pitfalls

Two ways this pattern will hurt you.

Trails that omit the prompt

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.

Trails that include secrets

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

Regulation

Duties from EU law that this pattern helps meet, or that land on it. A reading aid, not legal advice.

  • EU AI Act Art. 12The system technically allows automatic recording of events (logs) over its lifetime, for traceability.Providers of high-risk systems · from 2 Dec 2027 (Annex III) or 2 Aug 2028 (Annex I products)
  • EU AI Act Art. 19Providers keep the automatically generated logs that are under their control for at least six months, unless other law provides otherwise.Providers of high-risk systems · from 2 Dec 2027 (Annex III) or 2 Aug 2028 (Annex I products)
  • EU AI Act Art. 26Deployers assign competent human oversight, monitor operation and keep the logs that are under their control for at least six months, unless other law provides otherwise.Deployers of high-risk systems · from 2 Dec 2027 (Annex III) or 2 Aug 2028 (Annex I products)
  • EU AI Act Art. 73The provider reports a serious incident no later than 15 days after becoming aware of it, 2 days for a widespread infringement or a critical-infrastructure incident, 10 days after a death.Providers of high-risk systems · Chapter IX, in application since 2 Aug 2026; the high-risk requirements it refers to follow from 2 Dec 2027 or 2 Aug 2028
  • EU AI Act Art. 86A person affected by a decision that produces legal effects or similarly significantly affects them, taken by a deployer on the basis of a high-risk system's output, can demand a clear explanation of the system's role and of the main elements of the decision.Deployers of Annex III high-risk systems, critical infrastructure excepted · Chapter IX, in application since 2 Aug 2026; the high-risk requirements it refers to follow from 2 Dec 2027 or 2 Aug 2028
  • GDPR Art. 15A person can obtain confirmation that their data is processed, access to it, and the recipients it was disclosed to.Controllers · since 25 May 2018
  • GDPR Art. 33The controller notifies a personal-data breach to the supervisory authority within 72 hours where feasible, unless a risk to people is unlikely.Controllers · since 25 May 2018
  • GDPR Art. 35Before processing that is likely to result in a high risk, in particular with new technologies, the controller assesses its impact on the protection of personal data.Controllers · since 25 May 2018Explained on the DPIA page
  • NIS2 Art. 23A significant incident: early warning within 24 hours, notification within 72.Essential and important entities · under national law, due since 18 Oct 2024
  • DORA Art. 19Financial entities report major ICT-related incidents: the initial notification within 4 hours of classification and at most 24 hours after becoming aware (Delegated Regulation (EU) 2025/301).Financial entities · since 17 Jan 2025

An engineer's reading aid, not legal advice. The legal texts and their interpretation are authoritative.

Framework support

Where Audit Trail is native.

OpenAI Agents SDKbuilt-in TracingNative
LangSmithServicerun + tool logsNative
LangGraphcheckpointed state historyAdaptable
Microsoft Agent Frameworkactivity logNative
Google ADKevent logsNative
Amazon Bedrock AgentCore ObservabilityServiceagent traces and audit loggingNative

Search

Search patterns, frameworks, and pages.