# Memary: The Open Source Memory Layer for Autonomous Agents

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/kingjulio8238-memary
Generated for open source discovery and AI-assisted research.

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.

GitHub: https://github.com/kingjulio8238/Memary
OSRepos URL: https://osrepos.com/repo/kingjulio8238-memary

## 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.

## Topics

- agents
- knowledge-graph
- memory
- multiagent-systems
- rag
- self-improvement
- Jupyter Notebook
- Artificial Intelligence

## Repository Information

Last analyzed by OSRepos: Sun Dec 28 2025 08:01:35 GMT+0000 (Western European Standard Time)
Detail views: 7
GitHub clicks: 5

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## 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:
bash
pip install memary

For a local installation:
1.  Create a virtual environment with Python version <= 3.11.9.
2.  Install dependencies:
    bash
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:
python
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_id`s:
python
# 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:
python
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
*   [GitHub Repository](https://github.com/kingjulio8238/Memary){:target="_blank"}
*   [Documentation](https://kingjulio8238.github.io/memarydocs/){:target="_blank"}
*   [Demo Video](https://youtu.be/GnUU3_xK6bg){:target="_blank"}
*   [PyPI Package](https://pypi.org/project/memary/){:target="_blank"}
*   [LinkedIn](https://www.linkedin.com/company/memary/){:target="_blank"}
*   [Follow on X](https://x.com/memary_labs){:target="_blank"}