Skip to navigation

Agent memory

Give an agent context from previous interactions and activity

An agent can fail a later task when it cannot retrieve information from previous conversations, user activity, or changes in preferences. Agent memory keeps this user-owned context in a temporal Context Graph.

User and thread model

A Zep user owns a user Context Graph. Threads group conversations for that user. Messages and user business data become episodes in the graph.

Use:

  • A Zep user for context that belongs to one application user. Store the user uuid and graph_uuid next to your user ID.
  • A Zep thread for a conversation or workflow that belongs to that user. Store the thread uuid next to your conversation ID.
  • thread.get_context to retrieve a Context Block for the next model request.

Implementation path

1

Create a Zep user

Create one Zep user for each application user whose context must persist.

2

Create a thread and add messages

Create one thread for the conversation, and store its UUID. Add each user and assistant message after the application receives or produces it.

3

Add user business data

Add activity, preferences, or records to the user graph (the user graph_uuid) when that data belongs to the user.

4

Retrieve user context

Call thread.get_context before the next model request and place the returned Context Block in the correct provider input. For complex tasks, give the agent tools that search the user graph with its graph_uuid pinned. See Build an Agent with Zep.

Start with the Agent memory quickstart. Then read Memory security best practices for provider-specific placement rules.

Boundaries

Agent memory provides context from prior interactions and activity. Agent memory does not guarantee model behavior or authorize an external action. Your application must control tool permissions and action authorization.