Skip to main content

Fast, embedded vector + graph memory for AI agents

Project description

CortexaDB: SQLite for AI Agents

Build License: MIT/Apache-2.0 Status: Beta

CortexaDB is a simple, fast, and hard-durable embedded database designed specifically for AI agent memory. It provides a single-file-like experience (no server required) but with native support for vectors, graphs, and temporal search.

Think of it as SQLite, but with semantic and relational intelligence for your agents.


Quickstart

Python (Recommended)

CortexaDB is designed to be extremely easy to use from Python via high-performance Rust bindings.

from cortexadb import CortexaDB

# Open database (auto-creates if missing)
# You can provide a manual dimension or an Embedder instance
db = CortexaDB.open("agent.mem", dimension=1536)

# Store a memory
mid = db.remember("The user prefers dark mode for the dashboard.", metadata={"type": "preference"})

# Ask a question (Semantic Search)
hits = db.ask("Does the user have UI preferences?")
for hit in hits:
    print(f"ID: {hit.id}, Score: {hit.score}")

# Connect memories (Graph Relationships)
db.connect(mid1, mid2, "relates_to")

Installation

Python

CortexaDB is available on PyPI and can be installed via pip:

# Recommended: Install from PyPI
pip install cortexadb

# From GitHub (Install latest release)
pip install "cortexadb @ git+https://github.com/anaslimem/CortexaDB.git#subdirectory=crates/cortexadb-py"

Rust

Add CortexaDB to your Cargo.toml:

[dependencies]
cortexadb-core = { git = "https://github.com/anaslimem/CortexaDB.git" }

Key Features

  • Hybrid Retrieval: Combine vector similarity (semantic), graph relations (structural), and recency (temporal) in a single query.
  • Hard Durability: Write-Ahead Log (WAL) and Segmented logs ensure your agent never forgets, even after a crash.
  • Multi-Agent Namespaces: Isolate memories between different agents or workspaces within a single database file.
  • Deterministic Replay: Record operations to a log file and replay them exactly to debug agent behavior or migrate data.
  • Automatic Capacity Management: Set max_entries or max_bytes and let CortexaDB handle LRU/Importance-based eviction automatically.
  • Crash-Safe Compaction: Background maintenance that keeps your storage lean without risking data loss.

API Guide

Core Operations

Method Description
CortexaDB.open(path, ...) Opens or creates a database at the specified path.
.remember(text, ...) Stores a new memory. Auto-embeds if an embedder is configured.
.ask(query, ...) Performs a hybrid search across vectors, graphs, and time.
.connect(id1, id2, rel) Creates a directed edge between two memory entries.
.namespace(name) Returns a scoped view of the database for a specific agent/context.
.delete_memory(id) Permanently removes a memory and updates all indexes.
.compact() Reclaims space by removing deleted entries from disk.
.checkpoint() Truncates the WAL and snapshots the current state for fast startup.

Configuration Options

When calling CortexaDB.open(), you can tune the behavior:

  • sync: "strict" (safest), "async" (fastest), or "batch" (balanced).
  • max_entries: Limits the total number of memories (triggers auto-eviction).
  • record: Path to a log file for capturing the entire session for replay.

Technical Essentials: How it's built

Click to see the Rust Architecture

Why Rust?

CortexaDB is written in Rust to provide memory safety without a garbage collector, ensuring predictable performance (sub-100ms startup) and low resource overhead—critical for "embedded" use cases where the DB runs inside your agent's process.

The Storage Engine

CortexaDB follows a Log-Structured design:

  1. WAL (Write-Ahead Log): Every command is first appended to a durable log with CRC32 checksums.
  2. Segment Storage: Large memory payloads are stored in append-only segments.
  3. Deterministic State Machine: On startup, the database replays the log into an in-memory state machine. This ensures 100% consistency between the disk and your queries.

Hybrid Query Engine

Unlike standard vector DBs, CortexaDB doesn't just look at distance. Our query planner can:

  • Vector: Find semantic matches using Cosine Similarity.
  • Graph: Discover related concepts by traversing edges created with .connect().
  • Temporal: Boost or filter results based on when they were "remembered".

Versioned Serialization

We use a custom versioned serialization layer (with a "magic-byte" header). This allows us to update the CortexaDB engine without breaking your existing database files—it knows how to read "legacy" data while writing new records in the latest format.


License & Status

CortexaDB is currently in Beta (v0.1). It is released under the MIT and Apache-2.0 licenses.
We are actively refining the API and welcome feedback!


CortexaDB — Because agents shouldn't have to choose between speed and a soul (memory).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cortexadb-0.1.0-cp314-cp314-win_amd64.whl (429.9 kB view details)

Uploaded CPython 3.14Windows x86-64

cortexadb-0.1.0-cp313-cp313-win_amd64.whl (430.2 kB view details)

Uploaded CPython 3.13Windows x86-64

cortexadb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (545.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cortexadb-0.1.0-cp312-cp312-win_amd64.whl (429.6 kB view details)

Uploaded CPython 3.12Windows x86-64

cortexadb-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (611.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

cortexadb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (545.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cortexadb-0.1.0-cp311-cp311-win_amd64.whl (430.5 kB view details)

Uploaded CPython 3.11Windows x86-64

cortexadb-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (611.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

cortexadb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (547.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cortexadb-0.1.0-cp310-cp310-win_amd64.whl (432.6 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file cortexadb-0.1.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 429.9 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cortexadb-0.1.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3af41c44a0f5e0ffe61aa37c31f7cf5e08aecd38a094bf227392a9d33ab33765
MD5 c7a874ab02e50916cd53407b6975aece
BLAKE2b-256 e7ecfcc1e45bef7a22b3c7e9db62313fda5d24c68f57861035bc6a5d2a720094

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp314-cp314-win_amd64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 430.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cortexadb-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8b0a47e1bfed9d8f9ecb6005c985e3171c7ae715ac26cddf6f3b2b5a6f4ce382
MD5 d20b0310cef4a290b9134747a529e899
BLAKE2b-256 3997042bdf5d03086b4e937ce8c750159805b6f4b908194ce039e67c7689f76c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a0dcee90351760a51d6d1d638e988cb775bdee9817eac6b2694855c7dcf904e
MD5 42dbfdd69acaae9bd4c50210b27bb4da
BLAKE2b-256 888103739592fbd4d7dd28e7325b074ae31edf2800b94ebedfa2f718d30fc1ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 429.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cortexadb-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d30d9aff03cdc77b95061d2e1141470ecae11f520a415b2985a3e90e0b61eb42
MD5 5df875b6309991f9754b78b88499b821
BLAKE2b-256 6bd5dd519d537cb1cc5f371df61f46c6a70c12208e1eb10da57b3b5e7ca4c6b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 835bdf5f531a104ead5e457fce8a4314e5365ebdd0484889315c787a62651467
MD5 efdf4c325b55268fcda96b59d55e9a5f
BLAKE2b-256 9b78855e2c4a101d26b2cd472a78b23e21bee8e5baf6ea0049340b4de9109732

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0399decc5c57e722df51739f9f017e84e0919131a518cdd3a2c71da4660aa76
MD5 24e0100724aa11003de22f5743bb048f
BLAKE2b-256 8135a3273e1ff68cddbc27ab48ae7651e784fb56e46e36f8019b515b925ab050

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 430.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cortexadb-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 867169161a323cca628d1a607d29923861b21742e6d2ec92a196f3cb89f93a5f
MD5 d4f26c4be6f02882ed98cbc184cbc245
BLAKE2b-256 81e1299e529fc63a5cf816e2a1183d85087649f48c6156513807a58c39790d0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a07f61ed474761402d420c210a88dd308707b833c5207d55a3e97a9439b481a9
MD5 079203bd7dadbae600bedc4a10c31cc9
BLAKE2b-256 090891ea04cbd351a33f11729c8a34c214fd4398dd23f798b708a7bd60189836

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fde92521d061e9c817370751b7b7e4ecd6c3c9107e1e17e61a9ef363226f8d0a
MD5 f683ffc3c7c1c5e135ebb2e5f47a36c0
BLAKE2b-256 0a292404ad1f1f5b9f0f9219cadc5ad3a8fdcb910a9fc5e1ba7071682ea03de9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cortexadb-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 432.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cortexadb-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 99ec7e18f60e46e86d28e5762392fd7173e26f8ee752d1e0b4f418f38b0f58e4
MD5 0bc55cd9df256c505e4fbc5870d8287f
BLAKE2b-256 d83c270d8d2a309bf40ee28cfd185a037328c7fa3a9f01d56c610b57d2588722

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: release.yml on anaslimem/CortexaDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page