Skip to main content

๐Ÿง  MindCache

An open-source long-term memory engine for LLM agents.

BEAM-1M BEAM-10M MCP PyPI version License: MIT 4-Minute Blog YouTube Demo


Agents forget.

More history doesn't mean better memory.

As conversations grow, important information gets buried. An AI needs to know what to remember, what has changed, which decisions still matter, and what is relevant now.

Most systems treat this as a search problem.

MindCache treats it as a memory problem.

It turns conversations into organized, persistent memory and continuously updates that memory as the conversation evolves.


๐Ÿ‘‰ Read the 4-Minute Blog ย |ย  ๐ŸŽฅ Watch Demo Video ย |ย  โšก Quick Start ย |ย  ๐Ÿ“– Read the Engineering Journal


๐Ÿ“– Want the technical deep dive?

The short article explains the problem, architecture, and lessons behind MindCache in about four minutes.

For the full engineering story โ€” including implementation details, architectural decisions, experiments, failures, retrieval design, and evaluation โ€” see the MindCache Engineering Journal.


๐Ÿง  How MindCache Builds Memory

MindCache doesn't treat every message as equally important, and it doesn't leave memories as a flat collection.

It turns conversations into four kinds of memory:

  • User โ€” preferences, constraints, and habits.
  • Decision โ€” choices and their current state over time.
  • Episodic โ€” things that happened in previous conversations.
  • Knowledge โ€” useful facts and information learned along the way.

These memories are then placed into a living topic tree that organizes related information together. As new conversations arrive, MindCache can reorganize that structure, split growing topics, merge related ones, and build summaries of broader areas.

The result is not just a collection of stored memories. It is an evolving map of what the agent has learned over time.

Conversations
     โ”‚
     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        MindCache          โ”‚
โ”‚                           โ”‚
โ”‚  User                     โ”‚
โ”‚  Decision                 โ”‚
โ”‚  Episodic                 โ”‚
โ”‚  Knowledge                โ”‚
โ”‚                           โ”‚
โ”‚       โ”Œโ”€ Work             โ”‚
โ”‚       โ”œโ”€ Projects         โ”‚
โ”‚       โ”‚   โ”œโ”€ MindCache    โ”‚
โ”‚       โ”‚   โ””โ”€ ML Project   โ”‚
โ”‚       โ”œโ”€ Preferences      โ”‚
โ”‚       โ””โ”€ Personal         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฏ Memory changes. MindCache keeps up

People change their minds. Projects change direction. Old decisions become irrelevant.

For example:

โ€œWe use TensorFlow for model training.โ€

Later:

โ€œWe switched to PyTorch.โ€

A simple store can keep both statements without explicitly representing which decision replaced the other.

MindCache tracks the state of decisions over time:

Old decision
TensorFlow
    โ†“
SUPERSEDED

New decision
PyTorch
    โ†“
ACTIVE

MindCache keeps the old decision in the history, but knows that it is no longer the current choice. This lets MindCache distinguish what used to be true from what is true now, instead of treating every past statement as equally relevant.


๐Ÿ“š Memory needs context, not just facts

Remembering individual things is useful. But over time, an agent also needs to understand how those things fit together.

For example:

Machine Learning
โ”œโ”€โ”€ PyTorch
โ”œโ”€โ”€ NLP
โ”œโ”€โ”€ Computer Vision
โ””โ”€โ”€ Handwriting Project

MindCache builds summaries at different levels of this topic structure.

So instead of storing only:

โ€œBuilt a handwriting model.โ€

it can maintain a broader understanding of:

โ€œThe user has been working on machine learning, with a focus on PyTorch, NLP, and handwriting synthesis.โ€

As new memories arrive, these summaries are updated with the new information instead of rebuilding everything from scratch.

This gives the agent both the details and the bigger picture.


๐Ÿ’ก How It Works Together: An End-to-End Example

Consider how an agent's memory evolves across weeks of interaction:

User conversations over time

  Week 1: "I'm starting a new project and using TensorFlow for model training."
    โ”‚
  Week 4: "I'm running a few experiments with PyTorch."
    โ”‚
  Week 8: "I've switched completely to PyTorch for all model training."

                     โ”‚
                     โ–ผ
                 MindCache
                     โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                 โ”‚
    โ–ผ                                 โ–ผ
Decision Lifecycle              Living Topic Tree & Summary
TensorFlow โ†’ SUPERSEDED         Machine Learning
PyTorch    โ†’ ACTIVE             โ””โ”€โ”€ Frameworks
                                    โ””โ”€โ”€ PyTorch

                                Summary: "User's ML stack has transitioned
                                from TensorFlow to PyTorch."
                     โ”‚
                     โ–ผ
User query (Week 10): "What ML framework am I using?"
                     โ”‚
                     โ–ผ
Retrieved Context: PyTorch (ACTIVE)

By maintaining decision states, topic hierarchy, and incremental summaries, MindCache supplies the LLM with the current decision (PyTorch) while keeping the superseded choice (TensorFlow) in history.


๐Ÿ“น Demo

A 2-minute walkthrough covering installation, ingestion, automatic hierarchy generation, and hybrid retrieval.

MindCache Demo Video

๐ŸŽฅ Watch the MindCache Walkthrough & Demo on YouTube


๐Ÿš€ Quick Start (30 Seconds)

1. Install

export GEMINI_API_KEY="your-gemini-api-key"
pip install mindcache

2. Usage

from mindcache import MindCache

# Initialize client (SQLite-backed by default)
mc = MindCache(
    db_path="my_memory.db",
    provider="gemini",
    model_name="gemini-2.5-flash"
)

# 1. Ingest conversation turns (buffered into processing queue)
job_id = mc.add([
    {"role": "user", "content": "I prefer Python and FastAPI for backend development, and Postgres for DB."},
    {"role": "assistant", "content": "Got it! I will remember your preference for Python, FastAPI, and Postgres."}
], user_id="alice")

# 2. Process pending queue (extracts memories, updates tree and indices)
mc.process(user_id="alice")

# 3. Retrieve structured context for future prompts
context = mc.search("What is Alice's preferred database?", user_id="alice")
print(context)

โšก What Makes MindCache Different?

Problem Simple Memory Approach MindCache
Different kinds of information Treats memories similarly Separates User, Decision, Episodic, and Knowledge memory
Changing decisions Keeps old and new information together Tracks which decision replaced another
Growing information Leaves memories in a flat collection Builds a living topic structure
Big-picture questions Relies on individual memories Maintains incremental summaries across the topic hierarchy

Under the hood, MindCache combines this memory structure with hybrid search, decision-guided retrieval, and controlled context allocation.

Memory Pipeline

Conversations
      โ”‚
      โ–ผ
Important Information Extracted
      โ”‚
      โ–ผ
Four Kinds of Memory (User / Decision / Episodic / Knowledge)
      โ”‚
      โ–ผ
Living Topic Structure
      โ”‚
      โ–ผ
Changing Decisions Tracked
      โ”‚
      โ–ผ
Broader Summaries
      โ”‚
      โ–ผ
Relevant Context Assembled
      โ”‚
      โ–ผ
LLM Prompt

โš™๏ธ Architecture & Technical Retrieval

The MindCache pipeline operates in three distinct phases:

  • Phase 1 โ€” Ingestion Pipeline: Filters noise, maps memories to existing topic paths, and extracts structured facts.
  • Phase 2 โ€” Tree Lifecycle & Maintenance: Handles leaf node splitting, sibling merging, Leiden graph partitioning, and incremental summaries.
  • Phase 3 โ€” Online Multi-Stage Hybrid Retrieval Engine: Executes vector + BM25 hybrid search, RRF rank fusion, query classification, decision-anchor expansion, and memory-type budgeting in 1.08s average retrieval latency in our evaluation setup (reranking disabled).

๐Ÿ‘‰ View Complete Architecture Specification ย |ย  ๐Ÿ”„ Trace End-to-End Retrieval Flow ย |ย  ๐Ÿง  Core Architectural Ideas


๐Ÿ“Š Where MindCache Works Best

MindCache is not designed to outperform every memory system on every workload. Its architecture is particularly focused on long-running conversations where useful information is spread across sessions, decisions evolve over time, and answering a question requires understanding the bigger picture.

In our evaluation on the BEAM QA benchmark (300 questions across 15 multi-session conversations), MindCache showed its strongest relative performance in summarization, contradiction resolution, and multi-session reasoning, while Mem0 performed better on preference following and information extraction. Some categories, including temporal reasoning and knowledge update, were closely matched.

Workload Category MindCache Mem0
Summarization 0.75 0.46
Contradiction resolution 0.56 0.38
Multi-session reasoning 0.92 0.83
Preference following 0.79 0.84
Information extraction 0.40 0.45
Knowledge update 0.50 0.50
Temporal reasoning 0.875 0.875

๐Ÿ‘‰ View Full Benchmark & Evaluation Details ย |ย  ๐Ÿ”ฌ View Deep Competitive Analysis Matrix ย |ย  ๐Ÿ—๏ธ View Architecture & Evidence Matrix


๐Ÿ“ Project Structure

The project is organized into independent ingestion, storage, and retrieval modules.

mindcache/
โ”œโ”€โ”€ client.py                # Main SDK interface & MindCache client
โ”œโ”€โ”€ Database/                # Storage, tree reorg, embeddings & summaries
โ”‚   โ”œโ”€โ”€ db_manager.py        # Database operations (SQLite & pgvector)
โ”‚   โ”œโ”€โ”€ db_setup.py          # Table schema initialization
โ”‚   โ”œโ”€โ”€ decision_analyzer.py # Decision state tracking logic
โ”‚   โ”œโ”€โ”€ embedder.py          # Embedding generation & vector indexing
โ”‚   โ”œโ”€โ”€ nodes_summary.py     # Bottom-up delta summarization
โ”‚   โ””โ”€โ”€ reorganize_tree.py   # Tree splitting, merging & Leiden partitioning
โ”œโ”€โ”€ Memory_extract/          # Ingestion & extraction pipeline
โ”‚   โ”œโ”€โ”€ input_denoiser.py    # Conversation noise filtering
โ”‚   โ”œโ”€โ”€ memory_extractor.py  # Structured fact & memory extraction
โ”‚   โ”œโ”€โ”€ safe_ai.py           # Provider LLM client wrapper (Gemini/OpenAI/Anthropic)
โ”‚   โ””โ”€โ”€ schema.py            # Pydantic schemas for memory types
โ””โ”€โ”€ retrieval/               # Online hybrid retrieval engine
    โ”œโ”€โ”€ active_path.py       # Does retrieval & Query classification & context assembly 
    โ”œโ”€โ”€ hybrid_search.py     # Hybrid vector + BM25 + RRF ranking
    โ””โ”€โ”€ root_cache.py        # Caches the nodes, memories and bm25 indexing

โš™๏ธ Configuration & Database Setup

MindCache supports SQLite out-of-the-box and PostgreSQL (pgvector) for production workloads.

  • โš™๏ธ SQLite: Default local setup (mindcache.db).
  • ๐Ÿ˜ PostgreSQL: Set MINDCACHE_DB_URL="postgresql://..." or pass to MindCache(db_path=...).

๐Ÿ‘‰ View Full Configuration & Setup Guide


๐Ÿ“ก API Reference

  • add(messages, user_id): Buffer conversation turns into the ingestion queue in milliseconds.
  • process(user_id): Extract memories, update decision state, and refresh dynamic topic summaries.
  • search(query, user_id): Retrieve structured memory context and retrieval metadata for LLM prompt construction.
  • inspect(user_id, view): Inspect stored memory state (memories, tree, all).
  • forget(memory_id, user_id): Remove a specific memory entry by ID.
  • reset(user_id): Clear all stored memory data for a user.

๐Ÿ‘‰ View Complete API Reference


๐Ÿ”Œ MCP Server โ€” Connect MindCache to AI Clients

MindCache includes a built-in MCP server (mindcache-mcp) that exposes long-term memory tools to MCP-compatible AI clients such as Claude Desktop, Cursor, and Codex over stdio.

1. Install MCP Extension

pip install "mindcache[mcp]"

2. Launch CLI Server

mindcache-mcp --db-path my_memory.db --provider gemini --model-name gemini-2.5-flash

3. Exposed MCP Tools

MCP Tool Description
add_memory Buffer conversation turns into the ingestion queue.
process_memory Extract structured memories & update topic tree summaries.
search_memory Search and retrieve structured memory context, query classification, and retrieval metadata.
inspect_memories Inspect stored memory records (user, knowledge, episodic, decision).
inspect_tree View the live dynamic topic hierarchy tree.
forget_memory Remove a specific memory entry by ID.

4. Claude Desktop Setup

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mindcache": {
      "command": "mindcache-mcp",
      "args": ["--db-path", "my_memory.db"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key"
      }
    }
  }
}

๐Ÿ—บ๏ธ Roadmap

  • Hierarchical Topic Tree: Dynamic graph organization.
  • Decision Lifecycle: Evolving choice tracking (ACTIVE, SUPERSEDED, CONDITIONAL, REJECTED).
  • Incremental Delta Summaries: Bottom-up rollup summaries across the topic tree.
  • Hybrid Retrieval & Budgeting: Vector + BM25 RRF ranking with memory-type quotas.
  • BEAM QA Evaluation: Evaluated across 300 questions on 1M and 10M token context windows.
  • Model Context Protocol (MCP) Server: Native stdio MCP server (mindcache-mcp) with 6 core tools.
  • Developer Tooling & Integrations: Expanded agent framework adapters (LangChain / LlamaIndex / AutoGen).

Future Work

  • 3-way RRF ranking โ€” Evaluate 3-way RRF (Semantic + Lexical + Temporal ranking) for recency-sensitive queries and evolving state retrieval.
  • Selective stateful memories โ€” Explore state tracking for User and Knowledge memories that represent evolving information, while keeping ingestion cost bounded.
  • Utility-based retrieval โ€” Explore retrieval strategies that optimize for the expected utility of a memory for a query rather than semantic similarity alone.

๐Ÿค Contributing

We welcome contributions! Please open an issue or submit a pull request on GitHub to help advance structured long-term memory for AI agents.

๐Ÿ“„ License

MindCache is open-source software licensed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mindcache-1.0.0.tar.gz (120.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mindcache-1.0.0-py3-none-any.whl (108.9 kB view details)

Uploaded Python 3

File details

Details for the file mindcache-1.0.0.tar.gz.

File metadata

  • Download URL: mindcache-1.0.0.tar.gz
  • Upload date:
  • Size: 120.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for mindcache-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e58f2485131e4b18a95d82f8a6210f3067c97c736cbd13b37f61b35bda21bded
MD5 179282a01c9458472358e4d215184abc
BLAKE2b-256 315c6d14bad4ee01f2bcde7bf21306493db909e6e5f59da48ff6fc432624e480

See more details on using hashes here.

File details

Details for the file mindcache-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mindcache-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 108.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for mindcache-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a752f1f7c4e2d9130ceedf0857595e21284cdfee59b69613ca8d7cf8f4b4483
MD5 b8f3c048ff8f2018e0a961dde04e1f3a
BLAKE2b-256 77759c603f37dab16a16f1876fa48c42b5ee68fd120862c085cee5d1bb9d59bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page