Memary: The Open Source Memory Layer for Autonomous Agents

Memary: The Open Source Memory Layer for Autonomous Agents

Summary

Memary is an innovative open-source memory layer designed to enhance autonomous agents by emulating human memory. It integrates knowledge graphs and memory modules to provide agents with advanced capabilities for reasoning and learning. This project aims to make agents more intelligent and capable of self-improvement.

Repository Info

Updated on December 28, 2025
View on GitHub

Introduction

Memary is an innovative open-source project that provides a sophisticated memory layer for autonomous agents. Designed to emulate human memory, Memary equips AI agents with enhanced reasoning, learning, and self-improvement capabilities. By integrating advanced concepts like knowledge graphs and memory modules, Memary offers a robust framework for managing agent memories, making them more effective and intelligent.

Installation

Getting started with Memary is straightforward. To install via pip, ensure you are running Python version <= 3.11.9, then execute:

pip install memary

For a local installation:

  1. Create a virtual environment with Python version <= 3.11.9.
  2. Install dependencies:
    pip install -r requirements.txt
    

Memary supports local models via Ollama (e.g., Llama 3, LLaVA) and also integrates with OpenAI models. You'll need to set up a .env file with necessary API keys for services like OpenAI, Perplexity, Google Maps, and database connections (FalkorDB or Neo4j).

Examples

Memary provides a ChatAgent class for easy integration. Basic Usage:

from memary.agent.chat_agent import ChatAgent

system_persona_txt = "data/system_persona.txt"
user_persona_txt = "data/user_persona.txt"
past_chat_json = "data/past_chat.json"
memory_stream_json = "data/memory_stream.json"
entity_knowledge_store_json = "data/entity_knowledge_store.json"
chat_agent = ChatAgent(
    "Personal Agent",
    memory_stream_json,
    entity_knowledge_store_json,
    system_persona_txt,
    user_persona_txt,
    past_chat_json,
)

For multi-agent scenarios using FalkorDB, you can create separate agents with unique user_ids:

# User A personal agent
chat_agent_user_a = ChatAgent(
    "Personal Agent",
    memory_stream_json_user_a,
    entity_knowledge_store_json_user_a,
    system_persona_txt_user_a,
    user_persona_txt_user_a,
    past_chat_json_user_a,
    user_id='user_a_id'
)

You can also easily add and remove custom tools:

def multiply(a: int, b: int) -> int:
    """Multiply two integers and returns the result integer"""
    return a * b

chat_agent.add_tool({"multiply": multiply})
chat_agent.remove_tool("multiply")

Why Use Memary

Memary is built on core principles designed to enhance agent intelligence with minimal developer effort.

  • Auto-generated Memory: Agent memory automatically updates as the agent interacts, capturing all memories for display and analysis. It supports combining different databases seamlessly.
  • Memory Modules: Tracks user preferences and knowledge depth through the Memory Stream (breadth of knowledge) and Entity Knowledge Store (depth of knowledge), offering insights into user interests and learning.
  • System Improvement: Mimics how human memory evolves and learns over time, providing metrics on agent improvement.
  • Rewind Memories: Keeps track of all chats, allowing users to rewind agent executions and access memory at specific periods (feature coming soon).
  • Knowledge Graphs: Utilizes graph databases to store knowledge, employing recursive and multi-hop retrieval for efficient information access and reduced latency.
  • New Context Window: Tailors agent responses by integrating agent responses, most relevant entities, and summarized chat history to match the user's current interests and knowledge level.

Links