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.

pip install zep-cloud
export ZEP_API_KEY=your_api_key

Example

The following example demonstrates how to create an agent with access to Zep memory:

cookbook/tools/zep_tools.py
import time

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.zep import ZepTools

# Initialize the ZepTools
zep_tools = ZepTools(user_id="agno", session_id="agno-session", add_instructions=True)

# Initialize the Agent
agent = Agent(
    model=OpenAIChat(),
    tools=[zep_tools],
    context={"memory": zep_tools.get_zep_memory(memory_type="context")},
    add_context=True,
)

# Interact with the Agent so that it can learn about the user
agent.print_response("My name is John Billings")
agent.print_response("I live in NYC")
agent.print_response("I'm going to a concert tomorrow")

# Allow the memories to sync with Zep database
time.sleep(10)

# Refresh the context
agent.context["memory"] = zep_tools.get_zep_memory(memory_type="context")

# Ask the Agent about the user
agent.print_response("What do you know about me?")

Toolkit Params

ParameterTypeDefaultDescription
session_idstrNoneOptional session ID. Auto-generated if not provided.
user_idstrNoneOptional user ID. Auto-generated if not provided.
api_keystrNoneZep API key. If not provided, uses ZEP_API_KEY env var.
ignore_assistant_messagesboolFalseWhether to ignore assistant messages when adding to memory.
add_zep_messageboolTrueAdd a message to the current Zep session memory.
get_zep_memoryboolTrueRetrieve memory for the current Zep session.
search_zep_memoryboolTrueSearch the Zep memory store for relevant information.
instructionsstrNoneCustom instructions for using the Zep tools.
add_instructionsboolFalseWhether to add default instructions.

Toolkit Functions

FunctionDescription
add_zep_messageAdds 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_memoryRetrieves 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_memorySearches 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