Using Memory

Learn how to incorporate retrieved context into your LLM calls.

Provide the Context Block in Your System Prompt

Once you’ve retrieved the Context Block, or constructed your own context block by searching the graph, you can include this string in your system prompt:

MessageTypeContent
SystemYour system prompt

{Zep context block}
AssistantAn assistant message stored in Zep
UserA user message stored in Zep
UserThe latest user message

Provide the Last 4 to 6 Messages of the Thread

You should also include the last 4 to 6 messages of the thread when calling your LLM provider. Because Zep’s ingestion can take a few minutes, the context block may not include information from the last few messages; and so the context block acts as the “long-term memory,” and the last few messages serve as the raw, short-term memory.