An AI agent audit trail is a time-ordered, tamper-evident record of what an agent did on each run: what happened, when and where, from what source, with what outcome and under whose identity, plus each tool call and the model output that proposed it. That last part separates it from an ordinary application log. It is what lets you answer why the agent acted, which incident response and compliance audits both depend on.

The hard part is identity. When an agent acts with a user's delegated session or token, a plain log attributes every action to the user. The OWASP Top 10 for Agentic Applications for 2026 says an agent without its own governed identity "operates in an attribution gap". This guide sets out a logging design for production agents: what to log, a schema, what the EU AI Act requires, how long to keep logs, and how to make them credible to auditors.

On this page
  1. Key takeaways
  2. What to log
  3. Log schema
  4. Acting on behalf of a user
  5. Audit trail vs traces
  6. EU AI Act logging
  7. Retention
  8. Tamper-evident design
  9. Redaction and PII
  10. Access controls
  11. Common mistakes
  12. Incident response
  13. Compliance mapping
  14. FAQ

For the operational view of what to do when the audit trail tells you the agent misbehaved, see how to debug an agent that did the wrong thing. For broader monitoring concerns, see AI agent monitoring and observability.

An abstract row of linked grey blocks, each topped with an orange block, suggesting a chain of logged agent events.

What to log

Five categories cover what an audit record has to answer. NIST SP 800-53 Rev. 5 (OSCAL catalog, JSON) control AU-3 asks every audit record to establish what type of event occurred, when and where it occurred, its source, its outcome, and the identity of any individuals, subjects, or objects/entities associated with it. For an agent, that turns into five things to capture on every run.

  • Identity. Which user started the run, which tenant they belong to, which agent and version is running, which prompt hash, and the user the agent acted for if that is someone else. Without identity, no other field means much in an audit.
  • Inputs. The request that started the run, every tool result the agent read and every document it retrieved. Store the system prompt as a hash; the hash lets you look up the full prompt in the prompt store.
  • Decisions. Each tool call with its arguments, the model output that proposed it (or a hash of it, with the full output in a separate store), any policy check and its result, and the reasoning trace if your provider exposes one.
  • Outcomes. What each tool returned, errors and retries, and the final answer the agent gave the user.
  • Approvals. Every human-in-the-loop checkpoint: who approved, at what timestamp, with what comment. For approval design, see how to add a human approval step to an agent.

Log schema

Write one row per event, with many events per run. The schema below covers the five categories, the on-behalf-of fields described in the next section, and the hash chain.

FieldTypeNotes
event_iduuidUnique per event
run_iduuidGroups events into a single agent run
timestampiso8601 with tzServer-side, not client
tenant_idstringTenant scope, indexed
user_idstringThe person who started the run
on_behalf_of_user_idstringThe user whose authority the action used; can differ from user_id
agent_idstringPersistent agent identifier
agent_versionstringDeployed version or git hash
prompt_hashstringSHA-256 of the system prompt
credential_scopestringToken ID and scope the action ran under (never the secret itself)
event_typeenuminput, retrieval, model_call, tool_call, tool_result, policy_decision, approval, handoff, error, output
policy_decisionenumALLOW, DENY, MODIFY, STEP_UP, DEFER
approval_stateenumnot_required, pending, approved, rejected; approver ID in the payload
payloadjsonbType-specific data (redacted)
prev_hashstringHash of prior event for chain validation

The schema fits Postgres with a jsonb payload column. For higher volumes, append to S3 or equivalent with daily compaction, and keep an index in a queryable store for the working window. Sampling, hot and cold tiers and a canonical log schema for a whole fleet are covered in more depth in AI agent log aggregation patterns.

Logging actions an agent takes on behalf of a user

An agent that acts for a user usually holds that user's authority in some form: an OAuth token, a delegated session, an API key issued to a team. If the log records only the user, every action looks as if the user took it by hand. OWASP's agentic Top 10 files this under ASI03, Identity and Privilege Abuse: "Without a distinct, governed identity of its own, an agent operates in an attribution gap that makes enforcing true least privilege impossible."

The fix is to record two identities on every action, plus how the agent got its authority:

  • The agent. agent_id and agent_version, so each action traces back to a specific build.
  • The principal. on_behalf_of_user_id, the user whose authority the action used. It can differ from user_id, the person who started the run.
  • The credential. credential_scope, the token ID and scope the call ran under. OWASP recommends "short-lived, narrowly scoped tokens per task" and binding OAuth tokens "to a signed intent that includes subject, audience, purpose, and session". Those controls only help an investigation if the log says which token was used.
  • The approval. approval_state and the approver. OWASP's list also says to "require human approval for high-privilege or irreversible actions".
  • The policy check. policy_decision, the result of any rule evaluated before the action ran.

NIST SP 800-53 control AU-10 states the same goal in control language: "irrefutable evidence that an individual (or process acting on behalf of an individual) has performed" a defined action. A NIST draft concept paper from February 2026, "Accelerating the Adoption of Software and AI Agent Identity and Authorization", lists the open questions, including "How do we handle delegation of authority for 'on behalf of' scenarios?" and how to bind agent actions "back to human authorization". The paper asks for comments, so read it as a map of unsolved problems.

For the policy_decision values, the schema above borrows from AARM (Autonomous Action Runtime Management), a specification written by Herman Errico of Vanta and now developed in a Cloud Security Alliance working group. Version 1.0, published in February 2026, requires a tamper-evident receipt for every evaluated action (R5), cryptographic binding of each receipt to an agent identity (R6), and a policy engine that can return one of five decisions: ALLOW, DENY, MODIFY, STEP_UP or DEFER (R4). CSA itself calls AARM "a work in progress" and warns against overstating its maturity, so treat the five decisions as a handy vocabulary. For scoping the credentials themselves, see AI agent security best practices.

How is an audit trail different from observability traces?

Observability traces show how a run behaved so you can fix it. An audit trail has to show what happened, months later, to someone with reason to doubt you. The two can share a pipeline, but the defaults of today's telemetry conventions do not produce an audit record.

The OpenTelemetry GenAI semantic conventions define a shared vocabulary for agent telemetry. As of October 2026 they live in their own repository, semantic-conventions-genai, and the old pages on opentelemetry.io carry a "Moved" notice. Every gen_ai attribute is still marked Development. The conventions define agent spans such as invoke_agent and execute_tool, operations including plan and retrieval, and attributes such as gen_ai.agent.id, gen_ai.agent.version, gen_ai.tool.name and gen_ai.tool.call.id, which is required only when the model or provider supplied a tool call ID.

Content is where the gap shows. Model instructions, user messages and model outputs "are considered sensitive", and instrumentations "SHOULD NOT capture them by default". Tool call arguments and results are opt-in attributes that "may contain sensitive information". A default trace can therefore show that a tool ran without showing the arguments or the model output that chose it. For production setups where telemetry volume or sensitive data is a concern, the conventions recommend storing content externally and recording references on the spans, because "external storage enables separate access controls". That external store is a natural home for the full-fidelity tier of an audit trail.

Vendor consoles have limits of their own. OpenAI saves Response objects for 30 days by default, and setting store to false turns that off (OpenAI documentation). Its tracing dashboard shows each step's inputs, outputs, duration and status, and the API returns traces as OTLP JSON. Treat both as feeds into a store you own, with your own retention and access rules. For the operational side of telemetry, see AI agent monitoring and observability.

What the EU AI Act requires you to log

The EU AI Act puts logging duties on high-risk AI systems only, so the first question is whether your agent is part of one. Annex III lists the areas. Point 4 covers employment, including recruitment, filtering applications, evaluating candidates, decisions on promotion or termination and monitoring performance. Point 5(b) covers systems that evaluate the creditworthiness of natural persons or establish their credit score, except those used to detect financial fraud. An agent that filters job applications can land in scope. If your agent is not part of a high-risk system, the duties below do not bind it, though the design in this guide still works as a baseline.

What Article 12 asks for

Article 12(1) says high-risk systems "shall technically allow for the automatic recording of events (logs) over the lifetime of the system". Article 12(2) says what the logs are for: recording events relevant to (a) identifying situations where the system may present a risk or undergo a substantial modification, (b) post-market monitoring, and (c) the deployer's monitoring of the system's operation under Article 26(5).

Notice what is missing: a field list. The minimum fields in Article 12(3), such as the period of each use and the input data that led to a match, apply only to the remote biometric identification systems in Annex III point 1(a). For every other high-risk system, the Act states the purposes and leaves the fields to you. The schema above is one way to cover them.

The six-month floor

Providers must keep the automatically generated logs, "to the extent such logs are under their control", for a period appropriate to the system's intended purpose, "of at least six months" (Article 19(1)). Deployers carry the same duty under Article 26(6). Both rules give way to other EU or national law, "in particular in Union law on the protection of personal data", and financial institutions keep the logs as part of the documentation financial services law already requires (Articles 19(2) and 26(6)).

Two details trip people up. Article 18's ten-year rule covers the provider's technical and quality-management documentation; logs fall under Article 19. And six months is a floor: a period "appropriate to the intended purpose" can be longer. Once these duties apply, breaches of the deployer obligations in Article 26 can draw administrative fines (Article 99(4)(e)).

When the duties start

The dates moved this year. The Digital Omnibus on AI, Regulation (EU) 2026/1744 of 8 July 2026, was published in the Official Journal on 24 July 2026 and has been in force since 27 July 2026 (European Commission). It replaced the application dates for Chapter III, Sections 1 to 3, which contain Articles 12, 19 and 26:

  • 2 December 2027 for high-risk systems listed in Annex III, such as recruitment and credit scoring.
  • 2 August 2028 for high-risk AI embedded in products covered by Annex I, such as machinery, toys and lifts.

The Omnibus left the text of the logging articles unchanged. A guide that still gives an August 2026 start for high-risk logging predates it. For the rest of the timeline and the other obligations, see AI agents and the EU AI Act; for who should own these duties inside a company, see AI agent governance and compliance.

Retention

Retention is set by the strictest rule that applies to you. Several of the rules people cite for agent logs say less than they are usually quoted as saying, so here is what each one covers.

  • EU AI Act (high-risk systems only). At least six months for providers and deployers, for logs under their control (Articles 19(1) and 26(6)), from 2 December 2027 for Annex III systems and 2 August 2028 for Annex I products.
  • HIPAA. The Security Rule requires audit controls that "record and examine activity" in systems holding electronic protected health information (45 CFR 164.312(b)) but sets no retention period for the logs themselves. Its six-year rule (45 CFR 164.316(b)(2)(i)) applies to the documentation the Security Rule requires: policies, procedures and records of required actions, activities or assessments.
  • GDPR. No number. Article 5(1)(e) says personal data must be kept "in a form which permits identification of data subjects for no longer than is necessary for the purposes for which the personal data are processed" (GDPR). Personal data inside your logs falls under the right of access (Article 15). Where an agent makes automated decisions of the kind covered by Article 22, the person can also ask for "meaningful information about the logic involved" (Article 15(1)(h)), which is easier to give if the trail records the decision path. The separate Digital Omnibus on data and privacy rules is still a proposal (European Commission), so the GDPR applies as written.
  • US broker-dealers. SEC Rule 17a-4 requires certain records to be kept for at least six years, the first two in an easily accessible place (17 CFR 240.17a-4).
  • SOX. The SEC's Sarbanes-Oxley rule on record retention (17 CFR 210.2-06) requires the auditor to keep audit and review workpapers for seven years. It sets no retention period for your agent's own logs. If you are the auditor deciding whether AI can touch those workpapers, we cover the tools and the standards in AI for auditors.
  • PCI DSS. The current version of the standard is v4.0.1 (PCI Security Standards Council document library). If an agent touches cardholder data, take any logging and retention terms from that version directly.

SOC 2 is a separate conversation with your auditor; AI agent SOC 2 compliance covers what they check.

When no rule applies, our recommended default is 13 months hot plus 12 months in cold storage. That figure is our house recommendation, and no law requires it. It also clears the EU AI Act's six-month floor, should a system later turn out to be high-risk.

Cold storage keeps the long tail affordable, though the savings depend on the class. On AWS list prices for US East (N. Virginia), as of October 2026:

S3 storage classPrice per GB-monthCheaper than S3 Standard
S3 Standard (first 50 TB)$0.023Baseline
S3 Standard-IA$0.0125About 1.8x
S3 Glacier Instant Retrieval$0.004About 5.8x
S3 Glacier Flexible Retrieval$0.0036About 6.4x
S3 Glacier Deep Archive$0.00099About 23x

The Glacier classes bill a minimum storage duration: 90 days for Instant Retrieval and Flexible Retrieval, 180 days for Deep Archive (Amazon S3 pricing). A 12-month cold tier sits well past both minimums.

Tamper-evident design

Auditors and incident responders need confidence that logs were not changed after the fact. Two layers provide it: storage that refuses changes, and a hash chain that exposes any change that gets through. NIST SP 800-53 names both goals. AU-9 asks you to protect audit information "from unauthorized access, modification, and deletion", and AU-9(3) asks for "cryptographic mechanisms to protect the integrity of audit information and audit tools".

Append-only storage. The log table has no UPDATE or DELETE permission for the agent service account, and changes require a separate, audited role. At the database layer, Postgres with UPDATE and DELETE revoked from the application role does this. At the storage layer, AWS S3 Object Lock uses "a write-once-read-many (WORM) model", and in compliance mode "a protected object version can't be overwritten or deleted by any user, including the root user". Use compliance mode, not governance mode, for an audit store.

Hash chain. Each log entry includes prev_hash, the SHA-256 of the previous entry. A separate daily job computes the chain hash for the day and signs it with a key the agent service cannot reach. The signed digest goes to a bucket in a separate account or a separate audit system.

Detection. Verify the chain on a schedule. Changing any entry breaks the next entry's prev_hash link, and rewriting the later hashes to hide it no longer matches the signed daily digest; a single O(n) pass finds either. AWS CloudTrail log file integrity validation uses the same design: SHA-256 for hashing, SHA-256 with RSA for signing, an hourly digest file that "contains a hash of each" log file from the last hour, and the previous digest's signature inside each new one. That chaining lets validation tools detect a deleted digest. Sigstore's Rekor applies the idea to software supply-chain metadata, as "an immutable, tamper-resistant ledger".

OWASP's agentic Top 10 asks for the same property in agent terms (ASI08): record "inter-agent messages, policy decisions, and execution outcomes in tamper-evident, time-stamped logs bound to cryptographic agent identities".

Redaction and PII

Log destinations often have broader access than the source system. A support engineer who can read agent logs but not customer email is a common access topology. Redact before storage. Common redactions:

  • Email bodies, cut down to subject, sender and recipients.
  • Customer records, cut down to record ID and operation.
  • Free-text user messages, with PII patterns (email addresses, phone numbers, SSNs, credit-card numbers) masked.
  • Tool results that contain PII, stored separately with stricter access.

Incident response sometimes needs the unredacted record, so we recommend two tiers, redacted and full-fidelity, with every read of the full-fidelity tier audited. The OpenTelemetry GenAI conventions point the same way: they recommend storing prompts and outputs externally in production because "external storage enables separate access controls". For redaction at write time and retention by data class, see AI agent log aggregation patterns.

Access controls

Three roles cover the audit trail, and each one gets the least access its job allows:

  • Agent service account. Append-only. It cannot read its own historical entries, delete them or change them.
  • Support and engineering. Read access to the redacted tier only. Their reads are logged.
  • Audit and security. Read access to the full-fidelity tier. Their reads are logged to a separate system.

Logged reads close the audit-of-the-audit gap: someone with log access cannot look up specific data without leaving a trail. NIST SP 800-53 AU-9(4) adds a related rule, limiting access to the management of audit logging to a defined subset of privileged users.

Common mistakes

  • Logging actions but not decisions. The audit shows "agent refunded $500" but not the model output that proposed the refund, so the trail cannot answer why.
  • One identity for agent and user. The agent acts with the user's token and the log records only the user. That is the attribution gap OWASP describes; record both identities.
  • Same access for service and humans. The agent service has DELETE on the log table. One bug deletes evidence at the moment you need it.
  • No retention policy. The team builds the logger and never decides how long to keep entries. Storage costs pile up, and auditors find no stated retention period.
  • Logs in the same database as the data they describe. A database compromise that reaches production data also reaches the audit trail. Separate the audit store, even if the rest of the architecture is monolithic.
  • A vendor dashboard as the record. OpenAI keeps Response objects for 30 days by default, and storage can be switched off.

Reading the trail during incident response

An audit trail earns its keep when something has gone wrong. Three patterns make the trail readable under pressure. For a step-by-step review of one agent's past decisions, see how to audit an AI agent's decision history.

Run-scoped views. The first action in any investigation is "show me everything from run X." This requires run_id to be indexed and the UI to filter on it in one click. Trails that need a SQL query to assemble a run view slow incident response by minutes that count.

Decision diff. When two runs of the same task produced different outcomes, the question is what the model decided differently. A side-by-side view of the tool calls in both runs is worth building early. Build it once and use it in every incident.

Replay-on-trace. Some agent frameworks let you re-execute an agent against a recorded prompt and tool-result trace, producing a new model output for comparison. It depends most on capturing inputs: without recorded tool results there is nothing to replay. In LangGraph, replay resumes from a saved checkpoint: nodes before it are not re-executed, but everything after it runs again, including LLM calls and API requests, so replay a trace only against sandboxed tools, never live ones. For the failure patterns these reviews tend to surface, see AI agent failure modes.

Mapping the trail to compliance controls

Auditors work faster when the trail maps to the control language they use. The table below is our mapping of the schema to controls whose text is public: the EU AI Act's logging purposes, the NIST SP 800-53 Rev. 5 audit controls, the logging mitigations in OWASP's agentic Top 10, and the nearest OpenTelemetry GenAI name. Treat it as the first draft of the one-page table you hand an auditor, and reuse it every cycle.

Field or practiceEU AI Act (high-risk)NIST SP 800-53 Rev. 5OWASP agentic Top 10 (2026)OTel GenAI name (Development)
event_type, timestamp, outcome in payloadArt 12(2)(a) to (c)AU-3ASI08: time-stamped logs of execution outcomesgen_ai.operation.name
agent_id, agent_version, prompt_hashArt 12(2)(a): substantial modificationAU-3 (identity)ASI08: logs bound to agent identitiesgen_ai.agent.id, gen_ai.agent.version
on_behalf_of_user_id, credential_scopeArt 12(2)(c)AU-10ASI03: short-lived, narrowly scoped tokensNot mapped
tool_call events with argumentsArt 12(2)(a)AU-3ASI02: immutable logs of all tool invocationsgen_ai.tool.name, gen_ai.tool.call.id, gen_ai.tool.call.arguments (opt-in)
handoff events between agentsArt 12(2)(a)AU-3ASI08, ASI10: inter-agent messagesinvoke_agent operation
policy_decision, approval_stateArt 12(2)(c)AU-10ASI08: policy decisions; ASI03: human approval for high-privilege actionsNot mapped
prev_hash and signed digestNot specifiedAU-9, AU-9(3)ASI10: immutable, signed audit logsNot mapped
Append-only writer, logged readsNot specifiedAU-9, AU-9(4)ASI09: tamper-proof records of queries and actionsNot mapped
Retention policyArts 19(1) and 26(6): at least six monthsAU-11Not specifiedNot mapped

Two notes on status. The NIST AI Risk Management Framework "is intended for voluntary use", and NIST says AI RMF 1.0 "is being revised", so cite it as guidance for good practice. NIST has also published no final agent logging profile yet. Its SP 800-53 control overlays for AI, first called COSAiS, were renamed SP 800-53 Control Overlays for Super Intelligence Systems (COSIS) under a 29 September 2026 Executive Order, and they remain at concept-paper and outline stage. For the rest of an audit-prep list, see the AI agent compliance audit checklist.

Frequently asked questions

What should an AI agent audit trail include?

Five categories. Identity: which user, which tenant, which agent and version, and the user the agent acted for. Inputs: the request and every tool result or retrieved document that shaped a decision. Decisions: each tool call with its arguments and the model output that proposed it. Outcomes: what each tool returned and the final answer. Approvals: who approved any human-in-the-loop step and when. NIST SP 800-53 control AU-3 asks the same of any audit record: what happened, when, where, from what source, with what outcome, and who or what was involved.

How long should I keep AI agent audit logs?

Follow the strictest rule that applies. For high-risk AI systems, the EU AI Act says providers and deployers must keep automatically generated logs, to the extent they control them, for at least six months (Articles 19 and 26(6)); after the AI Omnibus those duties apply from 2 December 2027 for Annex III systems. HIPAA requires audit controls but sets no log retention period; its six-year rule covers required Security Rule documentation. GDPR sets no number but says personal data must be kept no longer than necessary. With no rule in play, our recommended default is 13 months hot plus 12 months in cold storage.

How do I make AI agent logs tamper-evident?

Write to append-only storage and chain the entries: each event carries the hash of the previous one, and a separate job signs a periodic digest with a key the agent cannot reach. AWS CloudTrail works this way, with SHA-256 hashes, hourly digest files signed with SHA-256 with RSA, and each digest carrying the signature of the one before. For storage-level protection, S3 Object Lock in compliance mode stops any user, including the root user, from overwriting or deleting a locked object version.

Should AI agents log every model call?

Yes, with personal data redacted. Log the prompt hash, model identifier, token counts, latency and a redacted excerpt, and keep full prompts and outputs in a separate store with tighter access. The OpenTelemetry GenAI conventions recommend the same split for production. Do not rely on a vendor dashboard as your record: OpenAI keeps Response objects for 30 days by default, and storage can be switched off.

What is a common mistake in AI agent audit logging?

In our view, it is logging the action but not the decision that drove it. A trail that records 'user asked for a $500 refund' and 'agent issued refund', without the tool call and the model output that proposed it, cannot answer why the agent acted. Log the model's tool-call output next to every action it caused.

Does the EU AI Act require audit logs for AI agents?

Only when the agent is part of a high-risk AI system, for example one used to screen job applicants or check creditworthiness (Annex III). Article 12 says high-risk systems must allow 'the automatic recording of events (logs) over the lifetime of the system'. Providers (Article 19) and deployers (Article 26(6)) must keep those logs, where they control them, for a period that fits the system's purpose and is at least six months, unless other EU or national law, in particular data protection law, says otherwise. The AI Omnibus, Regulation (EU) 2026/1744, in force since 27 July 2026, moved the start of these duties to 2 December 2027 for Annex III systems and 2 August 2028 for Annex I products. It did not change the logging articles themselves.

How do I implement an audit trail for actions an AI agent takes on behalf of a user?

Record two identities on every action: the agent's own (ID and version) and the user it acted for, plus the credential or scope it used and any approval. OWASP's Top 10 for Agentic Applications (2026) warns that an agent without 'a distinct, governed identity of its own' works in 'an attribution gap', and recommends short-lived, task-scoped tokens. NIST SP 800-53 control AU-10 asks for evidence that an individual 'or process acting on behalf of an individual' performed an action. Then make the record tamper-evident: OWASP calls for 'immutable and signed audit logs of all agent actions, tool calls, and inter-agent communication'.

Three things to ship this week

  • Lock down write permissions. The agent service account can only append; no service can modify historical entries.
  • Add prev_hash and on_behalf_of_user_id to every event. Then build the daily digest job.
  • Set a retention period and put the cold-storage move in code. If an agent works in an Annex III area such as hiring or credit scoring, plan for the EU AI Act's six-month floor from 2 December 2027.

Sources

All sources were current as of October 2026.

Share