Privacy & Security 8 min read

AI Audit Trails and Traceability: Can You Explain What the AI Decided?

When an AI answer is questioned, logs of the prompt and reply are not enough. What to record per decision, and how to protect the sensitive data in your trail.

Cover for the AI security series: Can you explain what the AI decided, showing three controls: versioned prompts and models, logged sources and tool calls, and protected records

Quick answer: To explain what an AI system decided, you need more than the final answer. Record the request context, model and prompt versions, the exact sources retrieved and the permission filter applied, every tool call, and any human approval. Store references and hashes rather than raw sensitive text where you can, restrict who can read the trail, and set retention deliberately.

When an AI feature gives a surprising answer, the first question from security, legal or a customer is usually "why did it say that?" With traditional software you can read the code path. With a model, the answer depends on inputs that change all the time: the prompt template, the model version, whatever documents retrieval returned and whatever tools the model chose to call. If you did not record those inputs when the request ran, you usually cannot reconstruct them later.

Example (fictional companies): Calder Mutual, a regional insurer, gives its marketing reviewers a compliance assistant. Reviewers paste in a draft campaign email and the assistant, using retrieval over the company's policy library, recommends whether it can be sent. One recommendation approves an email that a regulator later questions. Calder's team opens the logs and finds the reviewer's ID, the draft and the assistant's answer. What they cannot find is which policy documents informed the answer, whether an outdated version of the financial promotions policy was still in the index, which prompt template was live that week, or whether the reviewer read the cited sources before approving. The investigation turns into guesswork.

How are teams handling AI logging today?

Most teams reuse their existing observability and security logging, then add a little AI-specific data:

  • Application and access logs that record who called the AI endpoint and when, often forwarded to a SIEM.
  • Prompt and response logging, either in full or sampled, sometimes in a separate LLM observability tool used mainly for debugging and cost tracking.
  • Provider dashboards showing usage, latency and errors.
  • Guardrail logs showing which inputs or outputs were blocked by filters.
  • Tracing, increasingly following the OpenTelemetry semantic conventions for generative AI spans, which define attributes for model calls and a related set for agent and framework spans. These conventions are still marked as in development, so attribute names can change.

These give you activity data. They are rarely designed as evidence: something an investigator or reviewer can use to reconstruct a decision months later.

What do current approaches miss?

The retrieval step is invisible. In Calder's case, the logs held the question and the answer but not the documents in between. For retrieval-augmented generation, the retrieved chunks are often the most important input. Without document IDs, versions and the permission filter that was applied, you cannot tell whether the model relied on the right policy, an outdated one or one the user should not have seen.

Versions are not pinned in the record. "We use model X" is not enough when providers update models behind a stable name and prompt templates change in a config file. If the trail does not capture the exact model identifier and prompt template version per request, you cannot match an answer to the configuration that produced it.

Tool calls and approvals are logged elsewhere, or not at all. An agent that calls tools may leave traces in five different systems. The human approval might be a click in the UI that writes nothing durable. Joining these after an incident is slow and sometimes impossible.

Full-text logging creates its own risk. The opposite mistake is logging every prompt and response in full, forever, in a tool many engineers can read. Those logs then contain customer data, personal information and the hidden instructions you were trying to protect. The OWASP Top 10 for LLM Applications 2026 lists both LLM02:2026 Sensitive Information Disclosure and LLM08:2026 Hidden Context Exposure; a careless log store can create either. The data leakage article in this series covers this in more depth.

Exact reproduction is not realistic. Even with every input recorded, models are not always deterministic, and providers retire versions. The goal is not to re-run the request and get the same tokens. It is to reconstruct what the system saw, what it did and who approved it.

How do you build a useful audit trail?

Design one decision record per AI interaction (or per agent step), written by the application itself, with a stable ID that ties together the model call, retrieval, tool calls and human review.

What goes in the record

  • Request context: user, tenant, role, feature, purpose, timestamp and a correlation ID.
  • Configuration: exact model identifier returned by the provider, prompt template ID and version, guardrail policy version, and relevant parameters.
  • Retrieval: document IDs, document versions, chunk hashes, scores, the index snapshot or build ID, and the access filter applied before search.
  • Tool calls: tool name and version, arguments, result status, and which credential or scope was used. Record denied calls too.
  • Output: the response, or a hash plus a pointer to a protected store, and any citations shown to the user.
  • Human oversight: who reviewed, what they did (approved, edited, rejected) and when.

A trimmed example of what Calder's assistant could have written:

{
  "decision_id": "dr_2026_10_02_8f3c",
  "user": "u_4471", "tenant": "marketing", "feature": "promo-review",
  "model": "provider-model-2026-07-15",
  "prompt_template": "promo-review@v14",
  "retrieval": {
    "filter": "acl:marketing-reviewers",
    "index_build": "policies-2026-09-28",
    "docs": [
      {"id": "POL-112", "version": "3.2", "chunk_sha256": "a91e..."},
      {"id": "POL-087", "version": "1.0", "chunk_sha256": "77b0..."}
    ]
  },
  "tool_calls": [],
  "output_sha256": "c2d4...", "output_ref": "vault://promo-review/dr_2026_10_02_8f3c",
  "human_review": {"reviewer": "u_4471", "action": "approved", "at": "2026-10-02T14:11:09Z"}
}

With this record, Calder could see at once that POL-087 version 1.0, a superseded policy, was still in the index.

How to protect what you record

  • Prefer references to copies. Store document IDs, versions and hashes; keep full prompt and response text only where you need it, in a store with tighter access.
  • Redact before writing. Remove secrets and unnecessary personal data at the logging layer, not afterwards.
  • Separate duties. Engineers debugging latency do not need to read customer prompts. Give investigators a controlled, logged way to access full records.
  • Make the trail tamper-evident, for example with append-only storage, and set retention to match legal and contractual needs rather than "forever".
  • Version your corpus. Snapshot or version the retrieval index so a document ID and version can be resolved later.

Six components of an AI decision record: request context, model and prompt versions, retrieved sources, tool calls, human review, and protection through redaction, hashing, access control and retention

Recommendations: a checklist

  1. Define a decision record schema for every AI feature, with a correlation ID across model calls, retrieval, tools and reviews. Owner: platform engineering.
  2. Pin and log versions: exact model identifier, prompt template version and guardrail policy version per request. Owner: ML or AI platform lead.
  3. Log retrieval as evidence: document IDs, versions, chunk hashes and the access filter applied before search. Owner: search or RAG team.
  4. Log every tool call, including denied ones, with arguments and the credential scope used. Owner: agent and integrations team.
  5. Capture human oversight in the product, not in chat threads. Owner: product engineering.
  6. Minimise and redact at write time, and keep full text in a restricted store. Owner: security and privacy.
  7. Set retention per system, based on legal requirements, contracts and investigation needs. Owner: legal and compliance.
  8. Run a reconstruction drill each quarter: pick a past answer and try to explain it from the trail alone. Owner: AI governance lead.

How does this map to OWASP, NIST and the EU AI Act?

OWASP. In the OWASP Top 10 for LLM Applications 2026, audit trails support investigation of LLM01:2026 Prompt Injection and LLM03:2026 Excessive Agency (what did the model read, and what did it do?), and LLM09:2026 Vector and Embedding Weaknesses for retrieval problems. Poorly protected logs can themselves cause LLM02:2026 Sensitive Information Disclosure or LLM08:2026 Hidden Context Exposure. The OWASP AI Agent Security Cheat Sheet includes monitoring and logging among its recommended agent controls.

NIST. The NIST Generative AI Profile (AI 600-1) names content provenance and incident disclosure among its primary considerations, and lists risks such as confabulation and information integrity that an audit trail helps you investigate. Its suggested actions sit under the AI RMF functions, with Measure and Manage most relevant here.

EU AI Act. In Regulation (EU) 2024/1689, Article 12 requires high-risk AI systems to technically allow automatic recording of events over their lifetime, and Article 26 requires deployers to keep the logs under their control for a period appropriate to the intended purpose, of at least six months unless other law says otherwise. Following the 2026 amendment, the EUR-Lex summary lists 2 December 2027 as the application date for Annex III high-risk obligations. Even for systems outside the high-risk categories, these articles are a useful benchmark for what a defensible trail looks like.

Where to discuss and learn more

Frequently asked questions

Should we log full prompts and responses?

Only where you need them, and in a restricted store with a defined retention period. For most investigations, IDs, versions, hashes and a pointer to protected full text are enough.

Can we reproduce an AI answer exactly?

Often not, because models can be non-deterministic and providers retire versions. Aim to reconstruct the inputs, configuration, actions and approvals, which is what investigators and reviewers need.

Is OpenTelemetry enough?

It is a good transport and a shared vocabulary for model and agent spans. You still need to decide which fields form your evidence, how they are protected and how long they are kept.

Who should own the audit trail?

Platform engineering usually owns the schema and pipeline, security and privacy own protection and access, and legal owns retention. The business owner of each AI system confirms the record covers its decisions.

Related in this series: from AI policies to compliance evidence and continuous AI security testing and incident response.

Found this useful? Like it, share it or follow the blog.