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_ai_memory import Cortex

# Open or create a memory database
cx = Cortex("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

Hosted Bot projections

ControlledStore provides an isolated, durable projection backend without ingest-time inference or consolidation. See the controlled API contract for snapshot/replay reconciliation, immutable scopes, typed dictionaries, error codes, query bounds and a complete example. The caller retains PostgreSQL authority and must revalidate every hit before use. Cortex remains the personal-agent interface.

The wheel uses plaintext SQLite. Controlled roots and all artifacts are owner-only; this does not replace your host's approved storage encryption or retention policy. Native controlled operations release the GIL, but the host still needs bounded worker capacity and a PostgreSQL fallback. No public HTTP service or cloud sync is enabled.

Metadata

Release files for cortex-ai-memory 2.5.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 cortex-ai-memory 2.5.0
File Size Uploaded Provenance
cortex_ai_memory-2.5.0.tar.gz 283.3 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for cortex-ai-memory 2.5.0
File Interpreter ABI Platform
cortex_ai_memory-2.5.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
cortex_ai_memory-2.5.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.5.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: 6.2 MB

Release files / cortex_ai_memory-2.5.0.tar.gz

Download URL cortex_ai_memory-2.5.0.tar.gz
Size 283.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8512d50d579cc885ffe795611176ee9370f22f26f1134a957eb979bedce83dcb
BLAKE2b-256 checksum
How to use checksums
633ea2a67889c446342b17a7ba40918686a25564e303efb51aaba339cf0c18f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 22, 2026.

Transparency log

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

Download URL cortex_ai_memory-2.5.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
753564e663d52e055fcd579fc0aff4efb3eb2951a585bb1fcb70bfe5630fb597
BLAKE2b-256 checksum
How to use checksums
2cfbf9a542e80cfc3437418fcbf8f0c89043ab188e65696e4f01e9a5b5663cfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 22, 2026.

Transparency log

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

Download URL cortex_ai_memory-2.5.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 1.8 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8301327ae062a4bb2cfc01028dc38c1f85d47feb730d865c9c52757eca3b0366
BLAKE2b-256 checksum
How to use checksums
11c7f459e8ad3ba4fd2f78f26b17adeabfc11135fd14d1fb622dbd1ea767b565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 22, 2026.

Transparency log

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

Download URL cortex_ai_memory-2.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
00c157bdccc38c00dafc8988299a96146a1b4c9247ea9a47b7ec825dc092eece
BLAKE2b-256 checksum
How to use checksums
fac4be49e5c672cfd314c61383ae868684f36c39440c142dbbfb4faf8b052995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 22, 2026.

Transparency log

Security for cortex-ai-memory 2.5.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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for cortex_ai_memory-2.5.0.tar.gz

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 22, 2026.

Transparency log

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