AI Agent Audit Logs: What Should Be Recorded?

The exact fields an AI agent audit log should record, a sample record, OpenTelemetry mapping, EU AI Act rules, retention and PII redaction.

Bar chart of trace retention in days: LangSmith base 14, Datadog LLM Observability 15, Arize AX Free 15, Langfuse Hobby 30, Arize AX Pro 30, Langfuse Core 90, LangSmith Cloud extended 180

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.

FieldWhat to StoreWhy It Matters
Trace and span IDOne ID for the run, one for each stepRebuilds the full chain of actions
TimestampStart and end time in UTC, ISO 8601Orders events and measures duration
Initiating identityUser ID, service account or upstream agentAnswers who asked for the action
Agent name and versionStable agent name plus release versionTies behavior to a specific build
Model and versionRequested model and the model that respondedProviders can route to a different snapshot
System prompt versionHash or version ID of the instructionsProves which rules the agent followed
InputUser message or task, redactedRecords what the agent was asked
OutputModel response and finish reasonRecords what the agent decided
Tool callTool name, call ID, arguments, result, statusRecords every action on real systems
ApprovalApprover ID, decision, time, reasonProves human oversight happened
Tokens and costInput, output, cached and reasoning tokens, costSupports budgets and anomaly alerts
ErrorError type and message, redactedExplains 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.

FieldExample Value
trace_id4bf92f3577b34da6a3ce929d0e0e4736
span_id00f067aa0ba902b7
timestamp_start / end2026-11-20T14:03:11.204Z / 2026-11-20T14:03:12.877Z
gen_ai.operation.nameexecute_tool
gen_ai.agent.name / app.agent.versionsupport-refunds / 3.4.1
gen_ai.conversation.idconv_8812
app.user.idusr_20931 (pseudonymized)
gen_ai.request.model / gen_ai.response.modelmodel requested / model snapshot returned
app.system_prompt.sha2569c1e…a7f0
gen_ai.tool.nameissue_refund
gen_ai.tool.call.idcall_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.approvalapproved by usr_311 at 14:03:09Z, reason: within policy
gen_ai.usage.input_tokens / output_tokens1,842 / 96
app.cost_usdcomputed from your provider’s price sheet
app.record_hash / app.prev_hashsha256 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.

github.com
OpenTelemetry GenAI semantic conventions repository website screenshot
OpenTelemetry GenAI Conventions

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.name to a stable, low-cardinality name, not a generated value.
  • Leave gen_ai.conversation.id unset when no real ID exists. Do not invent UUIDs or reuse trace IDs.
  • Use the _ref attributes to point at content in external storage instead of inlining it, and keep credentials out of those URIs.
  • Treat exception.message as 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.

ArticleWhoRequirementApplies From
Article 12Provider (system design)Automatic event logging over the system’s lifetime2 Dec 2027 (Annex III), 2 Aug 2028 (Annex I)
Article 19ProviderKeep logs at least six months2 Dec 2027 (Annex III), 2 Aug 2028 (Annex I)
Article 26(6)DeployerKeep logs at least six months2 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.

ToolDefault or Entry RetentionLonger Options
LangSmith14 days base retention180 days extended on Cloud, 400 days on BYOC and self-hosted
Datadog LLM Observability15 days on all plansAdd-on for 30, 60 or 90 days
Arize AX15 days on AX Free30 days on AX Pro ($50 a month), configurable on Enterprise
Langfuse30 days on Hobby90 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.

Bar chart of trace retention in days: LangSmith base 14, Datadog LLM Observability 15, Arize AX Free 15, Langfuse Hobby 30, Arize AX Pro 30, Langfuse Core 90, LangSmith Cloud extended 180
Chart: AI Agents Choice

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.

langfuse.com
Langfuse data masking documentation website screenshot
Langfuse Masking Docs

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

Joydeep Bhattacharya Avatar

Written by