Skip to main content

MemBlock

Structured memory SDK for AI agents.

Typed blocks · Knowledge graph · Hybrid search · Encryption · Decay engine — all local, all yours.

memblock.xyz

PyPI version License: MIT Python versions


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.

Install

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.

Async (asyncio)

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.

Optional Extras

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

Contributing

Contributions are welcome! MemBlock is open source and community-driven.

  • Found a bug or have a feature idea? Open an issue.
  • Want to contribute code? Fork the repo, create a branch, and open a pull request.
  • Please make sure tests pass and follow the existing code style.

The main branch is protected, so all changes go through pull requests and review.

License

Released under the MIT License. Copyright (c) 2025-2026 iexcalibur.

Metadata

Release files for memblock 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memblock 0.14.0
File Size Uploaded Provenance Actions
memblock-0.14.0.tar.gz 230.5 kB Without provenance Details for memblock-0.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memblock 0.14.0
File Interpreter ABI Platform Actions
memblock-0.14.0-py3-none-any.whl Python 3 none any Details for memblock-0.14.0-py3-none-any.whl

Total release size: 393.5 kB

Release files / memblock-0.14.0.tar.gz

Download URL memblock-0.14.0.tar.gz
Size 230.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fb4ff47ee760ab2b2c8af4997c3805c4750e98f67975bc4662f0c0548b665478
BLAKE2b-256 checksum
How to use checksums
0d58ef2352b2f6e4207dd940baad6430bcf75213654bfe104b7f2166097b1c69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / memblock-0.14.0-py3-none-any.whl

Download URL memblock-0.14.0-py3-none-any.whl
Size 163.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c9cabd502e8a85e8a66b16cfb73b00ba1b22db80448140aff64b7f2656604e9
BLAKE2b-256 checksum
How to use checksums
c3e18438b03826652091a2f584a13d2f297edea7d80538f3a96a24957f7edc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for memblock 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page