When your AI agent processes a customer support ticket, where does that data go? Which model provider processes it? For how long do they retain the logs? And if the customer exercises their right to erasure under GDPR Article 17, can you guarantee the inference data is gone from every system that touched it?
Most engineering teams building AI workflows in 2026 answer these questions after deployment, not before. For organisations regulated under GDPR, MiFID II, HIPAA-equivalent frameworks, or the EU AI Act, that sequence is a compliance violation waiting to be audited.
This post covers a practical data governance framework for AI workflows: classification schemes, retention policies, audit trails, consent management at inference time, vendor risk assessment, and sector-specific requirements. Implement these controls in your agent pipelines before they process a single piece of customer data.
AI Data Classification: Not All Data That Touches an LLM Is Equal
The first step is a classification scheme that maps every data point entering your AI pipeline to a handling category. A three-tier system covers the vast majority of use cases:
Forbidden — never sent to a model. Passwords, API keys, biometric data, health records, minor data without parental consent, trade secrets, and any data subject to legal privilege. If it matches this category, your application must strip it before the data reaches the model provider’s API. Implementation pattern: a pre-inference middleware layer that scans the input for forbidden patterns (regex, PII detectors, classification models) and blocks the request or redacts the matched content.
Anonymised — PII stripped before inference. Customer names, email addresses, IP addresses, phone numbers, and any data that could identify a natural person. Strip or replace these with placeholder tokens before sending to the model. The model receives “User requested a refund for order ID [REDACTED]” instead of “Ana Horvat requested a refund for order INV-2026-0842.” The original data is stored locally with a link to the anonymised inference log.
Audited — full trace logged. Non-sensitive operational data where you need a complete record of what was sent and what the model returned. The inference log captures the full prompt, model version, temperature setting, output, tool calls made, user ID, and consent receipt. This category is the default for business data that is neither forbidden nor PII-containing.
Implement the classification as middleware in your AI gateway or proxy layer, not in application code per endpoint. A single classification middleware that all agent calls route through is auditable and updateable without touching every agent implementation.
Retention and Deletion Policies for Inference Data
Every major model provider retains API request and response logs for 30 to 90 days for abuse monitoring and model improvement — unless you explicitly opt out. For OpenAI, setting the store: false parameter on API calls prevents retention for non-improvement purposes. Anthropic and Google Cloud provide similar opt-out mechanisms. For Azure OpenAI Service, data residency and retention are contractually configured.
The compliance problem arises when a user submits a deletion request. GDPR Article 17 gives individuals the right to erasure of their personal data. If a user’s data was part of an inference call six months ago, can you delete it from the provider’s systems?
You probably cannot — at least not directly. The provider retained those logs under their own data-processing terms, and your contract may or may not support retroactive deletion. The practical approach is a three-part strategy:
- Opt out of model training by default — configure every provider integration to exclude data from training and improvement programmes. This is a contractual setting, not a runtime parameter for most providers.
- Define retention windows contractually — negotiate inference log retention in your DPA (data processing addendum). 30 days is the minimum most providers support. Some allow 7 days for an additional fee.
- Log only what you must — design your inference pipeline to minimise PII in prompts from the start. If the model does not need the customer’s name, do not include it. Anonymisation at the middleware layer reduces the scope of deletion requests because the provider never had personal data to begin with.
Audit Trails for Agentic Decisions
When a regulator asks, “Why did your AI agent deny this customer’s refund request?”, your system must produce an answer that is specific, traceable, and immutable.
What to log per inference:
- Prompt hash (for deduplication and integrity verification, not the raw prompt in the operational log — store the full prompt in append-only storage linked by hash)
- Model version and deployment identifier (so you can reproduce behaviour from a specific point in time)
- Temperature, top-p, and other sampling parameters
- Output hash and full output text
- Tool calls made (function name, arguments, and return values)
- User ID or session identifier
- Consent receipt (link to the consent event that authorised processing)
- Timestamp with nanosecond precision for ordering
Where to store it. Operational databases are mutable — a mistake, a migration, or a rollback can destroy audit evidence. Store audit events in append-only storage. immudb provides a cryptographic-verified append-only database for on-premise deployments. AWS CloudTrail and Azure Monitor provide append-only log groups for cloud-native architectures. The key property is that no one — not even your admin user — can delete or modify past audit events without detection.
Who can read it. Separate read access for audit logs from the operational database. The team operating the AI agents should not be able to edit the audit trail of their own decisions.
Consent Management at Inference Time
Before sending any user data to an LLM, your application must check that the user has consented to that specific data processing. This requirement flows from GDPR Article 6 (lawfulness of processing) and Article 7 (conditions for consent).
The check at inference time. Your AI gateway middleware reads the user’s current consent state from your preference store or cookie-consent banner system. If the user has not consented to “AI-powered assistance” or “data processing by third-party model providers,” the middleware blocks the inference call and returns a degraded response: “AI features are unavailable with your current privacy settings.”
Consent categories for AI features. A single “Accept All” consent is insufficient for regulated environments. Distinguish between:
- Functional AI (summarisation of user’s own data within the same session)
- Improvement AI (anonymised data used to improve the model or your product)
- Third-party processing (data sent to OpenAI, Anthropic, or other external model providers)
Each category maps to a different consent shelf. A user who accepts functional AI but rejects third-party processing should still get local-model inference or degraded features, not a hard block.
Vendor Risk Assessment for Model Providers
Your compliance posture depends on your vendors’ compliance posture. Before integrating any model provider into a regulated workflow, verify:
Data residency. Where are inference requests processed? OpenAI’s API may route traffic through US, EU, or both depending on your account configuration. Anthropic processes in the US by default with EU processing available on request for enterprise accounts. Google Cloud Vertex AI lets you pin processing to a specific region. Contractually require a specific region and test that the provider honours it.
Training data opt-out. Does the provider use your inference data to train or fine-tune their models? Most enterprise API tiers offer a contractual opt-out. Verify it is active on your account and document the verification.
Sub-processor list. The provider may subcontract inference processing to other entities. Review the provider’s sub-processor list (required under GDPR Article 28) and ensure every entity on the list meets your compliance requirements.
Certifications. SOC 2 Type II is the baseline for any enterprise AI provider. ISO 27001 adds an independent certification layer. For healthcare data, look for HIPAA BAA support. For finance, confirm the provider’s infrastructure meets the cloud security requirements of your jurisdiction’s financial regulator.
Data processing addendum (DPA). Every provider contract must include a DPA that covers data retention, deletion, security measures, sub-processor notification, and liability for data breaches. Do not use an AI provider without a signed DPA in a regulated context.
Sector-Specific Requirements
Beyond the general GDPR framework, sector-specific regulations impose additional constraints on AI data governance.
Healthcare (GDPR + national health data laws). Patient data processed by an AI agent must comply with both GDPR and national health-data regulations. Most health authorities classify clinical data retrieval through LLMs as a processing activity that requires a Data Protection Impact Assessment (DPIA). Never send unanonymised patient data to a general-purpose model API. If you need LLM inference in healthcare, run a dedicated model on your own infrastructure or use a provider with a HIPAA BAA and a contractual commitment to data isolation.
Finance (MiFID II record-keeping). MiFID II requires that all client-facing communications and order-processing steps be recorded and retained for at least five years. If an AI agent recommends a trade or processes a transaction, the entire decision chain — model input, output, reasoning (if available), and any human override — must be recorded as a communication record. The audit trail described above becomes a regulatory requirement with a five-year minimum retention period.
HR and employment (GDPR Article 22). Article 22 prohibits solely automated decision-making that produces legal effects concerning an individual. If your AI agent ranks job applicants or makes hiring recommendations, it must involve meaningful human review. The agent’s output becomes a recommendation subject to human override, and the human’s decision must be documented alongside the agent’s suggestion. The EU AI Act extends this to a broader set of high-risk AI systems with mandatory human oversight.
Conclusion
Data governance for AI workflows reduces to five operational controls: classify data before it reaches a model, minimise what you send, log every decision immutably, check consent at inference time, and verify your vendors’ compliance posture. Implement these in your AI gateway layer — a single middleware stack that every agent pipeline routes through — and you cover 90% of the regulatory surface area.
Start with the Forbidden category — run a quick audit of data that currently reaches your model calls and identify anything that should never be sent. That single pass catches the most risk for the least effort and gives your compliance team a concrete answer to the first question any auditor will ask: “What data is your AI touching, and what controls exist to protect it?”
For more on the security side of AI agents, read our post on Securing AI Agents Against Prompt Injection. To understand the observability layer that supports audit trails, read Observability for AI Agents: What to Log, Trace, and Alert On.
Related What I Do
Related What I Do
These What I Do pages are matched from the subject matter of this article, creating a cleaner path from educational content to implementation work.
Continue reading
Related articles
Based on shared categories first, then the strongest overlap in tags.