Working with Memory


A summary for the last or trailing N messages is generated on every new message added to a Session. This is done asynchronously and does not impact the latency of your requests to Zep.

Summaries are lossy. Information from earlier messages is gradually displaced by newer information. Zep supports search over historical summaries in order to retrieve relevant information from prior summaries.

List of Summaries

The first summary is generated after the first N messages are added to a Session.

N is a configurable get memory argument. The default value is 4.

Customizing Summary Generation

Available to Enterprise Plan customers only.

You can customize the contents and format of summaries by providing Custom Instructions when persisting a Memory to a Session.

1custom_instructions = """
2Focus on the user's family and friend relationships.
3Identify life goals and interests.
4Note any standout characteristics or traits about the user.
7result = await client.memory.add(
8 session_id,
9 messages=messages,
10 summary_instruction=custom_instructions

Accessing Summaries

Summaries are added to Memory responses when you retrieve a Session’s Memory. They’re also accessible the Search API and lower-level Session API.