# MemoryOS

> An OS-style memory system for personalized AI agents, with short-, mid- and long-term memory tiers

- Category: Agents & Automation / Agent Memory
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/BAI-LAB/MemoryOS
- Website: https://baijia.online/memoryos/
- Canonical page: https://ai-tldr.dev/tools/memoryos/
- Updated: 2025-07-18

## In short

MemoryOS is a memory system for personalized AI agents from the BaiJia AI team, a research group led by Associate Professor Bai Ting at Beijing University of Posts and Telecommunications. It sits in the Agent Memory category of the Agents & Automation tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

MemoryOS is a memory system for personalized AI agents from the BaiJia AI team, a research group led by Associate Professor Bai Ting at Beijing University of Posts and Telecommunications. It borrows from how operating systems manage memory: a hierarchical store with four core modules — Storage, Updating, Retrieval and Generation — so that a long-running assistant keeps a coherent picture of the user across many conversations. The project accompanies the paper "Memory OS of AI Agent" (arXiv 2506.06326), which the README says was accepted to the EMNLP 2025 main conference.

Memory is kept in three tiers. New user–assistant exchanges land in short-term memory; when it fills, the updater consolidates them into mid-term segments. Mid-term segments accumulate "heat" from how often they are visited and how long the interactions were, and once a segment passes a threshold its content is analysed into a long-term persona memory: a user profile, facts about the user and the assistant's own knowledge base. At answer time the retriever pulls from all of these layers and the generation step passes that context to the LLM.

It ships in several forms: a PyPI package (`memoryos-pro`), MemoryOS-MCP — an MCP server exposing `add_memory`, `retrieve_memory` and `get_user_profile` tools to clients such as Claude Desktop, Cline and Cursor — a ChromaDB-backed variant, a Docker image and a Flask playground that shows the three memory tiers filling as you chat. All model calls go through the OpenAI API interface, so OpenAI, Anthropic, DeepSeek, Qwen or a local vLLM endpoint can be used with a key and base URL; embeddings default to models such as BAAI/bge-m3 or Qwen3-Embedding-0.6B. On the LoCoMo long-term-memory benchmark the README reports average improvements of 49.11% in F1 and 46.18% in BLEU-1.

## What it does

- Three-tier memory — short-term, mid-term and long-term persona memory — with heat-based promotion between tiers
- Automatic user-profile and knowledge extraction from past conversations
- MemoryOS-MCP server with `add_memory`, `retrieve_memory` and `get_user_profile` tools for Claude Desktop, Cline and Cursor
- Works with any OpenAI-compatible endpoint (OpenAI, Anthropic, DeepSeek, Qwen, vLLM) and configurable embedding models
- PyPI package, ChromaDB variant, Docker image and a web playground
- Scripts to reproduce the paper's LoCoMo evaluation

## Getting started

You need Python 3.10+ and an OpenAI-compatible API key (OpenAI, DeepSeek, Qwen or a local vLLM endpoint).

1. Install the package

   Install from PyPI, or clone the repository for the latest version.

```bash
pip install memoryos-pro -i https://pypi.org/simple

# or the latest from GitHub
git clone https://github.com/BAI-LAB/MemoryOS.git
cd MemoryOS/memoryos-pypi
pip install -r requirements.txt
```

2. Add a memory and ask about it

   Create a `Memoryos` instance per user and assistant, store a conversation turn, then ask a question that needs it. Capacities and the heat threshold control when memories move between tiers.

```python
from memoryos import Memoryos

memo = Memoryos(
    user_id="demo_user",
    openai_api_key="YOUR_OPENAI_API_KEY",
    openai_base_url="",
    data_storage_path="./simple_demo_data",
    llm_model="gpt-4o-mini",
    assistant_id="demo_assistant",
    short_term_capacity=7,
    mid_term_heat_threshold=5,
    retrieval_queue_capacity=7,
    long_term_knowledge_capacity=100,
    embedding_model_name="BAAI/bge-m3",
)

memo.add_memory(
    user_input="Hi! I'm Tom, I work as a data scientist in San Francisco.",
    agent_response="Hello Tom! Nice to meet you. What kind of data do you work with?",
)
print(memo.get_response(query="What do you remember about my job?"))
```

3. Run the MCP server for an agent client

   Fill in `config.json` (user id, API key, base URL, storage path, model, embedding model), start the server, then copy `mcp.json` into Cline, Cursor or Claude Desktop with the path to your environment's Python.

```bash
cd memoryos-mcp
pip install -r requirements.txt
python server_new.py --config config.json
```

4. Or run it in Docker

   Pull the published image, or build it from the repository's Dockerfile.

```bash
docker pull ghcr.io/bai-lab/memoryos:latest
docker run -it --gpus=all ghcr.io/bai-lab/memoryos /bin/bash
```

5. Try the playground

   Start the web demo and enter a user id, API key, model and base URL; the Help button explains each control. Memories are stored under `memoryos-playground/memdemo/data`.

```bash
cd MemoryOS/memoryos-playground/memdemo/
python3 app.py
```

## When to use it

- Give a long-running chat assistant or companion a persistent user profile that builds up over many sessions
- Add long-term memory to Claude Desktop, Cline or Cursor through the MemoryOS-MCP server
- Research or benchmark agent-memory designs with a reproducible LoCoMo evaluation

## Version history

- 2025-07-18 V1.2: Adds support for the ChromaDB vector database and fixes fixed LLM calls inside it.
