On this page, 8 sections
Audit logging for AI agents under SOC 2 means recording, for every agent action, who or what triggered it, which tenant it acted for, which tools and data it touched, what it changed, and which model and prompt version made the decision. Keep those records where the agent and your engineers cannot quietly edit them, and review them. That is what auditors and enterprise buyers ask to see.
Why agents change the logging question
Ordinary application logging answers "which user did what". An agent breaks that chain. A user asks for something, the agent decides on a series of steps, calls tools, reads records and writes changes, sometimes minutes later and sometimes on a schedule nobody is watching. When a buyer asks "how would you know what your agent did with our data", a web server access log does not answer it.
SOC 2 was not written for AI, but the criteria already cover this. CC7.2 expects you to monitor system components for anomalies that indicate malicious acts, errors or failures. CC7.3 expects you to evaluate security events and decide whether they are incidents. CC6 expects access to be restricted and attributable. ISO 27001 asks the same through Annex A controls on logging, monitoring activities and clock synchronization. If an agent can act on customer data, its actions are system activity those controls must cover. The general case for designing logs early is in the guide to building logging and audit trails for compliance from day one. This post is about what changes when the actor is an agent.
What to log for each agent action
Treat each agent run as a transaction with a single identifier, and attach every step to it. For each run and step, record:
- The initiator. The human user, API client or scheduled job that started the run, with their identity as your system knows it, not just a session token.
- The tenant. Which customer the agent was acting for. In a multi-tenant product this is the field that lets you prove one customer's agent never touched another customer's records.
- The tool calls. Each tool or API the agent invoked, with parameters, the result status and the time. Redact secrets and sensitive values, but keep enough to reconstruct what happened.
- The data touched. Record identifiers for what was read and what was written or deleted. You do not need full payloads in the audit log, but you need to answer "which records".
- The decision context. The model name and version, the prompt or system instruction version, and the configuration of tools the agent was allowed to use at that moment.
- Approvals and refusals. Any human approval step, who approved, and any action the agent attempted that a guardrail blocked. Blocked attempts are some of the most useful security signals you will have.
- Errors and retries. Agents retry. A loop of failed writes looks very different from one failure, and both should be visible.
What not to put in the audit log
Full prompts and model outputs often contain customer personal information. Logging them all into a general-purpose log platform creates a second copy of sensitive data with weaker access control and an undefined retention period. Keep content logs separate from the audit trail, with their own access restrictions and retention, or store references instead of content. Never log credentials, tokens or connection strings, even in error messages.
Make the log trustworthy
A log the system it describes can edit is weak evidence. For agents this matters more, because the agent itself may have write access to the same data stores. Three properties make an audit trail something an auditor or a buyer can rely on.
Tamper evidence enforced by storage
Append-only design in application code is a good start, but auditors and incident responders will ask what stops an administrator, a compromised credential or a buggy job from changing records. The answer should be the storage layer: write-once retention settings, object lock, or a separate account the application can write to but not delete from. In a recent engagement, an agentic marketplace platform had built a tamper-evident audit ledger into its product, but the storage underneath did not enforce it. Backing the ledger with storage that actually enforces those protections was one of six findings closed during the gap assessment. The design was right; the guarantee was missing.
Synchronized time
Reconstructing an agent run across services only works if their clocks agree. Use your cloud provider's time source and record timestamps in UTC.
Separation from the actor
The agent's service identity should be able to write audit events and nothing else in that store. Engineers should be able to read them, and nobody should be able to edit them without leaving a trace.
Free weekly email
Get The Compliance Brief every Tuesday
One email a week from Jacob Masse: the security and compliance stories that changed something that week, and what each one means if you sell software to enterprise buyers. Five stories, a take on each, five minutes to read.
Free. Unsubscribe in one click, and replies reach Jacob directly. Read the latest issue or browse the archive.
Logs nobody reads are not monitoring
SOC 2 asks for monitoring, not storage. An auditor will want to see what you do with the logs. For an agent product, a small set of alerts covers most of the risk:
- An agent run that touches records belonging to more than one tenant.
- A spike in blocked tool calls or guardrail refusals, which often means someone is probing the agent with injected instructions.
- Agent actions outside the hours or volume a customer's usage would explain.
- Changes to the agent's allowed tools, permissions or system prompt, outside your change process.
- Failures in the logging pipeline itself. A silent gap in audit logs is an incident.
Route alerts to a person who is expected to respond, and keep a record of the response. In the same engagement, a production database failure had gone undetected because nothing was monitoring it. Monitoring and alerting were added during Phase 1. Agent activity deserves the same treatment: if nobody would notice, the control does not exist.
Retention and access
Decide how long audit logs are kept and write it down. Long enough to investigate an incident discovered late and to cover your audit period is a sensible floor, and a Type II observation window of up to 12 months sets the practical minimum for many startups. Customer contracts and privacy law may set limits in the other direction for content logs that hold personal information. Restrict who can read audit logs, and log access to them.
What buyers ask, and what a good answer sounds like
Enterprise security questionnaires now include questions written for AI vendors. On logging, they usually ask three things:
- "Can you show us every action your system took on our data?" A good answer names the fields you record per action and how a customer can request an export.
- "How do you prevent logs from being altered?" A good answer names the storage control, not the intention.
- "How would you detect your agent being misused?" A good answer lists the alerts above and who receives them.
The same buyers will ask what the agent can be made to do, which is a testing question rather than a logging one. Our guide to AI agent security assessment covers that side. Logging is how you prove what happened; testing is how you find out what could.
Evidence to keep for the audit
- A logging standard listing the events and fields captured for agent actions.
- Configuration showing write-once or locked storage for the audit trail, with the date visible.
- Alert rules and a sample of alerts with the investigation recorded.
- Access lists for the log store and a record of reviewing them.
- The retention policy and evidence the storage applies it.
- A sample reconstruction of one agent run, end to end. This is the single most persuasive artefact you can show an auditor or a buyer.
Common questions
Does SOC 2 require logging AI prompts and responses?
No. SOC 2 requires monitoring sufficient to detect and evaluate security events, and access that is attributable. You need to reconstruct what the agent did and why. Storing full prompts and outputs is a design choice, and because they often contain personal information, it carries its own access and retention obligations.
How long should we keep audit logs for AI agent actions?
Long enough to cover your audit observation period and to investigate an incident found late. For many startups that means at least 12 months for the audit trail. Write the period in your policy, configure storage to enforce it, and keep content logs on a shorter, separate schedule if they hold personal information.
Is an append-only table in our database enough for tamper evidence?
It is a start, but anyone with database administrator rights can still change it. Auditors and buyers will ask what stops that. Storage-level controls, such as write-once retention or a separate account the application cannot delete from, give a guarantee the application alone cannot.
What should we log when an agent's action is blocked?
Everything you would log for a successful action, plus the rule that blocked it. Blocked actions show attempted misuse and injected instructions, and a rise in them is often the earliest sign that someone is probing your agent.
If your agent acts on customer data and you are not sure your logs would answer a buyer's question, our AI security assessments test the agent directly, and SOC 2 readiness builds the monitoring controls around it. Book a free call and walk us through one agent run. We will tell you what an auditor would ask about it.
Can you show a buyer everything your agent did with their data? SOC 2 readiness starts with a fixed-price gap analysis from $3,000, ISO 27001 from $3,500, and the rest is scoped from what it finds.
See readiness pricingOr book a free call