MemoryStore is the storage backend for CognitiveMemory. Definable provides eight built-in implementations, from ephemeral in-memory stores for testing to production-grade vector databases.
Available Backends
| Backend | Import | Dependency | Best For |
|---|---|---|---|
InMemoryStore | definable.memory | None | Testing, ephemeral sessions |
SQLiteMemoryStore | definable.memory | aiosqlite (core) | Local dev, single-process |
PostgresMemoryStore | definable.memory | asyncpg | Production, multi-process |
RedisMemoryStore | definable.memory | redis | High-throughput caching |
ChromaMemoryStore | definable.memory | chromadb | Vector-native storage |
QdrantMemoryStore | definable.memory | qdrant-client | Vector-native at scale |
PineconeMemoryStore | definable.memory | pinecone | Managed vector DB |
MongoMemoryStore | definable.memory | motor | Document-oriented |
Installation
Core stores (InMemory, SQLite) require no extra dependencies. For others, install the matching extra:Backend Examples
SQLiteMemoryStore
The default choice for local development. Usesaiosqlite (included as a core dependency).
Path to the SQLite database file. Created automatically if it doesn’t exist.
PostgresMemoryStore
Production-ready backend with connection pooling. Requires a running PostgreSQL instance.PostgreSQL connection URL.
Connection pool size.
Prefix for database table names.
ChromaMemoryStore
Vector-native storage using ChromaDB. Supports both in-memory and persistent modes.Directory for persistent storage. When
None, uses in-memory mode.Prefix for ChromaDB collection names.
QdrantMemoryStore
High-performance vector database for production workloads.Qdrant server URL.
Qdrant server port.
API key for Qdrant Cloud.
Prefix for collection names.
Dimension of embedding vectors.
PineconeMemoryStore
Managed vector database — no infrastructure to maintain.Pinecone API key.
Name of the Pinecone index.
Pinecone environment (e.g.,
us-east-1-aws).Dimension of embedding vectors.
InMemoryStore
Ephemeral store for testing. Data is lost when the process exits.MemoryStore Protocol
All backends implement theMemoryStore protocol. You can create custom stores by implementing these methods:
Data Types
Episode
A single conversation turn stored in memory.| Field | Type | Default | Description |
|---|---|---|---|
id | str | — | Unique identifier |
user_id | str | None | — | Owner user ID |
session_id | str | — | Conversation session |
role | str | — | "user" or "assistant" |
content | str | — | Message text |
embedding | list[float] | None | None | Vector embedding |
topics | list[str] | [] | Extracted topics |
sentiment | float | 0.0 | Sentiment score (-1.0 to 1.0) |
token_count | int | 0 | Token count of content |
compression_stage | int | 0 | 0=raw, 1=summary, 2=facts, 3=atoms |
created_at | float | 0.0 | Unix timestamp |
last_accessed_at | float | 0.0 | Last retrieval timestamp |
access_count | int | 0 | Number of times retrieved |
KnowledgeAtom
An extracted fact stored as a subject-predicate-object triple.| Field | Type | Default | Description |
|---|---|---|---|
id | str | — | Unique identifier |
user_id | str | None | — | Owner user ID |
subject | str | — | Entity (e.g., “Alice”) |
predicate | str | — | Relation (e.g., “works-at”) |
object | str | — | Value (e.g., “Acme Corp”) |
content | str | — | Full text representation |
embedding | list[float] | None | None | Vector embedding |
confidence | float | 1.0 | Confidence score (0.0–1.0) |
reinforcement_count | int | 0 | Times this fact was reinforced |
topics | list[str] | [] | Related topics |
source_episode_ids | list[str] | [] | Episodes this fact was extracted from |
Procedure
A learned behavioral pattern.| Field | Type | Default | Description |
|---|---|---|---|
id | str | — | Unique identifier |
user_id | str | None | — | Owner user ID |
trigger | str | — | Condition that activates this procedure |
action | str | — | Action to take |
confidence | float | 0.5 | Confidence score |
observation_count | int | 1 | Times observed |