Prerequisites

The Memori toolkit requires the memorisdk Python package and a relational database connection string (SQLite, PostgreSQL, etc.).
pip install memorisdk

Example

The following example demonstrates how to create an agent with persistent memory using Memori:
cookbook/tools/memori_tools.py
from textwrap import dedent

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.memori import MemoriTools

# Setup the Memori ToolKit
memori_tools = MemoriTools(
    database_connect="sqlite:///memori_cookbook_memory.db",
    namespace="cookbook_agent",
)

# Setup your Agent
agent = Agent(
    # Add the Memori ToolKit to the Agent
    tools=[memori_tools],
    model=OpenAIChat(id="gpt-4o"),
    show_tool_calls=True,
    markdown=True,
    instructions=dedent(
        """\
        Instructions:
        1. First, search your memory for relevant past conversations using the memori tool
        2. Use any relevant memories to provide a personalized response
        3. Provide a helpful and contextual answer
        4. Be conversational and friendly

        If this is the first conversation, introduce yourself and explain that you'll remember our conversations.
    """
    ),
)

# Run your Agent
agent.print_response("I'm a Python developer and I love building web applications")

# Thanks to the Memori ToolKit, your Agent can now remember the conversation:
agent.print_response("What do you remember about my programming background?")

# Using the Memori ToolKit, your Agent also gains access to memory statistics:
agent.print_response("Show me your memory statistics")

Toolkit Params

ParameterTypeDefaultDescription
database_connectstrSQLiteDatabase connection string (e.g., “sqlite:///memory.db”, PostgreSQL, etc.).
namespacestrNoneNamespace for organizing memories (e.g., “agent_v1”, “user_session”).
conscious_ingestboolTrueWhether to use conscious memory ingestion.
auto_ingestboolTrueWhether to automatically ingest conversations into memory.
verboseboolFalseEnable verbose logging from Memori.
configdictNoneAdditional Memori configuration dictionary.
auto_enableboolTrueAutomatically enable the memory system on initialization.

Toolkit Functions

FunctionDescription
search_memorySearch through stored memories using a query string. Returns relevant past conversations and facts.
record_conversationStore a user/agent conversation in memory. Can be called manually or automatically (if auto_ingest=True).
get_memory_statsRetrieve statistics and status about the current memory system (total memories, database type, etc.).

Developer Resources