cortex-memory
Persistent memory engine for AI agents. Local-first, sub-millisecond, zero cloud.
Native Python binding for Cortex — a Rust memory engine with 4-tier memory, Bayesian beliefs, people graph, and HNSW vector search.
Install
pip install cortex-ai-memory
Quick Start
from cortex_python import PyCortex
# Open or create a memory database
cx = PyCortex("memory.db")
# Ingest memories
cx.ingest("Met Alice at the Q3 planning meeting", "slack", user_id="alice_123")
cx.ingest("User prefers dark mode", "cli")
# Retrieve relevant memories
results = cx.retrieve("What do I know about Alice?", limit=5)
for memory_id, score, text in results:
print(f"[{score:.2f}] {text}")
# Generate LLM-ready context (token-budgeted)
context = cx.get_context(2000, channel="slack")
# Structured knowledge
cx.add_fact("Alice", "works_at", "Acme Corp", 0.95, "slack")
cx.add_preference("timezone", "Asia/Shanghai", 0.9)
# Bayesian beliefs
cx.observe_belief("user_likes_python", True, 0.8)
beliefs = cx.get_beliefs(0.5)
# People graph
cx.add_person("Alice", "slack", "alice_123")
# Consolidation (run periodically)
scanned, promoted, swept, patterns = cx.run_consolidation()
With Embeddings
For semantic search, pass embeddings from any provider:
import numpy as np
# Use any embedding model (OpenAI, ollama, sentence-transformers, etc.)
def embed(text):
# your embedding function here
...
cx.ingest("I live in Shanghai", "cli", embedding=embed("I live in Shanghai"))
results = cx.retrieve("where do I live?", 5, embedding=embed("where do I live?"))
Features
- 4-tier memory: Working, Episodic, Semantic, Procedural
- HNSW vector search: Sub-millisecond at 100K+ memories
- Bayesian beliefs: Self-correcting with evidence
- People graph: Cross-channel identity resolution
- Conversation compression: Automatic session summarization
- Contradiction detection: Catches conflicting facts
- Chinese + English: Native bilingual NLP
- Zero cloud: 100% local, your data stays on your device
- 3.8MB binary: Pure Rust, zero runtime dependencies
License
MIT
Metadata
Release files for cortex-ai-memory 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cortex_ai_memory-2.3.0.tar.gz | 217.5 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cortex_ai_memory-2.3.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| cortex_ai_memory-2.3.0-cp312-cp312-macosx_10_12_x86_64.whl | CPython 3.12 | CPython 3.12 | macOS 10.12+ x86-64 | Details |
| cortex_ai_memory-2.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 5.0 MB
Release files / cortex_ai_memory-2.3.0.tar.gz
| Download URL | cortex_ai_memory-2.3.0.tar.gz |
|---|---|
| Size | 217.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4901c505f07b285c3d208c1a8f54fe9973feedbbf0be9da50fdaa4f62a40864a
|
|
BLAKE2b-256 checksum How to use checksums |
001d4062898ab17466c5569b0f10f8c01b4bf80ac634e1e82be8abcda55a62a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / cortex_ai_memory-2.3.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | cortex_ai_memory-2.3.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
33e72caed789cab35ecef47347bf3d732f0b46ea81170fd545bc5fc8cd7fb199
|
|
BLAKE2b-256 checksum How to use checksums |
bda708ccd1d0ee3a1ae7504ec7523e9c1bc44bbf397de564af82e233ced7307f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / cortex_ai_memory-2.3.0-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | cortex_ai_memory-2.3.0-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
19f811fdaa42a2f9bcc60ff9f987bd6ffe6865cef111830c14052909921f30af
|
|
BLAKE2b-256 checksum How to use checksums |
cbc5441991382f7135725d57791427e1280a5813e621886d20277a01e48d15fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / cortex_ai_memory-2.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | cortex_ai_memory-2.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
eb837a85f12ffeee8f6e270417076d5844619263793ea4a36ca92b63a5ec6aa8
|
|
BLAKE2b-256 checksum How to use checksums |
db0c16801fa8a4be0f00fc41c61488eb10e46bc38e2f45daabe5c250d9e029cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency log