Hierarchical Context
Blend individual user memory with shared group knowledge.
Problem Statement
In enterprise apps, users belong to groups (Companies, Departments). If User A teaches the agent "Our holiday policy is X," User B should know this immediately. However, User A's private "I like coffee" preference should remain private.
Architecture: Context Fusion
We maintain separate graphs for User and Group, and fuse them at runtime.
Implementation Steps
1. Setting up Scopes
We create a shared "Company" scope and ingest static business data into it.
2. The Dual-Search Pattern
When a user asks a question, we execute two searches in parallel: one for their personal preferences, and one for the shared inventory.
3. Context Stacking
The final step is formatting these distinct sources so the LLM understands their relationship.
Data Privacy
This architecture ensures strict data segregation. Queries to the COMPANY_ID never return user_alice's private data, and vice versa. You can effectively "wipe" a user's memory without affecting the company knowledge base.