mnemos is a framework that provides persistent memory for LLM agents. It attempts to answer a more fundamental question: how to decide what to retain, how to retrieve cheaply and correctly, how to forget responsibly, how to adapt retrieval strategies based on feedback, and how to prove that it is actually effective over the long term, rather than just looking good within a single session.
[Purpose] Without persistent memory, chat agents forget everything between sessions. mnemos targets LLM agent scenarios that need to remember user information across sessions and want auditability, observability, and verifiability. It divides memory into four categories: episodic memory (what was said and when it was said), semantic memory (distilled facts about the user), procedural memory (which retrieval strategy actually works for that user), and reflection (consolidating and forgetting facts over time).
[Main capabilities]
- Multiple storage backends: episodic and semantic memory sit behind the StorageBackend interface, with options including Postgres + pgvector (default, HNSW cosine similarity search), Qdrant (embedded local mode, no server or Docker required), and Neo4j (a real graph structure, where facts are traced back to their source episodes via DERIVED_FROM edges). Switch with STORAGE_BACKEND=postgres|qdrant|neo4j. The same set of behavioral tests (tests/test_storage_contract.py) runs against all three, proving that the backends are replaceable.
- Retrieval and ranking: the query is embedded and then matched separately against episodes and facts before being merged. The default similarity weight and recency weight are 0.7/0.3, and can be selected per turn. Semantic facts are ranked mainly by similarity, while episodic turns carry an exponential recency bonus. Every retrieved memory returns its real similarity, recency, and combined score; retrieval is not a black box.
- Procedural memory: three named strategies (different combinations of similarity_weight and recency_weight), with the empirically best strategy for that user selected each turn via epsilon-greedy (epsilon approximately 0.15 exploration); the outcome is judged as success or failure for the previous turn based on whether the user's message in the next turn contains correction cues (such as "no," "that's wrong," "actually,"). The relevant data can be viewed in the dashboard.
- Reflection and forgetting: one consolidation per user (triggered on demand, not scheduled in the background). Merge clusters active facts with high cosine similarity and generates a consolidated statement through Anthropic tool calling, original facts are marked as merged (soft delete, retaining audit); Decay lowers the confidence of facts that have not been reinforced for a long time; Forget marks facts whose confidence is below a threshold as forgotten. Each action is written to reflection_log. Reinforcement is the opposite of decay: facts that enter the retrieval results update last_reinforced_at and slightly increase confidence.
- Dashboard: React 19 + Vite + TypeScript, connecting to FastAPI over HTTP, including six views: Chat, Memory Browser (filter by active/merged/forgotten), Retrieval Trace (including an "as of" historical date selector, allowing you to see what would be retrieved at a past point in time and why), Timeline & Stats, Reflection Log (including a manual run reflection button), Procedural Strategies.
- Benchmark: benchmark/run_benchmark.py seeds 18 synthetic conversations on simulated days 0-18, each mentioning only one fact about a fictional user, then asks 18 probe questions at later times (some the same day, some a week later, some 30 days later), comparing "with memory" and "without memory (stateless baseline)" cases, evaluating retrieval recall@K and answer accuracy respectively (keyword matching on generated replies).
[How to use] The project has not yet been published to PyPI and is currently installed via git clone. Docker support is not provided. To use the full HTTP API + dashboard, or to try the Qdrant/Neo4j backends, refer to the Running it section of the repository. The system includes MemoryEngine (src/mnemos/memory/engine.py, the sole seam wrapping StorageBackend and EmbeddingClient), ConversationManager (src/mnemos/agent/conversation.py, each turn loop: select strategy -> recall -> build system prompt -> call LLM -> store new episodic -> periodically extract semantic facts -> settle the previous turn's strategy result), LLMClient (supports Anthropic and Groq, as well as an offline MockLLMClient for testing and development), EmbeddingClient (defaults to the local sentence-transformers all-MiniLM-L6-v2). After the frontend starts, it opens http://localhost:5173,后端需运行在 port 8000 by default to match dashboard/.env's VITE_API_BASE_URL and CORS configuration.
[Applicable scenarios] LLM agent developers who need to remember user preferences and facts across sessions over the long term and want auditable, verifiable memory effectiveness; research or engineering scenarios that need to evaluate memory storage backends among Postgres, Qdrant, and Neo4j; debugging scenarios that need to observe retrieval ranking and forgetting processes.
[Limitations] Not yet published to PyPI, and Docker support is not yet provided; reflective consolidation is triggered on demand, with no background scheduling or task queue; the project is positioned as a memory-augmented chat loop, not an agent that executes multi-tool tasks, so its "procedural memory" only tracks decisions about retrieval weights, not multi-step task workflows; the Neo4j backend, because vector indexes lack native pre-filtering, must over-fetch candidates and then filter in Cypher, and after writes must poll the vector index to confirm readability, resulting in higher latency. The original ideas of "memory compression" and "dreaming" do not exist as independent features.