SOC 2 Type II & HIPAA Compliance for US Enterprise AI Agents: Implementing Zero-Retention LLM Gateways, PII Redaction, and Immutable Audit Trails
Passing US Enterprise InfoSec Questionnaires
Every B2B AI startup selling into the US market eventually hits the same 200-question SOC 2 Type II / HIPAA Security Questionnaire from a prospective Fortune 500 or healthcare buyer:
- "Do your sub-processors retain customer prompts or train on PHI/PII?"
- "Can you prove what exact database rows and external APIs your autonomous agent touched during a user session?"
- "Is customer data guaranteed to stay inside US-East / US-West regions?"
Answering these cleanly requires architectural enforcement at your LLM & MCP Gateway, not just legal PDFs.
Compliance Gateway Architecture (US-East Zero Retention)
text[US Enterprise User / SaaS App] │ ▼ [1. Local Presidio PII / PHI Scrubber (<12ms)] • Masks SSNs, MRNs, Credit Cards, Emails -> Reversible Vault Tokens (<SSN_1>) │ ▼ [2. Zero-Data-Retention (ZDR) Regional Gateway] • AWS Bedrock (us-east-1) / Anthropic ZDR / VPC vLLM (BAA-covered) • Zero prompt logging on provider side │ ▼ [3. Immutable WORM Audit Trail (S3 Object Lock / Append-Only Postgres)] • Logs {actor_id, tool_name, args_hash, policy_decision, timestamp_utc}
Python PII Tokenization Middleware Before LLM Egress
Instead of stripping PII destructively (which breaks downstream tool calls like lookup_patient_id), replace sensitive fields with session-scoped reversible placeholders before tokens ever leave your VPC:
pythonfrom presidio_analyzer import AnalyzerEngine import uuid analyzer = AnalyzerEngine() class ReversiblePiiVault: def __init__(self): self.token_map: dict[str, str] = {} def redact_before_llm(self, text: str) -> str: results = analyzer.analyze( text=text, entities=["US_SSN", "CREDIT_CARD", "PHONE_NUMBER", "EMAIL_ADDRESS"], language="en", ) # Replace from right to left so character offsets stay valid redacted = text for res in sorted(results, key=lambda r: r.start, reverse=True): original = text[res.start:res.end] placeholder = f"<{res.entity_type}_{uuid.uuid4().hex[:6]}>" self.token_map[placeholder] = original redacted = redacted[:res.start] + placeholder + redacted[res.end:] return redacted def restore_for_authorized_tool(self, tool_args: dict) -> dict: # Re-hydrate inside trusted VPC only when executing an authorized internal tool serialized = str(tool_args) for placeholder, original in self.token_map.items(): serialized = serialized.replace(placeholder, original) return eval(serialized) # Use recursive dict walk in production
Key US Compliance Controls Auditors Check
- Signed BAAs + Zero Data Retention (ZDR): Standard consumer/developer API tiers often retain logs for 30 days for abuse monitoring. Enterprise healthcare/fintech requires explicit ZDR flags or AWS Bedrock/Azure Private Link inside
us-east-1. - Immutable Tool Audit Logs: Store every MCP tool invocation in an S3 Object Lock (WORM) bucket or append-only audit table so neither admins nor compromised agents can erase execution history.
- Tenant-Isolated Encryption Keys (CMK): Use AWS KMS Customer-Managed Keys per enterprise tenant for vector/episodic memory stores.