The Problem

LLM agents forget. A chatbot that cannot recall what a user said last week produces repetitive, context-blind answers. MemoryOS addresses this with a hierarchical memory system inspired by OS memory management: short-term, mid-term, and long-term storage with explicit update, retrieval, and generation phases. It reports a 49.11% F1 improvement on the LoCoMo benchmark.

What This Does

MemoryOS is five self-contained Python projects, not a single codebase. memoryos-pypi is the core library: short_term.py, mid_term.py, and long_term.py implement the three-tier memory hierarchy, coordinated by memoryos.py. memoryos-chromadb is a variant backed by ChromaDB, with storage_provider.py handling vector collections. memoryos-mcp exposes the same functionality as an MCP server for agent tool integration. memoryos-playground is a Flask demo (memdemo/app.py) with a web UI. eval/ contains the LoCoMo benchmark harness.

All variants share the same architecture: utils.py provides chat_completion, get_embedding, and get_timestamp; memory classes handle promotion between tiers; updater.py and retriever.py manage knowledge extraction and recall.

How It Is Wired

Execution starts at three Flask routes in memoryos-playground/memdemo/app.py: chat (reaches 72 functions), import_conversations (58), and trigger_analysis (35). These route into add_memory, which calls _trigger_profile_and_knowledge_update_if_needed and makes an outbound network call via session.get within two hops.

The highest fan-in functions are get_timestamp (24 call sites), chat_completion (14), and get_embedding (11). eval/utils.py — despite its name — is the true hub: 15 functions called from 17 other files, and it performs model inference. The storage_provider.py file owns vector storage; mid_term.py owns heat/recency scoring; long_term.py owns user profiles and assistant knowledge.

The module graph shows import cycles across all four variants (33 modules in circular dependencies). The most unstable modules are the top-level memoryos.py files (instability ~0.88), meaning changing them risks breaking everything that imports them. utils.py files are stable (0.14) but sit inside cycles, so refactoring them requires coordinated changes across the variant.

How To Use It

git clone https://github.com/moses-y/MemoryOS
cd MemoryOS/memoryos-pypi
pip install -r requirements.txt

Run the playground:

cd ../memoryos-playground/memdemo
./start_demo.sh

Configuration lives in memoryos-mcp/config.json and mcp.json. The playground requires an OpenAI-compatible API key. The README documents Docker deployment; the root Dockerfile uses python:3.10-slim.

Real-World Use

An agent that remembers a user's stated preferences across sessions. Call add_memory with each conversation turn; MemoryOS promotes important facts to long-term storage and retrieves them when the user returns. The MCP server (memoryos-mcp/server_new.py) exposes these operations as tools any MCP-compatible agent can call.

Code Health & Issues

Static analysis found 69 findings (47 high, 22 medium): 33 import-cycle memberships, 20 deeply nested blocks (max depth 8 in mid_term.py), broad exception handling in storage_provider.py and eval/long_term_memory.py, and 1,610 duplicated 6-line blocks across 36 files. The code health audit flags three high issues: no CI workflow, no Docker build gate, and app.run(debug=True) in memdemo/app.py — a production risk. Medium issues: no dependency update bot, unpinned base image, and a 0.038 test-to-source ratio (2 test files, 52 source files).

The Bottom Line

The memory architecture is sound and the benchmark results are credible. The duplication across five variants will make maintenance expensive, and the missing CI is risky for a research codebase. Use it if you need a proven hierarchical memory layer and can tolerate the upkeep.