An AI agent audit log should record, for every step of a run, who started it, which model and version answered, the prompt and output, each tool call with its arguments and result, any human approval, timestamps and token cost, all tied together by one trace ID. For high-risk systems under the EU AI Act, deployers must keep those automatically generated logs for at least six months. Most observability tools keep traces for far less by default, so retention is a design choice you have to make on purpose.
Agent logs are different from web app logs. One user request can fan out into a dozen model calls and tool calls, some of which change real systems. The OpenTelemetry GenAI semantic conventions give those steps a shared vocabulary, from invoke_agent spans down to execute_tool spans, so you can name fields once and send them to any backend.
Below is the exact field list, a sample record, how it maps to OpenTelemetry, what the EU AI Act, NIST AI RMF and SOC 2 expect, and how to handle retention, tamper-evidence and PII. For the security side of the same problem, see our guide to AI agent guardrails.
The 12 Fields Every AI Agent Audit Record Needs
The classic logging rule still applies: record when, where, who and what for each event. For agents, “what” splits into the model call, the tool call and the human decision. Log each as its own event, linked by trace and span IDs.
| Field | What to Store | Why It Matters |
|---|---|---|
| Trace and span ID | One ID for the run, one for each step | Rebuilds the full chain of actions |
| Timestamp | Start and end time in UTC, ISO 8601 | Orders events and measures duration |
| Initiating identity | User ID, service account or upstream agent | Answers who asked for the action |
| Agent name and version | Stable agent name plus release version | Ties behavior to a specific build |
| Model and version | Requested model and the model that responded | Providers can route to a different snapshot |
| System prompt version | Hash or version ID of the instructions | Proves which rules the agent followed |
| Input | User message or task, redacted | Records what the agent was asked |
| Output | Model response and finish reason | Records what the agent decided |
| Tool call | Tool name, call ID, arguments, result, status | Records every action on real systems |
| Approval | Approver ID, decision, time, reason | Proves human oversight happened |
| Tokens and cost | Input, output, cached and reasoning tokens, cost | Supports budgets and anomaly alerts |
| Error | Error type and message, redacted | Explains failed or partial runs |
Two fields get skipped most often. The first is the response model, which can differ from the requested model, so log both. The second is the system prompt version. Without it you cannot prove which instructions were live when the agent acted, which is the first question in any incident review.
A Sample Log Record for One Agent Tool Call
Here is what a single execute_tool record could look like for a support agent issuing a refund that needed approval. Values are illustrative. Field names follow OpenTelemetry where a convention exists and use an app. prefix where it does not.
| Field | Example Value |
|---|---|
| trace_id | 4bf92f3577b34da6a3ce929d0e0e4736 |
| span_id | 00f067aa0ba902b7 |
| timestamp_start / end | 2026-11-20T14:03:11.204Z / 2026-11-20T14:03:12.877Z |
| gen_ai.operation.name | execute_tool |
| gen_ai.agent.name / app.agent.version | support-refunds / 3.4.1 |
| gen_ai.conversation.id | conv_8812 |
| app.user.id | usr_20931 (pseudonymized) |
| gen_ai.request.model / gen_ai.response.model | model requested / model snapshot returned |
| app.system_prompt.sha256 | 9c1e…a7f0 |
| gen_ai.tool.name | issue_refund |
| gen_ai.tool.call.id | call_7Hq2 |
| gen_ai.tool.call.arguments | {“order_id”:”A-5531″,”amount”:49.00,”currency”:”EUR”} |
| gen_ai.tool.call.result | {“status”:”refunded”,”refund_id”:”rf_119″} |
| app.approval | approved by usr_311 at 14:03:09Z, reason: within policy |
| gen_ai.usage.input_tokens / output_tokens | 1,842 / 96 |
| app.cost_usd | computed from your provider’s price sheet |
| app.record_hash / app.prev_hash | sha256 of this record / sha256 of previous record |
Notice what is missing: no email address, no card number and no raw session token. The user is a pseudonymous ID, and the prompt is stored as a hash plus a version. Keep the raw prompt text in a separate, access-controlled store if you need it for replay.
Mapping Fields to OpenTelemetry GenAI Semantic Conventions
The GenAI conventions are still marked Development, so names can change. On the invoke agent span, gen_ai.operation.name is required, while the request model, token usage and finish reasons are recommended. Message content, system instructions and tool definitions are opt-in because they may contain PII.
The execute_tool span requires gen_ai.tool.name and recommends gen_ai.tool.type and gen_ai.tool.description. gen_ai.tool.call.id is conditionally required when the provider supplies one. Arguments and results are opt-in, which is the right default for audit: turn them on deliberately and redact first.

Model calls use the client inference span, where gen_ai.provider.name is required and gen_ai.response.id, gen_ai.response.model and token counts are recommended. Input tokens should include cached tokens, and output tokens should include reasoning tokens, so do not add cache counts on top when you compute cost.
- Set
gen_ai.agent.nameto a stable, low-cardinality name, not a generated value. - Leave
gen_ai.conversation.idunset when no real ID exists. Do not invent UUIDs or reuse trace IDs. - Use the
_refattributes to point at content in external storage instead of inlining it, and keep credentials out of those URIs. - Treat
exception.messageas possibly sensitive.
Read also: The Research Before the Draft: Which AI Agent Should Find Your Next Topic?
EU AI Act Article 12 and Article 19 Record-Keeping Rules
Article 12 requires high-risk AI systems to technically allow automatic recording of events over the lifetime of the system. Logs must capture events relevant to spotting risks or substantial modifications, post-market monitoring, and monitoring of operation by the deployer.
For remote biometric identification systems under Annex III point 1(a), the minimum is spelled out: the period of each use with start and end dates and times, the reference database checked, the input data that produced a match, and the identity of the people who verified the results. That last item is a direct template for agent approvals: record who checked the output.
Retention sits in two places. Providers must keep logs under their control for a period appropriate to the intended purpose of at least six months, and Article 26(6) sets the same floor for deployers. Financial institutions can fold these logs into documentation they already keep under EU financial services law.
| Article | Who | Requirement | Applies From |
|---|---|---|---|
| Article 12 | Provider (system design) | Automatic event logging over the system’s lifetime | 2 Dec 2027 (Annex III), 2 Aug 2028 (Annex I) |
| Article 19 | Provider | Keep logs at least six months | 2 Dec 2027 (Annex III), 2 Aug 2028 (Annex I) |
| Article 26(6) | Deployer | Keep logs at least six months | 2 Dec 2027 (Annex III), 2 Aug 2028 (Annex I) |
Not every agent is high-risk. But if yours touches hiring, credit, education or other Annex III areas, build these fields in now. Retrofitting logging after launch is far harder than adding it on day one.
Where Logs Fit in NIST AI RMF and SOC 2
NIST’s Generative AI Profile, NIST AI 600-1, published July 26, 2024, is a voluntary companion to AI RMF 1.0. It covers 12 risks, including confabulation, data privacy, information security and human-AI configuration. Several actions map straight to logging.
- GV-1.5-003: maintain a document retention policy to keep the history of testing, evaluation, validation and verification.
- GV-4.3-002: define minimum incident reporting fields, such as system ID, date of incident, description and impacts.
- GV-6.1-008: keep records of changes made by third parties, with sources, timestamps and metadata.
- MS-2.8-003: create a tamperproof history of content and use version control across the AI lifecycle.
- MP-3.4-005: monitor and track the outcomes of human and generative AI configurations.
SOC 2 is less specific about AI, but auditors still look at logs. The AICPA’s 2017 Trust Services Criteria cover five categories, and Security is required in every SOC 2 audit. Its system operations controls address detecting anomalies that may indicate malicious acts and responding to incidents. An agent that can call tools is a system component, so its actions belong in the same monitored, access-controlled log pipeline as the rest of your stack.
In practice, an auditor will ask three things: can you show who did what, can you prove the log was not altered, and do you review it. Make sure your agent logs answer all three. Vendors such as Vanta and Drata can collect that evidence for a SOC 2 audit.
Retention Periods: Tool Defaults vs Legal Minimums
Trace retention in observability tools is short by default. That is fine for debugging but not for audit. The table compares the main tools for agent tracing.
| Tool | Default or Entry Retention | Longer Options |
|---|---|---|
| LangSmith | 14 days base retention | 180 days extended on Cloud, 400 days on BYOC and self-hosted |
| Datadog LLM Observability | 15 days on all plans | Add-on for 30, 60 or 90 days |
| Arize AX | 15 days on AX Free | 30 days on AX Pro ($50 a month), configurable on Enterprise |
| Langfuse | 30 days on Hobby | 90 days on Core ($29 a month), 3 years on Pro ($199 a month) |
In LangSmith, traces move to extended retention when feedback is logged with extend_trace_retention=true or when online evaluators and automation rules with extension enabled match them. Once a trace expires, its inputs and outputs are deleted shortly after.

The practical answer is two tiers. Keep full traces in your observability tool for debugging. Export the audit fields from the table above to storage you control, with retention set to your legal floor, which for EU high-risk systems is at least six months.
Making Agent Logs Tamper-Evident
An audit log you can edit quietly is not evidence. Build in tamper detection so you know when a record changes or disappears, copy logs to read-only media as soon as possible, and log every access to the logs themselves.
Hash chaining is the standard technique. AWS CloudTrail, for example, hashes every log file with SHA-256, writes an hourly digest file that holds those hashes, signs it with RSA, and includes the previous digest’s signature in each new one. Deleting or editing any file breaks the chain. You can copy the idea for agent logs with a record_hash and prev_hash on each record, as in the sample above.
Pair hashing with write-once storage. S3 Object Lock uses a write-once-read-many model. In compliance mode, no user, including the root user, can delete or overwrite a locked object version or shorten its retention. Governance mode allows overrides with a special permission, which is useful for testing before you switch to compliance mode.
- Write audit records to a separate account or bucket the agent cannot reach.
- Chain record hashes and anchor the latest hash somewhere else on a schedule.
- Lock storage for at least your retention floor.
- Sync clocks on every host so timestamps can be trusted.
Redacting PII Before Logs Leave Your App
Agent prompts are full of personal data, so redact before export, not after. Never log session identifiers, access tokens, passwords, connection strings, encryption keys or payment card data in the clear. Mask, hash or drop them, and use pseudonyms where you do not need a real identity.
Most tools support masking at the source. In Langfuse, masking runs client-side in the SDK, so only redacted values are exported. The Python mask_otel_spans hook can patch any OpenTelemetry span attribute, including spans from third-party instrumentations. With plain OpenTelemetry, you can also redact centrally in a Collector with its attributes, redaction or transform processors.

Datadog LLM Observability connects to Sensitive Data Scanner to find and redact personal, financial or proprietary details at any step, and its access controls can restrict data by team, role or the ml_app tag. Whatever tool you use, test masking with real-looking samples before launch, and keep the redaction rules under version control so an auditor can see what was removed.
For the wider risk picture, read our guide to AI agent data leakage.
Questions Compliance Teams Ask About AI Agent Audit Logs
Should Full Prompts and Responses Go in the Audit Log?
Store a hash and a version of the prompt in the audit log, and keep full text in a separate, access-controlled store if you need replay. OpenTelemetry makes message content opt-in for this reason, since it often contains PII.
How Long Should AI Agent Logs Be Kept?
For high-risk systems under the EU AI Act, at least six months. Other law, such as financial or data protection rules, can set a different period. Debug traces can expire sooner than audit records.
Is OpenTelemetry Stable Enough to Use for Agent Logs?
The GenAI conventions are still in Development, so attribute names can change. Use them anyway, pin your instrumentation versions, and map fields in one place so renames are easy.
What Makes an Agent Log Tamper-Evident?
Hash chaining, where each record includes the hash of the previous one, plus write-once storage such as S3 Object Lock in compliance mode. Restrict and log access to the logs too.
Which Tools Help Track Agent Activity for Compliance?
Tracing tools like Langfuse, LangSmith, Datadog and Arize capture the runs, while your own storage holds the long-term audit copy. Browse our list of compliance monitoring AI agents for more options.
Related AI Agents
Read also: Perplexity Comet vs Opera Neon: Which AI Browser Should You Use?
Explore Agent Categories
Related Articles
GuidesDuplicates, Typos and Broken Dates: Which AI Agent Should Clean Your Data?
GuidesThe Research Before the Draft: Which AI Agent Should Find Your Next Topic?
ComparisonsPerplexity Comet vs Opera Neon: Which AI Browser Should You Use?
ComparisonsLovable vs v0: Which AI App Builder Should You Use?
NewsZapier Agents Is Now AI by Zapier: What Changed and What Users Should Do
GuidesHow to Protect Sensitive Data in AI Agent Workflows




