HomeRoadmapsAgent Memory Day 4
Conversational AI, Agent Memory & Multi-Turn Testing Β· Day 4 Β· 20 min

Cross-Session Isolation & Leakage Gate
Conversational AI, Agent Memory & Multi-Turn Testing β€” Day 4

Verify strict (tenant_id, user_id) memory partitioning using synthetic canary PII tokens to prove User A claims, identifiers, and preferences never bleed into User B retrieval or summaries.

⚑ Runtime: Python 3.10+ · Zero External Dependencies (unittest)🧠 Conversational AI & Agent Memory QE Lead
Multi-Tenant IsolationCanary TokensPII LeakageSession PartitioningPrivacy Gate
About this lab

A single misconfigured vector-store filter or global cache key can leak one customer's dispute ID or PII into another customer's session summary. Today you will run canary-token isolation tests against both a strictly scoped router and a deliberately leaky router to verify 100% detection coverage.

πŸ“¦Sample Codebase & Working Solution (Day 4)Available Now
View on GitHub

The official reference codebase for Day 4 is hosted in the repository. Clone the repository and navigate to day-4-session-isolation/test_day4.py to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/777abhi/agent-memory-testing-roadmap.git
cd agent-memory-testing-roadmap/day-4-session-isolation/test_day4.py
🏭Production Context & Regulated Servicing Implementation
πŸ’‘ Why We Are Doing This: Cross-session PII disclosure is a severe privacy breach in regulated financial and consumer services, triggering mandatory incident reporting.
🏒 Real-World Production Usecase: Automated canary-token leakage assertions scanning both memory retrieval payloads and generated conversation summaries across tenants and users.
βš™οΈ How Implemented in Production: ScopedMemoryRouter, LeakyMemoryRouter, and detect_cross_session_leakage in memlab/isolation.py.
Phase 1

Run Cross-Session Isolation Assertions

Execute the Day 4 multi-tenant isolation test suite and inspect canary detection.

Step 1.1: Run Day 4 Isolation Tests
Terminal β€” Run Day 4
npm run test:day4
Step 1.2: Canary Leakage Scan
memlab/isolation.py
violations = detect_cross_session_leakage(
    target_session=user_b,
    retrieved_memories=router.retrieve(user_b),
    summary_text=router.build_summary(user_b),
    other_users_canaries={"user-alpha": {"SSN-4812", "DSP-ALPHA-99"}},
)
assert violations == []
Day 4 Key Learnings
  • Enforced composite (tenant_id, user_id) partition keys across all memory writes and retrievals.
  • Verified zero cross-user and cross-tenant bleed even when two tenants share an identical user_id.
  • Proved the canary leakage detector catches misconfigured global buckets on both retrieval and summary surfaces.

🧠 Knowledge Check

Why should multi-tenant memory isolation tests seed synthetic canary tokens and scan both retrieval results and conversation summaries?