Skip to main content

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.2.1

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

Source distribution (sdist)

Source distribution for cortex-ai-memory 2.2.1
File Size Uploaded
cortex_ai_memory-2.2.1.tar.gz 216.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cortex-ai-memory 2.2.1
File Interpreter ABI Platform
cortex_ai_memory-2.2.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
cortex_ai_memory-2.2.1-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
cortex_ai_memory-2.2.1-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.2.1.tar.gz

Download URL cortex_ai_memory-2.2.1.tar.gz
Size 216.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a9c340784c9dffa9ee9d201a4b572c66dab8d62600d5a446b7e9c93d73775c6c
BLAKE2b-256 checksum
How to use checksums
7f33ec3aaef1175156e2112408051a0b7e222b52df6d0126a9d06dc5fe15a349
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

Release files / cortex_ai_memory-2.2.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL cortex_ai_memory-2.2.1-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
2abc3a86becbc7d24e746567e4028b0a54fc8a968bd69ddf7fe71107cae2a5e2
BLAKE2b-256 checksum
How to use checksums
16ffd04519078167c5446d318019e5872278ae67bc861382d43e7291781aa96f
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

Release files / cortex_ai_memory-2.2.1-cp312-cp312-macosx_10_12_x86_64.whl

Download URL cortex_ai_memory-2.2.1-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
8f09d33de92dff51fa2fc4270646231205967ae94f359fc8e07ad71d0bc1b597
BLAKE2b-256 checksum
How to use checksums
7fe5ef4e7ab8a421990dadaa8ff97083befd3d7b4acb179222f4dbf99c3956a6
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

Release files / cortex_ai_memory-2.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cortex_ai_memory-2.2.1-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
86ae7f253aeb1e5812a9fbc7e4d5fd6e78698d5024637888db89293e5038a18e
BLAKE2b-256 checksum
How to use checksums
0bafb13ff34f0d793292ed652bb72b5eb00a84d7396c579061bf1f6e11a01586
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

Release history Release notifications | RSS feed

2.4.0

4 release files

2.3.0

4 release files

This release

2.2.1 This release

4 release files

2.2.0

3 release files

1.3.0

4 release files

1.0.0

3 release files

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