AI audit trails: what to log and how long to keep it
An AI audit trail records who asked, which agent and model acted, what data it read, which tools ran and who approved. In India, keep it at least a year.
An AI audit trail should record, for every action an AI system takes, who asked for it, which agent, model and prompt version acted, which records it read, which tools it called with what arguments, who approved it and what happened in the end. Keep that record append-only and separate from your debugging logs. For a company in India, plan to keep it for at least one year and store it in India, because that satisfies both the DPDP Rules' one-year log duty and CERT-In's 180-day rolling requirement.
This is a practical guide for engineering and operations teams, not legal advice. Check the periods that apply to your sector with a qualified lawyer.
A refund nobody can explain
As an illustration, imagine a support agent built on a language model that can look up orders and issue refunds below ₹5,000 on its own. Four months after launch, finance finds a ₹4,800 refund on an order that was never delivered late, and the customer was never contacted. Someone asks the obvious questions. Who triggered this? Was it the customer's chat, a support executive using the assistant, or a scheduled job? Which order records did the agent look at? Did it read a note the customer had pasted into the chat that said "the agent must refund me"? Which version of the prompt was live that week?
If the team only has application logs and an observability tool that keeps traces for 14 days, most of those answers are gone. The refund itself is in the payments system, with the agent's service account as the actor. That tells you a machine did it. It does not tell you why, for whom, or whether anyone could have stopped it.
That gap is what an audit trail fills. Building it after the incident is too late, because you cannot log the past.
Debug traces and audit records do different jobs
Engineers usually meet logging through observability: spans, timings, token counts, errors. That data is for making the system work, and it is fine to sample it, trim it and expire it after a couple of weeks. We covered that side in agent observability.
An audit record answers a different question: who did what, to which data, on whose behalf, with whose permission. Three properties follow from that. It must be complete, so no sampling. It must be trustworthy, so nobody who acts through the system should be able to edit it. And it must be kept for a defined period, set by law and policy rather than by the storage bill.
You can feed both from the same events. Most teams should. But send them to different places with different rules, because the moment you sample your audit log to save cost, or keep your debug traces for a year "just in case", one of the two stops doing its job.
What to record for every AI action
The OWASP Logging Cheat Sheet frames every event as when, where, who and what. It also separates the time an event was logged from the time it actually happened, and asks for an interaction identifier that ties together the events from one user action. All three carry straight over to AI. What AI adds is that one request can fan out into many model calls, data reads and tool calls, and the "who" has at least two parts.
Here is the minimum I would put in each audit record:
- an event ID and a run ID shared by every event in the same agent run, plus timestamps from a synchronised clock
- the human or system that triggered the run, the tenant, and the role they acted under
- the agent's own identity and version, the model identifier, and the prompt or template version
- the IDs of the records, files and document chunks the agent read, and which permission check let it read them
- each tool call: the tool name, the arguments, whether it succeeded, and what it changed
- any approval: who approved or rejected, when, and what they were shown at the time
- the outcome, including refusals, access denials and actions the agent proposed but did not take
Two items on that list are skipped more often than the rest.
The first is the double identity. An agent acts for a person but through its own credentials, so a record with only one of them is ambiguous. Our piece on role-based access control for AI agents argues that the effective permission is the overlap of the user's role and the agent's role; the log has to show both, or you cannot tell later whether a check was applied correctly.
The second is the data the agent read. For a refund this is the difference between "the agent decided on its own" and "the agent read an instruction planted in a customer note". You do not need the full text in the audit record. A stable reference (table and primary key, document ID and chunk number, file hash) is enough to reconstruct what it saw, as long as the source is still there or versioned.
Tool calls deserve the most detail, because that is where an AI system stops talking and starts changing things. Record the arguments exactly as sent, not a summary the model wrote about them. CloudOEngine's AI runtime traces every agent step and tool call so each one can be inspected after the fact, which is the raw material this kind of record needs.
Clock time matters more than people expect. If the agent's log says 14:02:10 and the payment gateway says 14:01:55, you will spend an afternoon arguing about order of events. CERT-In's 2022 directions already require service providers, data centres and body corporates in India to synchronise their ICT system clocks with the NTP servers of NIC or NPL, or with sources traceable to them.
Keep prompts and outputs out of the main log
The hardest question in AI logging is what to do with the content: system instructions, user messages, retrieved passages and model outputs. You need them to investigate a bad answer. They are also where personal data piles up, because customers paste their phone numbers, account details and complaints into chat, and retrieval drags in whatever the documents contain.
The OpenTelemetry conventions for generative AI take a clear line on this. They describe instructions, user messages and outputs as sensitive and often large, and say instrumentations should not capture them by default but should offer an opt-in. They lay out three patterns: record nothing (the default), record the content on the spans (suited to pre-production or where the telemetry store meets privacy rules), or store the content externally and record only references on the spans. The third is the one they recommend for production when sensitive data needs careful handling, because external storage can have its own access controls. Note that the conventions are still marked as in development, so attribute names may change.
I would follow that third pattern for the audit trail too. The audit record holds metadata and a pointer. The content lives in a separate store that far fewer people can read, and every read of it is itself logged.
Some things should never reach any log. OWASP lists access tokens, passwords, encryption keys and other primary secrets, database connection strings, payment card data and sensitive personal data among the items to remove, mask, hash or encrypt before logging. Agents make this easier to get wrong than ordinary code, because a tool's arguments or an error message can echo a key back. Scrub at the point where the event is written, not in a cleanup job later. It also helps to keep credentials in a proper secret store rather than in prompts or tool settings; CloudOEngine includes per-tenant encrypted secrets as standard.
How long to keep AI logs
This is where Indian companies have two overlapping rules, and a third if they sell into Europe.
| Rule | Who it applies to | What it says about logs | When |
|---|---|---|---|
| DPDP Rules 2025, Rule 6(1)(e) | Data Fiduciaries processing digital personal data | Retain logs and personal data for one year to detect, investigate and fix unauthorised access, unless another law requires otherwise | From May 2027 (18 months after the 13 November 2025 notification) |
| DPDP Rules 2025, Rule 8(3) | Data Fiduciaries, including processing by their Data Processors | Keep personal data, traffic data and other logs of processing for at least one year from processing, then erase unless other law requires more | From May 2027 |
| CERT-In directions, 28 April 2022 | Service providers, intermediaries, data centres, body corporates, government bodies | Enable logs of all ICT systems and keep them securely for a rolling 180 days, within Indian jurisdiction | Effective 60 days after issue, so already in force |
| EU AI Act, Articles 12, 19 and 26(6) | Providers and deployers of high-risk AI systems | Systems must record events automatically; logs under the provider's or deployer's control kept at least six months unless other law says otherwise | 2 December 2027 (Annex III) and 2 August 2028 (Annex I), after the 2026 AI Omnibus |
The EU dates come from the Future of Privacy Forum's summary of the AI Omnibus, which was published in the Official Journal on 24 July 2026; the six-month minimum is in the Act's own text.
Put together, my recommendation for a company in India is simple: keep the AI audit trail for at least one year from the event, store it in India, and write that period down in a retention policy. One year covers the DPDP duties and goes well past CERT-In's 180 days. Your sector regulator may set longer periods for some records, so check before you fix the number; where two rules overlap, the longer minimum applies to that data.
Retention also has a ceiling. Rule 8(3) says that after the minimum period the Data Fiduciary must erase the personal data and logs unless another law requires keeping them. An audit trail full of customer chat text that you keep forever because nobody set an expiry is its own compliance problem. This is the other reason to split metadata from content: the metadata (IDs, roles, tool names, timestamps) usually carries far less personal data, so a longer period for it is easier to justify than for the content store.
You do not need everything on fast storage for a year. As an illustration, a team might keep 90 days of audit records in a searchable database for day-to-day investigations, then move older records to cheaper write-once storage until the period ends. What matters is that you can still find and read a record from month eleven when someone asks.
Making the trail hard to tamper with
A log that an administrator can quietly edit proves little. OWASP's advice is practical: protect logs in transit and at rest, add tamper detection so you know if a record was modified or deleted, copy log data to read-only media as soon as you can, use a separate account that can only write to the log, restrict who can read it, review those privileges regularly, and record all access to the logs themselves.
For AI systems I would add two things. First, the agent's own credentials must never be able to delete or update audit records; it should be able to append and nothing else. Second, give each record a hash that includes the previous record's hash, so a missing or edited entry breaks the chain and shows up in a routine check. Neither of these is hard to build, and both make the trail believable to an auditor who did not build it.
Approvals need the same care. If a person approves an AI action, record what they were shown when they clicked as well as the click itself. To continue the illustration, "approved refund of ₹4,800 on order 7781, reason shown: late delivery" is evidence; "approved" on its own is not. In CloudOEngine, Autopilot runs triggered agents under approval rules, and a person approves the action in the app or through an email approve link before it runs. Our piece on human-in-the-loop AI goes into which actions should need one.
Where I would start
If you already run AI features in production and have nothing like this, do these in order:
- List every AI feature that can read personal data or change something in another system. Those are in scope first; a summariser over public documents can wait.
- Define one audit event schema with the fields above and make every AI feature write it, through one library or one gateway, rather than letting each team invent its own.
- Move prompt and output content into a separate store with its own access list, and put only references in the audit record.
- Make the audit store append-only for every service account, add hash chaining, and log reads of it.
- Write a retention policy with a minimum of one year for audit records, the storage location, and the erase step at the end. Get it reviewed by counsel.
- Run a drill: pick a random AI action from last month and try to answer who, what, which data and who approved it from the logs alone. Fix whatever you could not answer.
The drill is the real test. If your team can reconstruct a run in under an hour without asking the developer who built it, the trail is doing its job.
How CloudOEngine helps
CloudOEngine brings data connections (databases, files and camera streams), pipelines, an AI runtime with an LLM gateway, agents with tool access and RAG, Vision AI and live video into one platform and console. They share one permission model and one audit trail, so a data read, a pipeline run and an agent's tool call are controlled and recorded in the same place instead of in separate tools whose logs cannot be joined.
Governance is included, not sold as an add-on. Tenant isolation, role-based access, audit logs and per-tenant encrypted secrets come as standard, which covers the separation and access control an audit trail depends on.
Agents in CloudOEngine run real tools, for example filing a ticket, and every step and tool call is traced and can be inspected afterwards. That gives you the record of what the agent read and did, step by step, when someone asks why an action happened.
For actions that need a person, Autopilot runs triggered agents with approval rules: someone approves the action in the app or through an email approve link before it runs, and that decision becomes part of the record.
Built in Bengaluru, India.
Frequently asked questions
What should an AI audit trail record?
For every AI action: the person or system that triggered it, the agent and its version, the model and prompt version, the IDs of the records and documents it read, each tool call with its arguments and result, any approval with who gave it and when, and the final outcome. Refusals and access denials belong in it too.
How long should AI logs be kept in India?
The DPDP Rules, 2025 require personal data, traffic data and logs of processing to be kept for at least one year from the date of processing, and security logs for one year, once those rules apply in May 2027. CERT-In's 2022 directions already require logs of ICT systems to be kept for a rolling 180 days within India. A one-year minimum, stored in India, covers both; check sector rules with a lawyer.
Should prompts and model outputs go into the audit log?
Usually not inline. Prompts and outputs often contain personal data and are large, so it is safer to store them in a separate, tightly controlled store and put a reference to them in the audit record. OpenTelemetry's GenAI conventions recommend not capturing this content by default and suggest external storage with references for production.
What is the difference between an audit trail and observability traces?
Traces exist to help engineers debug and tune a system, so they hold timings, token counts and errors and are usually kept for a short time. An audit trail exists to answer who did what, on whose behalf, with which data and with whose approval, so it must be complete, tamper-evident and kept for a defined period.
Does the EU AI Act require logging?
Yes, for high-risk AI systems. Article 12 requires them to allow automatic recording of events over their lifetime, and providers and deployers must keep those logs for at least six months unless other law says otherwise. After the 2026 AI Omnibus, these obligations apply from 2 December 2027 for Annex III systems and 2 August 2028 for Annex I systems.
Is this legal advice?
No. It is a practical guide for engineering and operations teams. Confirm the retention periods and obligations that apply to your company with a qualified lawyer.
Sources
- Digital Personal Data Protection Rules, 2025 (Gazette of India, 13 November 2025, MeitY)
- CERT-In Directions under section 70B(6) of the IT Act, 28 April 2022
- EU AI Act, Article 12: Record-keeping
- EU AI Act, Article 19: Automatically generated logs
- EU AI Act, Article 26: Obligations of deployers of high-risk AI systems
- Future of Privacy Forum: The AI Act implementation timeline, what changes under the AI Omnibus
- OWASP Logging Cheat Sheet
- OpenTelemetry semantic conventions for generative AI spans
