Zep
The ZepTools toolkit enables an Agent to interact with a Zep memory system, providing capabilities to store, retrieve, and search memory data associated with user sessions.
ZepTools enable an Agent to interact with a Zep memory system, providing capabilities to store, retrieve, and search memory data associated with user sessions.
Prerequisites
The ZepTools require the zep-cloud Python package and a Zep API key.
1uv pip install zep-cloud1export ZEP_API_KEY=your_api_keyExample
The following example demonstrates how to create an agent with access to Zep memory:
1import time23from kern.agent import Agent4from kern.models.openai import OpenAIResponses5from kern.tools.zep import ZepTools67# Initialize the ZepTools8zep_tools = ZepTools(user_id="kern", session_id="kern-session", add_instructions=True)910# Initialize the Agent11agent = Agent(12 model=OpenAIResponses(id="gpt-5.2"),13 tools=[zep_tools],14 dependencies={"memory": zep_tools.get_zep_memory(memory_type="context")},15 add_dependencies_to_context=True,16)1718# Interact with the Agent so that it can learn about the user19agent.print_response("My name is John Billings")20agent.print_response("I live in NYC")21agent.print_response("I'm going to a concert tomorrow")2223# Allow the memories to sync with Zep database24time.sleep(10)2526# Refresh the context27agent.context["memory"] = zep_tools.get_zep_memory(memory_type="context")2829# Ask the Agent about the user30agent.print_response("What do you know about me?")Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
session_id | str | None | Optional session ID. Auto-generated if not provided. |
user_id | str | None | Optional user ID. Auto-generated if not provided. |
api_key | str | None | Zep API key. If not provided, uses ZEP_API_KEY env var. |
ignore_assistant_messages | bool | False | Whether to ignore assistant messages when adding to memory. |
enable_add_zep_message | bool | True | Add a message to the current Zep session memory. |
enable_get_zep_memory | bool | True | Retrieve memory for the current Zep session. |
enable_search_zep_memory | bool | True | Search the Zep memory store for relevant information. |
instructions | str | None | Custom instructions for using the Zep tools. |
add_instructions | bool | False | Whether to add default instructions. |
Toolkit Functions
| Function | Description |
|---|---|
add_zep_message | Adds a message to the current Zep session memory. Takes role (str) for the message sender and content (str) for the message text. Returns a confirmation or error message. |
get_zep_memory | Retrieves memory for the current Zep session. Takes optional memory_type (str) parameter with options "context" (default), "summary", or "messages". Returns the requested memory content or an error. |
search_zep_memory | Searches the Zep memory store for relevant information. Takes query (str) to find relevant facts and optional search_scope (str) parameter with options "messages" (default) or "summary". Returns search results or an error message. |
Async Toolkit
The ZepAsyncTools class extends the ZepTools class and provides asynchronous versions of the toolkit functions.
Developer Resources
- View Tools