Unify customer and account context
A customer task can require personal context and information that belongs to the customer’s account. Keep each source in its correct scope:
- A user graph stores a person’s conversations, activity, and preferences. The
application addresses the graph with
user_id. - A shared account Context Graph stores account records and support events. The
Context Graph also stores contracts, product documents, and other shared
data. The application addresses the graph with
graph_id.
This recipe creates both scopes and retrieves from them for one authorized support task.
Set up the user, thread, and account graph
Use stable identifiers from your application. This example uses one user, one conversation thread, and one account Context Graph.
Add shared account sources
Add each shared source to the account Context Graph. The example combines an account record, a support event, and a product document.
Wait until the account context is searchable
Zep processes episodes asynchronously. Poll the last submitted account episode, and then retry a query that is specific to the imported data. The ingestion status guide explains the processing order and production alternatives to polling.
Retrieve personal and account context
Authorize the account in your application before you request its Context Graph. Then record the current user message, retrieve its Context Block in the same request, and search the authorized account graph.
Put the two context values in the model request as untrusted reference data. Keep stable application instructions in a higher-priority message. Do not put retrieved context in a developer or system message.
After the model returns a response, add the assistant message to the thread so that later tasks can retrieve it as agent memory.
Apply governance
Your application must validate the relationship between the user and the account. You can also use policy-based access control to limit an API key to permitted account graphs and sources.
Retain the source episode references from account search results when you must trace retrieved facts to their sources.