PII and Secrets in AI Agent Traces: How to Keep an Audit Trail Without Keeping Everything
Agent traces capture prompts, retrieved documents, tool arguments and tool results, so once content capture is on they fill with personal data and credentials. Keep the audit trail but minimise what goes into it: remove secrets before storage, pseudonymise identifiers you need to correlate, keep bulky content apart from the action record, restrict and log access, and delete each kind of data on its own schedule.
On this page
A trace of an agent is a record of everything it saw. That is what makes it useful for debugging, and what makes it a liability. The customer record a tool returned, the document retrieval surfaced, the API key passed in a header: all of it can end up in the trace, then in the trace backend, its indexes, its backups and its exports.
This is a practical reading of the data protection side, not legal advice.
Why AI agent traces collect sensitive data
An agent's trace is not a log line. It holds the content of the work:
- Prompts and conversations. Users paste in whatever they have, including other people's details.
- Retrieved documents. HR files, contracts, customer correspondence.
- Tool arguments and results. A CRM lookup returns the whole record, not just the field the agent needed.
- System prompts and tool definitions, which may describe internal systems.
- Errors. A failed database call can carry its connection string into a stack trace.
The OpenTelemetry semantic conventions for generative AI, still marked as in development, are direct about this. Their span conventions say model instructions, user messages and model outputs "are considered sensitive", that instrumentations "SHOULD NOT capture them by default, but SHOULD provide an option for users to opt in", and flag tool-call arguments as an attribute that "may contain sensitive information".
So the default is right. The risk starts the day someone turns capture on to debug a problem and leaves it on.
Secrets are the sharper version. OWASP's Logging Cheat Sheet lists data that should usually not be recorded directly in logs, including access tokens, passwords, database connection strings, encryption keys, payment card data and sensitive personal data, and says it should be removed, masked, sanitised, hashed or encrypted instead. The MCP specification's security best practices list "log leakage" among the ways an attacker obtains an over-scoped access token.
Audit trails vs GDPR data minimisation: is there a conflict?
It looks like one.
On one side, an agent audit trail has to let you reconstruct what the agent did and why, and for high-risk systems the EU AI Act asks deployers to keep logs for at least six months under Article 26(6). We set out what an agent audit trail should contain in an earlier piece.
On the other, Article 5(1)(c) GDPR requires personal data to be "adequate, relevant and limited to what is necessary in relation to the purposes for which they are processed". Article 5(1)(e) adds storage limitation: data kept in identifiable form no longer than necessary. Article 25 asks for data protection by design and by default, with pseudonymisation as one of its examples.
The AI Act anticipates the collision. Article 26(6) sets its six-month floor "unless provided otherwise in applicable Union or national law, in particular in Union law on the protection of personal data".
In practice the conflict mostly dissolves once you name the purpose. An audit trail exists to show which agent acted, on whose authority, what it did, what checked it and what happened. That needs identifiers, actions, arguments and verdicts. It rarely needs the full text of every document the agent read. The minimisation question is asked field by field: does the audit purpose need this value, or only a reference to it?
How to keep PII and secrets out of AI agent logs: 5 controls
1. Redact before storage, not after
Remove secrets and unnecessary personal data in the instrumentation or the collector, before anything is exported. Once a value reaches a trace backend it is copied into indexes, backups and exports, and scrubbing all of them later is a project. An audit trail never needs a credential's value, only which credential was used, which is one more reason to give each agent its own identity and scoped credentials.
2. Pseudonymise the identifiers you need to correlate
Replace names, email addresses and account numbers with keyed tokens, and keep the key elsewhere. That is the GDPR's own definition in Article 4(5): data that can no longer be attributed to a person "without the use of additional information", kept separately.
Be clear about what it buys you. Recital 26 says pseudonymised data is still information on an identifiable person. The European Data Protection Board's Guidelines 01/2025 on Pseudonymisation, adopted in January 2025 as a version for public consultation, say controllers may need it "in order to adhere to the data minimisation principle", and also that, for data protection by design or for security, pseudonymisation alone will normally not be enough. It reduces risk. It does not take the trace out of scope.
3. Keep content apart from the action record
Store the audit record (who, what, which check, what verdict, what outcome) separately from bulky content such as full prompts, retrieved documents and tool results. Link the two by a reference and a hash. The content store gets tighter access and shorter retention. When content has to be deleted, under storage limitation or an erasure request under Article 17, the action record and its tamper-evidence survive.
4. Restrict and log access to traces
Debugging favours wide access. A trail full of customer data needs the opposite. OWASP's guidance is that privileges to read log data should be restricted and reviewed periodically, and that all access to the logs must be recorded and monitored. Article 32 GDPR lists pseudonymisation and encryption among the security measures to consider.
5. Set retention per kind of data
One retention period for everything is either too short for the audit record or too long for the content. OWASP puts both halves plainly: log data must not be destroyed before the required retention period, and must not be kept beyond it.
| Data in the trace | Example | Treatment |
|---|---|---|
| Credentials and secrets | API keys, tokens, connection strings | Remove at source; record only which credential was used |
| Direct identifiers | Names, emails, account numbers | Pseudonymise with a keyed token |
| Sensitive personal data | Health details, government IDs | Remove, or keep only in the restricted content store |
| Retrieved documents and tool results | A full customer record | Reference and hash in the audit record; content stored separately, short retention |
| Actions, arguments, verdicts | Tool called, target, check result | Keep in the audit record for the required period |
Where evaluation runs is a data protection decision too
Every system that reads your traces holds a copy of them. If traces are sent to an external service to be evaluated, that is another processing operation, another place the data lives, and possibly a transfer. It is one reason we argue the judge should run where the data already is.
Where Syntrox fits
Nucleus, our judge, is a 4B-parameter open-weight model, small enough to run on hardware inside your own network, so the traces a check reads do not have to leave it. Syntrox records, for each trace it evaluates, the score, the confidence and the version of the judge that produced them, outside the agent. Which content you keep, for how long and under which key remains your organisation's design.