What an audit log of an AI agent's actions should record, and how to protect it
In short
For every agent step, record when it happened, which customer and run it belonged to, who started it, what the agent did to which target, and the outcome. Keep the log append-only and tamper-evident, scoped per customer, free of secrets, and kept for a stated period.
An agent audit log is a record of every action an AI agent took on a customer's behalf, written so that someone who was not watching can later tell what happened, in what order, why it was allowed and what it changed. When your agent works inside customers' apps, it is the evidence you hand over after an incident and the first artifact a customer's security team asks to see.
Why does an AI agent need an audit log of its own?
An AI agent needs its own audit log because its actions are chosen at run time, not written in advance, so no other record shows what it actually did. The UK National Cyber Security Centre, writing about prompt injection, advises: "You should therefore be logging enough information to identify suspicious activity", covering inputs, outputs and tool or API use (NCSC, Prompt injection is not SQL injection, read 2026-11-26).
The record answers three questions a customer will ask after something goes wrong: which runs touched our app, what exactly did they do, and could anything have reached another customer.
What fields should each audit record contain?
Each audit record should contain when, where, who and what, plus the agent-specific context that makes it useful. The OWASP Logging Cheat Sheet's rule is that "The application logs must record "when, where, who and what" for each event" (OWASP Logging Cheat Sheet, read 2026-11-26). NIST SP 800-53 control AU-3 lists the same content: "What type of event occurred", "When the event occurred", "Where the event occurred", "Source of the event", "Outcome of the event", and the "Identity of any individuals, subjects, or objects/entities associated with the event" (NIST SP 800-53 Rev. 5, read 2026-11-26).
Table: Fields for an AI agent audit record
| Field | Example | Why it matters |
|---|---|---|
| Event time and log time | 2026-11-26T09:14:03.218Z | Order of events; OWASP notes the two can differ |
| Tenant ID (server-verified) | acme | Scopes the record and its readers |
| Run ID and step number | run-7f3c, step 42 | Ties actions into one sequence |
| Initiator | API key ID, user ID or schedule | Who asked for the run |
| Agent version | Image digest, prompt version, model name and version | Lets you reproduce the behaviour |
| Action type | navigate, click, type, upload, request, tool_call | What kind of action it was |
| Target | URL, element selector, tool name | Where the action landed |
| Input reference | Hash or stored copy of the prompt and page text | What the agent was reacting to |
| Decision | allowed, blocked_by_policy, needs_approval | Which guardrail applied |
| Approver | Person who approved a high-impact action | Accountability for exceptions |
| Outcome | HTTP status, assertion result, error | What happened next |
| Secret use | Credential reference, never its value | Shows which secret was used |
What does one record look like?
One record is a single structured line. This example is illustrative; the field names are yours to choose:
{"event_time":"2026-11-26T09:14:03.218Z","log_time":"2026-11-26T09:14:03.240Z","tenant":"acme","run":"run-7f3c","step":42,"initiator":{"type":"api_key","id":"key_19"},"agent":{"image":"sha256:<digest>","prompt_version":"checkout-v12","model":"<model and version>"},"action":"type","target":{"url":"https://staging.acme.example/login","selector":"#password"},"input_ref":"sha256:<hash of page text and prompt>","secret_ref":"cred/acme/staging-qa-user","decision":"allowed","outcome":{"status":"ok"},"prev_hash":"sha256:<hash of record 41>"}
Note what is absent: the password itself. The OWASP Logging Cheat Sheet lists "Authentication passwords", "Access tokens" and "Encryption keys and other primary secrets" among data to remove, mask, hash or encrypt rather than log directly.
How do I keep the audit log from being altered?
Keep it from being altered by making the store append-only and making changes detectable. OWASP's multi-tenant sheet says to "Enforce append-only audit behavior through database permissions or storage controls such as write-once, read-many (WORM)" and to "Use tamper-evident mechanisms to detect modifications to stored audit records", noting that "tamper detection identifies modifications rather than preventing them" (OWASP Multi-Tenant Security Cheat Sheet, read 2026-11-26).
- Write records to a store the agent runs and the application cannot update or delete.
- Chain records: each one carries a hash of the previous record of the same run (the
prev_hashfield above), so a removed or edited record breaks the chain. This is one way to be tamper-evident; signed batches are another. - Copy records to read-only storage quickly. OWASP's logging sheet says to "Store or copy log data to read-only media as soon as possible".
- Alert on deletion attempts. NIST AU-9 asks you to "Protect audit information and audit logging tools from unauthorized access, modification, and deletion" and to alert on detection.
Who may read the audit log?
Each customer may read the records of their own tenant; your staff may read across tenants only through an explicit, logged platform role. OWASP: "A centralized audit store is acceptable when read access enforces tenant scope", "Cross-tenant audit reads and writes require explicit platform authorization", and "Tenant administrator rights must not grant platform-wide audit access" (OWASP Multi-Tenant Security Cheat Sheet, read 2026-11-26). Log the reads too: the logging sheet asks that access to logs be recorded and monitored.
How long should the records be kept?
Keep the records for a defined period, then dispose of them. NIST AU-11 asks organizations to "Retain audit records for" a period they define "to provide support for after-the-fact investigations of incidents and to meet regulatory and organizational information retention requirements" (NIST SP 800-53 Rev. 5, read 2026-11-26). The OWASP logging sheet adds that logs must not be destroyed before the required period, nor kept beyond it. Write the period into your contracts; our guide to retention and deletion for agent runs shows how to set one for each kind of data.
What should I alert on?
Alert on patterns that suggest an injected or misbehaving agent, or an isolation failure:
- Any denied cross-tenant read or write. OWASP asks you to "Monitor denied or unexpected cross-tenant access attempts".
- A run with many policy blocks in a row, such as refused hosts or refused tools.
- A secret used by a run whose task did not name it.
- A high-impact action without an approver.
- A gap or a broken chain in a run's records.
What we read for this article
- OWASP Logging Cheat Sheet, read 2026-11-26
- OWASP Multi-Tenant Application Security Cheat Sheet, read 2026-11-26
- NIST SP 800-53 Rev. 5, Security and Privacy Controls (controls AU-3, AU-9 and AU-11), read 2026-11-26
- NCSC: Prompt injection is not SQL injection (it may be worse), read 2026-11-26
Questions readers ask
What is the difference between an audit log and a debug log?
An audit log is a record of who did what, kept to support investigations and accountability, with protected integrity and a fixed retention period. A debug log helps engineers fix faults and is usually short-lived and noisy. Keep them separate so the audit trail is complete and the debug log can be trimmed.
Should the audit log include the full prompts and model outputs?
Record enough to reconstruct what the agent saw and did, such as a hash or a stored copy of each prompt and output under the same access rules as the run's other data. Full text in the audit log itself makes it large and may copy customer data or secrets into a store with a longer life.
Can customers see the agent's audit log?
They should be able to see and export the records of their own runs. OWASP's multi-tenant guidance adds that tenant administrator rights must not grant platform-wide audit access, so the export must be scoped to the tenant.
How long should agent audit logs be kept?
For a period you state and can defend, set by your contracts and the regulations that apply. NIST control AU-11 asks organizations to define the period, and OWASP warns against both destroying logs early and keeping them beyond the period.
Yours,
SecureAgentSandbox editors
Revised , 5 minutes to read