ai
Running AI Agents on Customer Data Without Leaving Your Boundary: Architecture Patterns
By Art Kukharenko · Published · Updated
Browse ai resourcesTo run AI agents on customer data safely, keep the model, the tools and the data inside infrastructure you control or contractually cover. Give each agent least-privilege tool access, mask personal data before it reaches the model, require human approval for every write or activation, and log each action with the actor, model version and inputs hash. This article shows how, for a customer data platform (CDP).
Who this is for: CTOs, architects, CISOs, DPOs and marketing-operations leads in banks, healthcare, iGaming, government and other regulated sectors who are being asked to "add agents" to the stack. You will get an architecture, a risk table, the regulatory touchpoints and a 15-point checklist. This page belongs to the AI hub.
What "AI agent" means in this article
Anthropic separates workflows, in which LLMs and tools follow predefined code paths, from agents, in which LLMs "dynamically direct their own processes and tool usage" 1. Here, an agent is the second kind plus approvals: a tool-using LLM loop with approvals. The model proposes a step, a runtime executes a tool your code has exposed, the result returns to the model's context, and the loop repeats until the task ends or a gate stops it.
Three consequences follow.
- The model's context is a data path. Whatever a tool returns goes wherever the model runs.
- The tool list is the permission system. The agent can do what its tools allow, provided the tools enforce it.
- The approval gate is the deterministic control. Everything the model does is probabilistic, so anything that must not happen needs a rule outside the model.
Anthropic advises finding the simplest solution possible and notes that single LLM calls with retrieval are often enough 1. Much marketing-operations work (nightly QA, report summaries) is a workflow with an LLM step. Use a loop only where the path cannot be written down in advance.
The data-exposure problem with SaaS-hosted agents
Agents multiply the places where customer data is copied into model context. Five exposure paths matter in practice.
- Context transfer. Everything a tool retrieves and places in a prompt leaves your environment if a third party hosts the model. Amperity's MCP documentation says tool results may contain PII and tells customers to confirm their AI client is approved to handle it 15.
- Provider-side processing and retention. Contract-covered endpoints still process data. Microsoft's Azure documentation says prompts and completions are not shared with other customers or used to train foundation models, yet it also describes abuse monitoring: samples can be selected for review, with human review where flagged, unless the customer is approved for modified abuse monitoring 5. Read your plan's terms rather than assuming zero retention.
- Processing location. On Azure, "Global" and "DataZone" deployment types may process prompts outside the resource's geography (within the zone for DataZone), while data at rest stays in the designated geography 5.
- Injection-driven exfiltration. Simon Willison's "lethal trifecta" describes an agent that combines access to private data, exposure to untrusted content, and a way to communicate externally; such an agent can be tricked into leaking data 4. OWASP lists prompt injection first and excessive agency sixth in its 2025 top ten for LLM applications 23. Klaviyo's MCP documentation warns that tools reading user-generated content (profiles, events, reviews) return text the model could interpret as instructions, and tells users to review each tool call 12.
- Connector bugs. Agent connectors are new code. Asana's MCP server launched on 1 May 2025; the company found a flaw on 4 June that could have exposed information from one customer's domain to other MCP users, and took the feature offline from 5 to 17 June; no indication of exploitation was reported 34.
When a hosted agent is the right answer. Not every task needs private inference. Hosted agents are reasonable when the data is aggregated or non-personal (Braze's MCP tools cover aggregated analytics, custom attributes and segments, and do not return data from user profiles 13), when you have read the vendor's business associate or data processing agreement, when volume is low, and when you cannot staff GPU operations. AWS lists Amazon Bedrock as HIPAA eligible, subject to a business associate agreement 67. The useful question is "what crosses which boundary, under which contract". For personal-data-heavy work in regulated industries, keeping inference and tool execution inside your boundary removes whole categories of review: transfer assessments, sub-processor changes and provider retention terms.
Seven architecture patterns for agents inside your boundary
"Inside your boundary" means the network and legal perimeter in which you hold the keys, logs and processors. Terms used here:
- On-premise: hardware you operate in your own or a colocation data centre.
- Private cloud: a single-tenant environment, often a VPC in your own AWS, Azure, GCP or OCI account.
- Self-hosted: you operate the software, wherever it runs.
- Customer-owned: you hold the keys, the data and operational control.
- Sovereign: deployment constrained to a jurisdiction and to operators under its law.
1. Place the model deliberately
Choose among three placements, per data class rather than per application.
- Private inference on your own GPUs with an open-weight model; see on-premise LLM deployment.
- A contract-covered endpoint in your cloud account, such as Bedrock with PrivateLink 7 or an Azure DataZone deployment 5.
- A public API under a data processing agreement, for non-personal data only.
Put a gateway in front of the endpoints that enforces which data classes may reach which model. Under GDPR Article 28 the processor must act on documented instructions, keep personnel under confidentiality, delete or return data at the end of the service and allow audits 23.
2. Expose data through least-privilege tool servers
Agents should reach customer data only through narrow tools, never through database credentials. OWASP's guidance on excessive agency names three root causes (excessive functionality, permissions and autonomy) and recommends minimal extensions, no open-ended tools such as shell or URL fetch, read-only scopes where possible, acting as the individual user, human approval for high-impact actions, and authorization enforced downstream rather than by the model 3. MCP's security guidance agrees on scopes: start minimal, elevate incrementally, avoid wildcards 9.
Vendors already do some of this. Salesforce ships separate standard servers for reads, mutations and deletes, disabled by default, with field-level security and sharing rules applied to every call 1011. Klaviyo offers a read-only=true option on its remote server 12. Mirror the pattern: one tool server per risk tier (read, draft, execute), each with its own credentials and approval policy. The protocol itself is covered in What Is MCP.
3. Minimize and mask personal data before the model sees it
GDPR Article 25 requires that, by default, only the personal data necessary for each specific purpose is processed, and names pseudonymization as an example measure 21. In an agent, that translates into six rules.
- Aggregate first. Tools return counts, distributions and segment IDs rather than rows.
- Mask at the tool layer. The model receives tokens such as
cust_8f3aand[MASKED], never raw direct identifiers. - Tokenize deterministically so the agent can join records without seeing values; re-identify only in the execution layer, after approval.
- Apply minimum group sizes to any slice.
- Exclude special-category and payment-card fields from agent-visible schemas.
- Redact free text (notes, transcripts), which carries incidental identifiers and injection payloads.
An instruction in the prompt to "ignore the email column" is not masking.
4. Gate every write and activation with approval
Write tools should produce a proposal (diff, affected audience count, channels, schedule), a named human approves it in a separate interface, and an execution service with its own credentials performs it. The MCP specification says there should always be a human in the loop with the ability to deny tool invocations 8. The pattern is visible across vendors: Tealium's Configuration MCP stages AI-generated changes as drafts and never publishes them, so a person publishes in the Tealium interface 14; Braze recommends not using auto-mode 13; Salesforce runs each MCP transaction as the authenticated user, so the audit trail shows that person's name 10. Add thresholds: larger or sensitive audiences need two approvers, approvals expire, and executions carry idempotency keys.
5. Record every action in an audit ledger
Log one record per agent action, written outside the agent's own permissions, with:
- actor: the human principal, the agent identity and the runtime;
- tool name and version, plus parameters and result stored as hashes with the payload in a protected store;
- model name and version, or the weights hash or endpoint version;
- prompt template version and the inputs hash, a hash of the exact context assembled for the call;
- policy version, approval ID, approver and outcome.
Make the ledger append-only (hash-chained or write-once storage) and hold pseudonymous references rather than raw personal data, so erasure requests do not break its integrity. It lets you answer a regulator, auditor or data subject later; see Explainable AI for Customer Decisions. PrivyCDP records every AI-assisted action in an append-only audit ledger; the pattern is implementable on any platform.
6. Evaluate and red-team before and after every change
Anthropic recommends extensive testing in sandboxed environments with appropriate guardrails, because agent autonomy brings higher costs and compounding errors 1. A working programme has five parts:
- Task golden sets with expected tool calls and outputs.
- An injection corpus: poisoned profile fields, event payloads, review text and tool descriptions, including the trifecta combination.
- Permission tests that attempt out-of-scope calls.
- Regression runs on any change of model, prompt or tool schema, and when a vendor server changes its tool descriptions. Invariant Labs describes "rug pull" attacks in which a server alters a tool description after approval 35.
- Shadow mode, where the agent proposes and humans act, plus tracked metrics: tool-call accuracy, false-approval rate, escaped errors.
7. Build a kill switch and drill it
A kill switch needs central revocation of agent tokens, a flag that disables each tool server, a freeze on the execution queue and scheduled runs, and a rollback path for recent approvals. The EU AI Act describes, for high-risk systems, a "stop" button or similar procedure that brings the system to a safe halt 27; it is a sensible target for any agent. Drill it quarterly and record the time to stop.
Agent tasks by risk and the controls each needs
Scroll horizontally to compare all columns ↔
| Task | Example | Risk | Required controls | Approval | Autonomy ceiling |
|---|---|---|---|---|---|
| Read-only analysis | Summarize churn drivers; compare cohorts | Low to medium: disclosure through context; injection can steer queries | Aggregate-first tools, masking, read-only scopes, group limits, logging | None for the answer | Autonomous reads within scope |
| Segment drafts | Turn a brief into a segment definition; propose lookalikes | Medium: wrong or sensitive audiences | Draft-only tool; blocked-attribute validation; audience-size preview; reasons recorded | Human accepts before the segment goes live | Proposes only |
| Workflow QA | Check journeys for broken links, missing suppression, consent gaps | Medium: false assurance | Read-only config access; deterministic rule checks as ground truth; findings logged | Human resolves findings | Reads and reports |
| Anomaly detection and reporting | Flag a delivery drop or event spike; draft a weekly report | Low to medium | Read-only metrics; fixed thresholds; human triage | None for alerts | Alerts; pausing a send only under a pre-approved rule |
| Activation | Send, sync an audience to an ad platform, publish a journey | High: external, hard-to-reverse effects; personal data leaves the boundary | Separate execution service; diff and audience count; two approvers above a threshold; consent and suppression enforced in the execution layer; kill switch | Required every time | None |
| Data subject requests and consent changes | Erasure, access, withdrawal | High: legal deadlines and irreversibility | Rules engine executes; agent may only assemble evidence; human sign-off | Required | None for execution |
The ceiling column is the point of the table: raising a task's autonomy is a decision with an owner, not a configuration change. The roadmap describes the sequence in which teams earn that trust.
The market reality: agent washing, cancellations and the MCP wave
Gartner predicted on 25 June 2025 that over 40% of agentic AI projects will be cancelled by the end of 2027 because of escalating costs, unclear business value or inadequate risk controls. It also described "agent washing", the rebranding of assistants, robotic process automation and chatbots without substantial agentic capability, and estimated that only about 130 of the thousands of agentic AI vendors are real 16. Its 2026 Hype Cycle for Agentic AI puts the technology at the Peak of Inflated Expectations: a 2026 Gartner CIO survey found 17% of organizations had deployed AI agents and more than 60% expected to within two years, while fully autonomous agents are not ready for most enterprise use cases 17.
Spending is real regardless: Salesforce reported Agentforce and Data 360 annual recurring revenue of nearly $3.9 billion for its quarter ended 31 July 2026, and widened its separate Agentforce ARR definition that quarter 18. Treat such figures as vendor-defined.
One caution applies to all of them. A vendor's MCP server inherits the user's permissions, which is good, but it does not decide where the model runs; the AI client the user connects does. Amperity says handling of data after it reaches the AI application is the customer's responsibility 37. An "agentic AI customer data platform" is only as private as the model placement you choose in pattern 1.
EU AI Act and GDPR Article 22 touchpoints
Scroll horizontally to compare all columns ↔
| Rule | What it says | What it means for agents on customer data |
|---|---|---|
| GDPR Art. 22(1)-(3) | A right not to be subject to a decision based solely on automated processing, including profiling, with legal or similarly significant effects. Exceptions (contract, law, explicit consent) need safeguards: human intervention, the chance to express a view and to contest 19 | An agent that decides credit offers, account restrictions or eligibility is in scope. Design approvals so the reviewer can change the outcome. |
| GDPR Art. 15(1)(h) and CJEU C-203/22 (27 Feb 2025) | Meaningful information about the logic involved. The Court held that the controller must explain the procedure and principles actually applied, and that communicating a complex formula alone is not enough 2025 | Log what the agent did and why; "the model decided" is not an answer. |
| CJEU C-634/21 (7 Dec 2023) | Automated creation of a credit score can itself be an automated individual decision when a third party draws strongly on it 24 | An agent that produces a score others rely on can trigger Article 22. |
| Dutch DPA fine on Uber | EUR 824,990,000 for unlawful automated decision-making and insufficient information on profiling, announced August 2026; Uber has appealed 26 | Automated actions against individuals carry serious penalties. |
| GDPR Art. 25 and 35 | Data protection by design and by default; a DPIA where systematic, extensive automated evaluation, including profiling, supports decisions with legal or similarly significant effects 2122 | Document each agent's data classes and purpose before launch. |
| AI Act Art. 5(1)(a)-(b) | Bans subliminal, manipulative or deceptive techniques and exploiting vulnerabilities (age, disability, social or economic situation) that cause significant harm; applies since 2 Feb 2025 31 | Personalization agents must not be optimized against vulnerable audiences, a live issue in gambling and consumer finance. |
| AI Act Art. 50 | Transparency duties, including telling people when they interact with an AI system; applies from 2 Aug 2026 3032 | Customer-facing agents need disclosure. |
| AI Act Annex III, Art. 12, 14, 26 | Credit scoring (not fraud detection) and life and health insurance pricing are high-risk. Duties include automatic logging, human oversight and deployer log retention of at least six months 33282729. Regulation (EU) 2026/1744 moved Annex III application to 2 Dec 2027 32 | Marketing segmentation and personalization are not high-risk per se, but agents touching credit or insurance decisions are. |
Dates and details are in the EU AI Act guide and the deadline tracker; a policy your team can adopt is in the AI governance policy template.
A 15-point controls checklist
- Inventory every agent: owner, purpose, data classes, tools, model endpoint.
- Classify data and decide, per class, which model endpoints may see it; enforce this at a gateway.
- Place the model privately or on a contract-covered endpoint; read the agreement, abuse-monitoring and retention terms.
- Expose data only through tool servers; no direct database credentials for agents.
- Separate read, draft and execute tiers with separate credentials.
- Grant least-privilege scopes, no wildcards, acting as the individual user where supported.
- Use aggregate-first tools and minimum group sizes on slices.
- Mask or tokenize direct identifiers, special-category and payment-card fields at the tool layer; redact free text.
- Treat tool results as untrusted input. Never combine private data, untrusted content and an outbound channel in one agent without an approval step.
- Require approval for every write and activation (diff, audience count, expiry); two approvers above a threshold.
- Enforce consent and suppression in the execution layer, never by prompt.
- Keep an append-only audit ledger with actor, model version, prompt version, inputs hash and approval ID.
- Run an evaluation suite with an injection corpus on every model, prompt or tool change; use shadow mode before go-live.
- Test the kill switch, token revocation and rollback each quarter.
- Document the legal analysis per agent (legal basis, DPIA, Article 22, AI Act class, log retention) and review it quarterly.
If you are designing agents for a regulated stack, the PrivyCDP team can review your architecture against these patterns, covering model placement, tool scopes, approval gates and ledger fields, as part of a deployment qualification conversation. More on the AI layer is in the AI hub and on /cdp.
Frequently asked questions
What is an AI agent in marketing automation?
It is software in which a language model repeatedly chooses and calls tools, such as querying segments, drafting a campaign or checking a workflow, until a task is finished. Unlike a normal automation, the model chooses the steps. In regulated teams an agent should propose changes, and humans should approve any write or activation.
Is it safe to connect an AI agent to a customer data platform?
It can be, if the connection is narrow and governed: least-privilege tool servers, masked identifiers, tool results treated as untrusted, the model inside your boundary or under a contract you have read, and approval for writes. It is unsafe to give an agent database credentials, or an outbound channel combined with private data and untrusted content.
Do AI agents on customer data trigger GDPR Article 22?
Only when an agent's output forms or drives a decision based solely on automated processing that has legal or similarly significant effects, such as credit or eligibility outcomes. Ordinary segmentation drafts reviewed by staff usually do not. The Uber fine shows regulators will test automation claims 26. Ask your DPO to assess each use case.
Can AI agents run on-premises or in a private cloud?
Yes. Open-weight models can run on your own GPUs in a data centre or a VPC, and tool servers run next to the customer data platform. Models, licences and hardware are covered in the on-premise LLM guide. Private inference costs more to operate than an API at low volume, so decide per data class.
What is an agentic customer data platform (CDP)?
An agentic customer data platform exposes profiles, segments, events and decisions to AI agents through governed tools rather than only through a user interface. Several vendors now ship MCP servers for this. What makes one trustworthy is the permission model, approval gates and audit trail, not the label; Gartner's "agent washing" warning applies 16.
What should be logged for each agent action?
At minimum: the human principal and agent identity, tool and parameters (hashed), model name and version, prompt version, a hash of the exact inputs, policy version, approval ID and approver, and the outcome. Logs should be append-only and hold pseudonymous references. For high-risk AI Act uses, deployers must keep the logs they control for at least six months 29.
Sources
- Anthropic, "Building effective agents", 19 Dec 2024 Open source
- OWASP, Top 10 for LLM Applications 2025 Open source
- OWASP, LLM06:2025 Excessive Agency Open source
- Simon Willison, "The lethal trifecta for AI agents", 16 Jun 2025 Open source
- Microsoft Learn, Data, privacy, and security for Foundry Models sold by Azure (updated June 2026) Open source
- AWS, HIPAA eligible services reference Open source
- AWS, Amazon Bedrock security and compliance Open source
- Model Context Protocol specification, Tools (revision 2026-07-28), security considerations Open source
- Model Context Protocol, Security Best Practices (scope minimization) Open source
- Salesforce Developers Blog, "Salesforce Hosted MCP Servers Are Now Generally Available", April 2026 Open source
- Salesforce Developers, Standard MCP Servers Reference Open source
- Klaviyo Developers, Connect to the Klaviyo MCP server Open source
- Braze Docs, The Braze MCP server Open source
- Tealium Docs, About Tealium Configuration MCP Open source
- Amperity Docs, About the Amperity MCP server Open source
- Gartner press release, 25 Jun 2025 Open source
- Gartner, "What the 2026 Hype Cycle for Agentic AI Reveals", 15 Apr 2026 Open source
- Salesforce, Q2 FY27 results, 26 Aug 2026 Open source
- GDPR Article 22 Open source
- GDPR Article 15 Open source
- GDPR Article 25 Open source
- GDPR Article 35 Open source
- GDPR Article 28 Open source
- CJEU, Case C-634/21 SCHUFA Holding (Scoring), 7 Dec 2023 Open source
- CJEU, Case C-203/22 Dun & Bradstreet Austria, 27 Feb 2025 Open source
- EDPB, "Dutch DPA fines Uber EUR 824 990 000 for unlawful automated decision-making and insufficient information on profiling" Open source
- EU AI Act, Article 14 (human oversight) Open source
- EU AI Act, Article 12 (record-keeping) Open source
- EU AI Act, Article 26 (deployer obligations) Open source
- EU AI Act, Article 50 (transparency) Open source
- EU AI Act, Article 5 (prohibited practices) Open source
- Regulation (EU) 2026/1744 (Digital Omnibus on AI), OJ 24 Jul 2026 Open source
- EU AI Act, Annex III Open source
- The Register, Asana MCP server bug, 18 Jun 2025 Open source
- Invariant Labs, MCP tool poisoning attacks, 1 Apr 2025 Open source
- HubSpot Developers changelog, "Remote HubSpot MCP server is now generally available" Open source
- Amperity, "MCP server for customer data", 13 Jul 2026 Open source
Put this evaluation into practice.
Request an architecture reviewThis article is general information, not legal advice.
Further reading
- AI and customer data operations
- What Is an MCP Server? Model Context
- AI Governance for Marketing: A Policy
- AI Marketing Operations Roadmap
- Explainable AI for Marketing
Published: · Updated:
Publication date recorded for the approved release. Editorial updates do not establish legal approval or a customer result.