Skip to main content

Fast, embedded vector + graph memory for AI agents

Project description

CortexaDB: SQLite for AI Agents

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.1-cp314-cp314-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.14Windows x86-64

cortexadb-0.1.1-cp313-cp313-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13Windows x86-64

cortexadb-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cortexadb-0.1.1-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

cortexadb-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

cortexadb-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cortexadb-0.1.1-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

cortexadb-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

cortexadb-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cortexadb-0.1.1-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

File details

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

File metadata

  • Download URL: cortexadb-0.1.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • 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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 95e798107f766ff00b6051bd064fa6fb66032843f00edbe86f28a393c3471337
MD5 e0b8cdbbbb30bf3c16372ccaed65b42f
BLAKE2b-256 0064214bbf1f66fb895c988ea56567c3aa9640cafbf9422ecc9b7bd63c82c0bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e7d1be9ee83914a6c717f9b4461c4c7b94d20e87211a95315d0a173448708999
MD5 563834fe8ea75b46c484a17946e9b303
BLAKE2b-256 ceac108ff7929584bad89c4a626a8de09d7ef0395eb1d70a1c4445169518345d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 241c208578207720dcc1a472dd7b88366260f4e72f85461807ec145680c8597e
MD5 dbedb4ddc614cb73277da2fe42ae9f01
BLAKE2b-256 260bd655446ac18d084df6fdc6957c32fad7f9671af3fe1c4e9936a92656af8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d02ec199e2fb4939e631bd273defdf6e563aac4c70a3fb3bd3bd98e9c05997b3
MD5 40941debef2dde9f4909e246b495d911
BLAKE2b-256 225c40cc5bc2f5e1eaa0e970da5251c82eda0afeba1082472e1908112244fbc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f62d1975838edd4cf29a0f4a0194bba9a67d0ba9288b04d6256da337e564478c
MD5 40ba229385717f01c5c2d7b13ce0439f
BLAKE2b-256 8744ac14c667eace12566c06cf9a1505bab2fc3488b203dcc43f395d19dacac8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 521c3b72dddba67e8db49d0b0fec7083ca8047375d100ab5c178c1c49656d6fd
MD5 ab0ec51a3ea42e741d12f8fba935c40d
BLAKE2b-256 a7f65fc80780b86a9deeb6d364613f73f7ab04d7d1ebcb4ab912f149629ffa27

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1dd16944361e7fdec489e301e0719886e5ba41ef67186535b91ed1b88aa41436
MD5 6c8c3854ce3862be0f8ff9e1c9b4300b
BLAKE2b-256 664e1d164bfa80cecfe6ba9df4265de33e07535b25c81a2476779b061f498868

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7cec67442c339c9a9b3f4804ec088010cf6761ba92dd5356da45b9434f99dc65
MD5 3cbc03b463027ca2c25c23106ff175fc
BLAKE2b-256 e84ce14090649e9183993ded4edc360639d16d2236f740e8f528f643bc7aa3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cortexadb-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2837990c8b20593868892e5a893e5997749ca85544ba3633816a4b0c160eebb5
MD5 db43dfb1963866dcba92622fe7987d2f
BLAKE2b-256 0232d73d860ecb0d319f83b68f41cf07299040161ca022361fa38e9c5fcb98ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cortexadb-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2ea81923966c1e708968d24644e41cd8535d090bd55ecb30f8401dd10c2ffade
MD5 f53cdf4908e253d0ba670d316deb21be
BLAKE2b-256 786ee46f4d1c05e3058c02600783e3dfc9b3760097c2e3c65f8be637647b9495

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortexadb-0.1.1-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