The Audit Trail: How to Prove What Your AI Agent Saw
Proving what an AI agent saw means being able to reconstruct, for any individual answer, which sources were retrieved, which identity they were retrieved under, what was passed to the model, and what came back. That record has to be produced by the system at the moment of the answer, and it has to survive long enough to be examined months later by someone who was not there. Most deployments can produce none of it, because they log the conversation and nothing underneath it.
This is the first question asked in financial services, healthcare, and government, and the one that most often stops a working pilot from reaching production. The pilot answers well. Then someone in risk or internal audit asks how an answer would be defended if challenged, and the honest reply is that it would not be.
What a regulator or auditor actually asks
Auditors do not ask about architecture. They ask about one specific event, usually one that already went wrong, and they ask in a consistent order.
- Who asked this? A named person, not a session token or a service account, and the agent that acted for them.
- What were they entitled to see at that moment? Not today’s entitlements, the ones in force on the day of the answer.
- What did the system actually show them? Everything the answer drew on, including material retrieved but not cited.
- Where did each claim come from? Claim by claim, not a bibliography at the end.
- Has anything changed since? In the documents, the permissions, the index, and the model.
- Who else got the same answer? Scope of exposure, which is how one bad answer becomes a reportable event.
Only one of those is about the generated text, which is why a chat transcript satisfies almost none of them.
The reply that does not survive an auditor is “the model said it.” That describes the mechanism, not the evidence, in the way “the spreadsheet calculated it” would not close a finding without the inputs and the formula. Supervisory regimes in financial services expect evidence that communications were reviewed effectively, health privacy rules expect audit controls over access to protected information, and public sector programs inherit audit and accountability requirements from their authorization frameworks. Those obligations belong to the organization deploying the system, so turn them into vendor criteria: what the platform records by default, in what format, and for how long. Lucidworks publishes its own security and compliance posture, and buyers should expect that specificity from anyone they evaluate.
The seven things an answer log has to contain
An answer log is not a transcript. It is a structured record written at the moment of the answer, one entry per response, holding seven elements.

| What to record | Why it matters | What goes wrong without it |
|---|---|---|
| The question as asked | Establishes intent and exact wording, including any rewrite applied before retrieval. | You defend an answer to a question nobody asked, and cannot tell whether a rewrite changed the meaning. |
| The identity of the asker and of the agent | Separates whose authority the request ran under from which configured software acted. | Everything resolves to a shared service account, so no answer is attributable and exposure cannot be scoped. |
| The retrieval set, with document identifiers and versions | This is the evidence: what the agent saw, cited or not, as it existed at that instant. | Reconstruction fails once content is edited, and you cannot show a restricted document was never returned. |
| The permission decision applied | Records the entitlements in force at query time and what they excluded, not only what they allowed. | You cannot prove a person saw only what they were cleared for, the question every access review turns on. |
| The exact context passed to the model | Captures the assembled payload: passages, system instructions, tool outputs, and history. | You see what was retrieved and what came back, but not what the model worked from, so odd claims stay unexplained. |
| The model and configuration used | Pins the provider, model version, sampling settings, and prompt template version. | Behavior changes under you, and a silent model update gets attributed to a prompt change. |
| The response with its citations | Links each claim to the passage supporting it, rather than listing sources at the end. | Review becomes a reading exercise, and unsupported statements sitting beside good citations go unnoticed. |
Two rows are missed far more often than the rest. The first is the permission decision applied. Teams log which documents were returned and consider access handled, but that set says nothing about what was withheld or why. An access review asks the inverse question, whether anything the person was not entitled to could have reached them, and only the decision answers it: the groups and roles resolved for that principal, the policy evaluated, and the candidates filtered out.
The second is the exact context passed to the model. The gap between what retrieval returned and what the model received is where most surprising behavior lives. Passages are truncated to fit a window, reranked, deduplicated, and merged with history, system instructions, and tool outputs nobody logged because they count as application code. When an answer contains a claim found in none of the retrieved documents, the explanation is usually in that payload.
Why the model’s output is the least useful thing to log
Nearly every team starts by logging prompts and responses, because that layer is closest to the user and easiest to instrument. It is also the layer with the least evidentiary value, because the generated text is the least reproducible artifact in the pipeline. Models get updated, sometimes quietly, and sampling is nondeterministic by default, so the same prompt can produce different words on consecutive runs. Even pinned to a version and set as deterministically as the provider allows, you are relying on their guarantee rather than on something you hold.
What is reproducible is everything before the model. The retrieval set is a list of identifiers and versions and can be fetched again exactly. The permission decision is a function of a principal, a policy, and a set of group memberships, and can be replayed. The assembled context is a byte-for-byte artifact you wrote down. Those three are deterministic records of what the system did, and they are what the auditor’s questions ask about.
Logging the output alone leaves a transcript of something you cannot defend. You can show what was said, not that it was grounded in approved content, that the content was visible to the person who asked, or that the same question tomorrow would be handled the same way. Our state of enterprise search research keeps finding the same split: confidence in AI answers tracks the quality of the grounding behind them, not the fluency of the text.
Reproducing an answer six months later
Six months is the realistic interval. A complaint, an examination, or a dispute arrives, and someone must establish what the system told a named person on a specific date. Four things will have drifted by then, each breaking reconstruction differently.

Content drift. The documents have been edited: a policy revised, a contract amended, a wiki page rewritten by someone tidying up. Fetching the same identifiers today returns different text, so the reconstruction shows an answer that does not follow from its sources, and the system looks like it invented something.
Permission drift. The person changed roles, left a group, or was off-boarded. Replaying under today’s entitlements produces a different retrieval set, and in the worst case returns nothing, which reads as evidence that the original answer was impossible.
Index drift. The corpus has been recrawled, rechunked, or reembedded. Chunk boundaries moved, so the passage supporting a claim no longer exists as a unit, and an upgraded embedding model reorders results even when the text is identical.
Model drift. The provider shipped a new version, or you upgraded deliberately. The same context produces different wording, different emphasis, and sometimes a different conclusion.
The decision that makes reconstruction possible is this: pin document versions at retrieval time, not just document identifiers. Record the version or content hash of each retrieved passage, and either retain the passage text in the log or guarantee the version stays addressable in the content store. This is the single thing most teams get wrong, because logging an identifier feels sufficient and because version-addressable content costs storage and connector work rather than demo quality. Everything else here is implementable in a sprint. This one is an architecture commitment, and retrofitting it means earlier answers stay unreconstructable. For firms like Morgan Stanley, showing what a system presented at a point in time is a condition of operating, not an engineering preference.
Permission drift needs the same treatment. The record must hold the decision as made, including resolved group memberships and the policy version, so that reconstruction is a lookup rather than a re-evaluation.
Retention, immutability, and who can read the log
Append-only storage. Entries are written once and never updated in place. Corrections are new entries referencing the original, the way a ledger handles a reversal. The instinct when an entry is wrong is to fix it, and that instinct destroys the property that makes the log worth keeping.
Tamper evidence. You cannot stop a privileged administrator from altering storage, so make alteration detectable: hash-chain each entry to its predecessor, anchor digests periodically outside the system’s control, and use storage that enforces retention at the platform level. Several regimes expect records preserved so they cannot be overwritten or erased during their retention period, or preserved instead under a verifiable audit trail. The broker-dealer books and records rule, SEC Rule 17a-4, is the most cited example, and firms subject to it should map AI answer logs against it rather than assume general logging qualifies.
Separation of duties. The team operating the AI system should not be able to modify its audit record: the log is owned by a different group, written through an append-only interface, and reviewed by people with no delivery stake. If the platform team can edit the evidence of its own work, an auditor will treat the whole record as unreliable.
The log holds the sensitive material. Record the retrieval set and the assembled context, and the log now contains restricted documents, patient information, or deal material, aggregated in one place and sorted by person and date. It needs its own access control, retention policy, and review. The usual approach splits the record: metadata and decisions in a widely readable tier, retrieved content in a restricted tier reachable only through a named, logged request.
Retention periods are not an AI question. They come from the regime the organization is already subject to, applied to the class of record the log falls into. Classify the log, find the existing rule, and apply it.
What to log when the agent acts rather than answers
Everything above assumes the agent reads and answers. The moment it writes, sends, files, or approves, the harm is no longer disclosure but an action someone has to explain or undo, and four elements come in addition to the seven.
- Intent. The action proposed, in structured form, before it was taken: operation, target, and parameters.
- The policy check. Which rule authorized it, evaluated against the principal’s entitlements and the agent’s permitted operations, and what the evaluation returned.
- The approval, if any. Who approved, when, what they were shown at that moment, and whether approval was explicit or an expired timeout.
- The result. What the target system returned, including the identifier of whatever was created or changed, plus enough state to support reversal.
Read logging and write logging are different problems. Read logging is high volume, individually low stakes, and exists for reconstruction. Write logging is low volume, individually high stakes, never sampled, and exists for accountability and reversal. A read log that loses an entry is a gap; a write log that loses an entry is an action nobody can account for. Build the write path as a transaction: record the intent, obtain the authorization, act, record the result, and treat a missing result as an incident. Decide per action type whether it is reversible, by whom, and within what window. Actions that cannot be reversed, such as an outbound email or a filed submission, should require approval by default.
Building the record into the system instead of bolting it on
Teams usually attempt this at one of two layers, and both fail structurally rather than for want of effort. The record has to be written by the same tier that performs the retrieval and enforces the permissions, which is the practical argument for a context layer rather than a set of separately procured tools.
Logging at the application layer, in the chat interface or agent framework, captures the question, the response, and the session. It misses the permission decision, which happens deeper, inside retrieval, where group memberships are resolved and candidates filtered. The application sees the survivors, never what was excluded or why, which is what an access review needs.
Logging at the model gateway, where prompts and completions pass through a proxy, captures the assembled context and model configuration faithfully and misses retrieval entirely. By the time text reaches the gateway it is a flattened payload with no document identifiers, no versions, and no trace of the candidates considered and dropped. You get the input to the model and no provenance for it.
The record has to come from the layer that does the retrieving and the permission checking, because only there are the identity, the candidate set, the policy decision, the surviving passages, and their versions all in hand at once. That layer is the context layer: the runtime tier that connects sources, carries permissions with the content, assembles passages, and hands grounded context to an agent. Evidence is not a feature you add to it. It is a byproduct of doing that job in one place.
This is the design Lucidworks takes with its AI Context Data Platform: retrieval, permission enforcement, and the answer record are produced together rather than stitched from separate systems, so every response carries the identity it ran under, the documents and versions it drew on, the entitlements applied, and the context handed to the model. Agents built on Lucidworks Studios inherit that record by default rather than by instrumentation.
A readiness checklist
- Pick one answer from last week and reconstruct it end to end. What you cannot produce is your gap list.
- Confirm each entry names a person and a named agent, not a shared service account.
- Confirm the retrieval set is recorded in full, including documents retrieved but not cited.
- Confirm each retrieved passage carries a version or content hash, not only a document identifier.
- Confirm the permission decision is recorded, including resolved groups and what was excluded.
- Confirm the exact assembled context is stored, including system instructions and tool outputs.
- Confirm the model, version, sampling settings, and prompt template version are pinned per answer.
- Confirm the log is append-only, tamper-evident, and not writable by the team that runs the system.
- Confirm the log has its own access control and that its retention comes from an existing records policy.
- For every action an agent can take, confirm the intent, policy check, approval, result, and reversal path are recorded.
Frequently asked questions
Is logging the prompt and response enough?
No. The prompt and response tell you what was said, not what the system worked from or whether the person was entitled to see it. Without the retrieval set, the versions, and the permission decision you cannot show an answer was grounded, cannot show restricted content was withheld, and cannot reconstruct the answer once the content changes. It is the easiest layer to instrument and the weakest evidence you can hold.
How long should we keep AI answer logs?
The regime you are already subject to governs it. Classify the log as a record under your existing records management policy, find the rule for that class, and follow it rather than inventing an AI-specific period. In regulated settings the period is frequently measured in years, and the storage form matters as much as the duration, so check whether your regime requires preservation in a form that cannot be overwritten.
Does this slow the system down?
The write itself is cheap and belongs on an asynchronous path, so the effect on response latency is small. The real cost is a design cost, in version-addressable content and in retaining the assembled context, which shows up in storage and connector work rather than in response time. Budget for the versioning, not the logging.
What if our content store has no version history?
Retain the retrieved passage text in the log itself, which is the common fallback. It increases storage and raises the sensitivity of the log, which is why it needs a restricted tier, but it preserves reconstruction when the source system cannot. Keeping identifiers only means accepting that answers cannot be defended once a document is edited.
Who owns the audit trail, security or the AI team?
Compliance or risk usually owns the requirement and the retention rule, security owns the integrity properties, and the platform team owns producing the record. The part that becomes nobody’s job is the periodic test, reconstructing a past answer to confirm it still works. Assign that explicitly and run it on a schedule rather than when an auditor asks.
Can we just use our existing SIEM?
Partly. A security information and event management system suits the metadata and the integrity properties well, and routing answer records to it is reasonable. It suits document content and assembled context poorly, because those are large, sensitive, and not events. The common split is metadata and decisions in the SIEM, with content in a restricted store its entries point to.