MemMini is a Python library for layered memory in AI agents. It stores full memory records in L2, generates compact summaries in L1, and keeps short routing hints in L0 so an agent can load only the context it needs.
The package is framework-neutral. It can be used directly through MemoryCore
or connected to agent frameworks through adapters.
- L0/L1/L2 layered memory model
- File, vector, and hybrid storage backends
- Namespace isolation for multiple users or agents
- TTL-based expiration and cleanup
- Positive and negative keyword filters
- Async wrapper
mini://resolver for layer and search references- LangChain, AutoGen, and OpenClaw adapters
- Atomic file writes for local JSON and Markdown storage
MemMini does not bundle or require a model provider. The default layer
generation path is rule-based. Projects that want model-generated summaries can
inject their own provider through the LayerGenerator interface.
pip install memminiOptional vector storage dependencies:
pip install "memmini[vector]"Optional framework adapters:
pip install "memmini[langchain]"
pip install "memmini[autogen]"
pip install "memmini[openclaw]"from memmini import open_memory
memory = open_memory(
"./memory",
auto_layer_update=False,
)
memory.add(
"Project started: MiniPM-v2 uses React and Node.js.",
metadata={"category": "project", "tags": ["minipm"]},
)
memory.update_layers()
print(memory.retrieve(layer="L0"))
for item in memory.search("MiniPM", limit=3):
print(item["content"])For custom storage backends, instantiate MemoryCore directly:
from memmini import MemoryCore
from memmini.storage.file import FileStorage
memory = MemoryCore(storage=FileStorage(base_path="./memory"))| Backend | Package | Use case |
|---|---|---|
FileStorage |
memmini |
Local JSON and Markdown files |
VectorStorage |
memmini[vector] |
ChromaDB-backed similarity search |
HybridStorage |
memmini[vector] |
File persistence with vector search |
| Layer | Purpose | Typical use |
|---|---|---|
| L0 | Short routing hints | Decide whether deeper context is needed |
| L1 | Compact summaries | Load relevant context for the current task |
| L2 | Original records | Preserve full source memory |
python examples/basic_memory.py
python examples/smart_search.py
python examples/vector_storage.pyexamples/vector_storage.py requires pip install "memmini[vector]".
from memmini import MemoryCore
from memmini.adapters import LangChainAdapter
from memmini.storage.file import FileStorage
core = MemoryCore(storage=FileStorage(base_path="./memory"))
adapter = LangChainAdapter(core)
history = adapter.load_memory_variables({})["history"]MemMini is released under the MIT License.