Log enough to reconstruct any decision the agent made: the input it saw, the sources and tools it used, what it proposed, what a person changed and what finally happened. For high-risk systems the AI Act requires automatic logs kept for at least six months, while the GDPR requires you to keep personal data in those logs no longer than you need it and to protect it, so retention and access need a written decision rather than a default.
This guide is for CTOs and compliance leads who need an agent’s actions to stand up to an audit, a complaint or an incident review.
What the law asks for
Article 12: logs designed into high-risk systems
Article 12(1) of the AI Act says high-risk AI systems must technically allow for the automatic recording of events (logs) over the lifetime of the system. This is a design duty on the provider: the logging has to be built in, not bolted on by each customer.
Article 12(2) says the logging must give a level of traceability appropriate to the system’s intended purpose. It must record events relevant to:
- (a) identifying situations that may result in the system presenting a risk within the meaning of Article 79(1), or in a substantial modification;
- (b) facilitating the post-market monitoring referred to in Article 72;
- (c) monitoring the operation of the system referred to in Article 26(5).
Article 12(3) sets a fixed minimum only for remote biometric identification systems under Annex III point 1(a): the period of each use, the reference database, the input data that led to a match and the people who verified the results. For every other high-risk system, the content of the logs follows from the three purposes in Article 12(2). That is a design question you answer and document.
Under Article 13(3)(f), the provider’s instructions for use must describe, where relevant, the mechanisms that let deployers properly collect, store and interpret the logs.
The high-risk rules apply from 2 December 2027 for systems listed in Annex III, such as creditworthiness assessment or life and health insurance pricing, and from 2 August 2028 for AI in products covered by Annex I.
Articles 19 and 26(6): how long to keep them
Article 19(1) requires providers to keep the automatically generated logs, to the extent they are under their control, for a period appropriate to the intended purpose of at least six months, unless other Union or national law, in particular data protection law, provides otherwise. Article 26(6) puts the same duty on deployers for the logs under their control.
Both articles have a rule for financial institutions. Article 19(2) and Article 26(6) let providers and deployers that are financial institutions subject to internal governance requirements under Union financial services law keep the logs as part of the documentation they already maintain under that law. Article 26(5) similarly treats their monitoring duty as fulfilled by complying with those governance rules. For a bank or insurer, the AI logs belong in the existing records framework, not in a separate store nobody audits.
Six months is a floor, not a target. The period must be “appropriate to the intended purpose”, so a system whose decisions can be challenged for years may need longer.
The GDPR: the other side of retention
Agent logs almost always contain personal data: names in prompts, customer records the agent retrieved, free text from emails. The GDPR applies to them in full.
- Data minimisation, Article 5(1)(c). Log what you need for the purposes you have defined, not everything the agent touched.
- Storage limitation, Article 5(1)(e). Keep personal data in identifiable form no longer than necessary for the purpose.
- Integrity and confidentiality, Article 5(1)(f), and security, Article 32. Logs are a concentrated copy of sensitive data. Protect them at least as well as the source systems.
- Accountability, Article 5(2). You must be able to show compliance, which logs help with.
- Access, Article 15, and automated decisions, Article 22(3). A person can ask for their data, and where Article 22 applies, contest a decision. You need logs to answer both.
The AI Act’s six months and the GDPR’s storage limitation do not conflict. Articles 19 and 26(6) defer to data protection law, and the GDPR asks you to justify the period. Write that justification down.
What to log for an AI agent
An agent is a chain of steps, so log the chain, not only the final answer. The observable agent loop pattern in our guide to building agentic AI systems is one way to structure it. A practical record per run:
- Run identity. A unique run ID, the time, the workflow, and the case or customer reference.
- Versions. Model name and version, prompt template version, tool definitions version, and the configuration of thresholds. Without versions you cannot tell whether a fault came from a change.
- Input. What triggered the run and the data the agent received, or a reference to where that data is stored. For a claims intake agent, that means the documents and answers it collected, as in our first notice of loss reference design.
- Retrieval. Which documents or records the agent pulled, by ID, so you can show what it relied on.
- Tool calls. Each call with its parameters, the result and any error. For write actions, the record before and after.
- Proposal. What the agent proposed to do, and any reasons or citations it produced.
- Checks. Rules checks, agreement checks and threshold decisions, and why a case was escalated or not.
- Human review. Who reviewed it, when, and whether they approved, edited or rejected it. This is the evidence that oversight under Article 14 and Article 26(2) actually happened. Our guide to human oversight for AI agents covers the thresholds that decide which cases reach a reviewer.
- Outcome. What was finally executed and in which system.
- Stops and incidents. Every pause, restart and override of the agent, with who did it.
Points 2, 7 and 10 map most directly to Article 12(2)(a): they show when the system’s behaviour changed or started to present a risk. Points 6 to 9 support the monitoring in Article 26(5).
What not to log
The easiest way to break the GDPR with logs is to log everything by default.
- Do not copy whole records when an ID will do. Store a reference to the claim or customer file, not the file.
- Mask or tokenise direct identifiers in prompts and outputs where you can still reconstruct the decision.
- Separate debug traces from audit logs. Full prompt and token traces are useful for engineers for days, not years. Give them a short retention period and narrower access.
- Never log secrets. API keys, passwords and session tokens must be stripped before anything is written.
How long to keep it
Set retention per log type, not one number for everything. A simple scheme:
- Audit record (points 1, 2 and 5 to 10): at least six months for high-risk systems, and as long as decisions can reasonably be challenged, complained about or reviewed by a supervisor. For a financial institution, align with the retention of the governance records it already keeps.
- Full inputs and retrieved content: as short as possible. Keep references in the audit record and rely on the source system’s own retention.
- Debug traces: days or weeks.
Record each period, its reason and its owner in your records of processing and in the system’s documentation. When the period ends, delete or anonymise, and log the deletion.
Who can read the logs
Access is where audit logs most often fail a security review.
- Role-based access. Engineers see debug traces; compliance and audit see the audit record; customer service sees what it needs to answer a request about one case.
- Log access to the logs. Reads of the audit record are themselves recorded.
- Tamper evidence. Use append-only or write-once storage, or hash chaining, so a record cannot be changed silently after the fact.
- Location. Keep logs in the same region as the source data. If the agent’s data must stay in the EU, its logs must too. Our RAG architecture with EU data residency shows where logs and traces fit in that design.
- Provider access. Under Article 72(2), providers collect data on performance, which may come from deployers. Agree in the contract what log data the provider receives, in what form and under which data processing terms.
An example (Illustrative)
Illustrative: a lender uses an agent to prepare credit decisions on personal loans, which involves assessing the creditworthiness of natural persons under Annex III point 5(b). Our guide to credit scoring under the AI Act covers the other duties for these systems. The agent gathers documents, checks them against the application and proposes a decision for a credit officer.
- Each run logs the application ID, model and prompt versions, the document IDs retrieved, each tool call, the proposed decision with reasons, the threshold checks and the officer’s final decision.
- Full document text is not copied into the log. The log references the document store, which keeps its own retention.
- The audit record is kept in the lender’s existing credit file system, under the retention its governance rules already set, using the route Article 26(6) allows for financial institutions.
- Debug traces are kept for a short period, readable only by the engineering team.
The retention periods and access groups are the lender’s documented choices, not numbers from the law.
What this means for you
- Classify the system. Use our AI Act checker to see whether the agent’s use falls under Annex III. If it does, Articles 12, 19 and 26(6) apply from the Annex III date.
- Write the log specification before you build. List the fields per run, mapped to the three purposes in Article 12(2) and to your GDPR purposes.
- Version everything. Model, prompts, tools and thresholds, so any decision can be tied to the configuration that made it.
- Split audit logs from debug traces, with separate retention and access.
- Set and justify retention per log type, with six months as the floor for high-risk systems.
- Lock down access with roles, access logging, tamper evidence and EU storage where required.
- Test reconstruction. Pick a past case and rebuild the decision from the logs alone. If you cannot, the logs are not ready.
If you want an agent built with audit logging designed in from the start, see how we build AI agents.
Sources
- Regulation (EU) 2024/1689 (AI Act), EUR-Lex: Articles 12, 13, 14, 19, 26 and 72, and Annexes I and III.
- Regulation (EU) 2026/1744 (Digital Omnibus on AI), EUR-Lex: the amending regulation.
- AI Act Service Desk, Article 12: record-keeping, consolidated text as amended.
- AI Act Service Desk, Article 13: instructions for use.
- AI Act Service Desk, Article 19: automatically generated logs.
- AI Act Service Desk, Article 26: obligations of deployers.
- AI Act Service Desk, Article 72: post-market monitoring.
- Regulation (EU) 2016/679 (GDPR), EUR-Lex: Articles 5, 15, 22 and 32.
This article is general information, not legal advice.