How do you achieve per-tenant isolation and data privacy in a multi-tenant RAG/agent SaaS?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
The core threat is cross-tenant leakage - tenant A's data surfacing in tenant B's answers - which happens through shared indexes, shared caches, and under-scoped tools. Isolation has to hold at every stateful layer.
Full worked answer
The core threat is cross-tenant leakage - tenant A's data surfacing in tenant B's answers - which happens through shared indexes, shared caches, and under-scoped tools. Isolation has to hold at every stateful layer.
Retrieval / vector store. Options, strongest to weakest: (1) separate index/database per tenant - strongest isolation, higher operational cost, best for high-value/regulated tenants; (2) namespace/partition per tenant within a shared store (Pinecone namespaces, per-tenant collections) - good balance; (3) shared index with a mandatory tenant_id metadata filter - cheapest, but one missing filter is a breach, so enforce it in a single choke-point query layer, never trust callers, and test it adversarially. Whatever you choose, apply ACL filters at query time so within-tenant permissions hold too (user X can't retrieve doc user Y can't see).
Caches. Prompt caches, semantic caches, and embedding caches must be keyed by tenant (and often by user). A semantic cache that returns tenant A's cached answer to tenant B's similar question is a classic silent leak.
Model / context. Never batch multiple tenants' data into one context. If fine-tuning, fine-tune per tenant or not at all on tenant data (shared fine-tuned weights leak via memorisation across tenants) - prefer RAG so deletion and isolation are clean.
Tools / agents. Scope every credential and tool to the acting tenant: per-tenant API keys, row-level security in databases, short-lived scoped tokens. An agent must never hold a credential broader than the current tenant.
Infra / compliance. Per-tenant encryption keys where required; VPC or dedicated deployment for enterprise tiers; audit logs partitioned by tenant; and honour deletion per tenant (drop their index/namespace and purge caches - trivial for RAG, another reason to avoid baking tenant data into weights).
The interview signal: naming the cache and the missing-filter failure modes unprompted, and matching isolation strength to tenant risk rather than one-size-fits-all.
What a good answer covers
- The core threat is cross-tenant leakage - tenant A's data surfacing in tenant B's answers - which…
- Isolation has to hold at every stateful layer
- Options, strongest to weakest
- Whatever you choose, apply ACL filters at query time so within-tenant permissions hold too (user X can't…
- Prompt caches, semantic caches, and embedding caches must be keyed by tenant (and often by user)
Key terms: cross-tenant leakage · Retrieval / vector store · separate index/database per tenant · namespace/partition per tenant · ACL filters at query time · Caches · must be keyed by tenant · Model / context · Tools / agents · Infra / compliance
In the glossary: Fine-tuning · Memorisation · RAG
Interviewer follow-ups to expect
What's the failure mode of the "shared index + tenant_id filter" approach, and how do you harden it?
How does a semantic cache leak across tenants?
Why does fine-tuning on tenant data complicate isolation and deletion?
Infra / compliance. Per-tenant encryption keys where required; VPC or dedicated deployment for enterprise tiers; audit logs partitioned by tenant; and honour deletion per tenant (drop their index/namespace and purge caches - trivial for RAG, another reason to avoid baking tenant data into weights).
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep