AI agent audit logs contain a record of every action the agent takes. How long you keep these logs depends on your regulatory environment, operational needs, and storage budget. This guide covers retention requirements and implementation.
Different regulations specify different minimum retention periods:
| Regulation | Minimum Retention | |-----------|------------------| | EU AI Act (Article 12) | Lifetime of the system, minimum 6 months | | SOC 2 | 12 months (audit period) | | HIPAA | 6 years | | GDPR | As long as necessary for the purpose | | PCI DSS | 12 months (3 months immediately available) | | SEC (financial) | 6 years |
If you operate under multiple regulations, use the longest applicable period.
Not all log data has the same retention value:
Always retain: Policy decisions (allow, block, escalate), tool names, timestamps, principal identities, receipt hashes, and escalation outcomes. This is the core audit trail.
Retain with caution: Tool arguments may contain sensitive data (PII, credentials). You may need to redact or encrypt arguments before long-term storage while keeping the rest of the receipt intact.
Consider discarding: Debug logs, performance metrics, and temporary session state may not need long-term retention.
Configure retention in the control plane:
const guard = createGuard({
policy,
receipts: {
store: 'postgresql',
connectionString: process.env.DATABASE_URL,
retention: {
default: '24months',
highRisk: '7years', // HIPAA, SEC
arguments: 'redact_after_90days',
}
}
});
To satisfy both audit and privacy requirements, redact sensitive fields after the short-term investigation window:
The hash chain remains verifiable even after redaction because the receipt hash was computed when the full data was present.
For regulatory compliance, store receipts in append-only storage. Options include:
GDPR gives users the right to request deletion of their personal data. This conflicts with audit retention requirements. The common approach is to redact personal data from the receipts while keeping the structural data (hashes, timestamps, decisions) intact. Consult legal counsel for your specific situation.
Hash-chained receipts are compact. A typical receipt is 500 bytes to 2 KB. An agent making 100 tool calls per day generates roughly 50-200 KB of receipt data daily. Even at 7-year retention, this is manageable for most organizations.
Explore more guides on AI agent safety, prompt injection, and building secure systems.
View All Guides