Typed block tree + knowledge graph memory SDK for AI agents
pip install memblock==0.14.0 Copy PIP instructions
Typed blocks · Knowledge graph · Hybrid search · Encryption · Decay engine — all local, all yours.
AI agents forget everything between sessions. Vector databases give you search but no structure. Cloud memory APIs lock you in and store your users' data on someone else's servers. MemBlock is the alternative: typed memory blocks, a built-in knowledge graph, hybrid search, encryption, and intelligent decay — all running on your infrastructure with pip install and one line of Python. No Docker, no Neo4j, no subscriptions. Your data never leaves your machine.
pip install memblock Quick Start from memblock import MemBlock, BlockType mem = MemBlock(storage="sqlite:///memory.db") # Store structured memories mem.store("User prefers Python", type=BlockType.PREFERENCE) mem.store("User works at Acme Corp", type=BlockType.FACT, confidence=0.95) # Query with hybrid search results = mem.query(text_search="programming", type=BlockType.PREFERENCE) # Build LLM-ready context context = mem.build_context(query="user preferences", token_budget=4000) # Knowledge graph mem.link(results[0].id, other.id, relation="related_to") # Tamper detection mem.verify() Pluggable classifier (typed decisions on the write path) Let a local System One model decide type, source, calibrated confidence, encryption level and decay rate for every memory, and gate conflict resolution before the LLM resolver runs:
from memblock import MemBlock from jevblock import LayaMLXRouterBackend # or AnthropicBackend / OpenAIBackend / StubBackend from jevblock.memblock_bridge import MemoryClassifier mem = MemBlock(storage="sqlite:///memory.db", classifier=MemoryClassifier(LayaMLXRouterBackend()), extract_provider="anthropic", # optional: LLM escalation for low-confidence cases conflict_resolution=True) block = mem.store("User prefers Python over JavaScript") # type=PREFERENCE, confidence calibrated block.metadata.custom_metadata["_classifier"] # full audit of the decision Explicit store() arguments always win over the classifier. See memblock/classifier.py for the contract and CHANGELOG.md for details.
from memblock import AsyncMemBlock, BlockType # Native asyncpg path — non-blocking storage I/O mem = AsyncMemBlock(storage="postgresql+asyncpg://user@host/db") await mem.store("User prefers Python", type=BlockType.PREFERENCE) results = await mem.query(text_search="programming", limit=10) # Multi-tenant isolation: each tenant gets its own Postgres schema. mem = AsyncMemBlock( storage="postgresql+asyncpg://user@host/db", schema="tenant_xyz", # bootstraps + isolates on first use ) AsyncMemBlock accepts plain postgresql:// URLs too — those use the legacy thread-pool wrapper. Use postgresql+asyncpg:// to opt into the native async backend.
pip install "memblock[postgres]" # PostgreSQL backend (sync + async + pgvector) pip install "memblock[embeddings]" # Local vector embeddings (FastEmbed) pip install "memblock[llm]" # LLM extraction (OpenAI, Anthropic, Gemini) pip install "memblock[reranker-cohere]" # Cohere reranker pip install "memblock[reranker-cross-encoder]" # HuggingFace reranker pip install "memblock[all-cloud]" # Everything without onnxruntime (Python 3.13+) pip install "memblock[all]" # Everything including local embeddings Documentation Full docs, API reference, and examples: memblock.xyz
Contributions are welcome! MemBlock is open source and community-driven.
The main branch is protected, so all changes go through pull requests and review.
postgres pool pgvector tokens llm embeddings fast embeddings-openai embeddings-gemini llm-gemini reranker-cohere reranker-cross-encoder all-cloud all dev
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




