Skip to content

Adapters Overview

Cognitive Memory separates the memory engine (decay, scoring, associations) from the storage backend. You pick an adapter that matches your infrastructure, and the engine works identically regardless of what’s underneath.

All adapters implement the same abstract interface (MemoryAdapter in Python, MemoryAdapter in TypeScript), providing:

  • CRUD operations on memories
  • Vector similarity search
  • Tiered storage migration (hot/cold/stub)
  • Association link management
  • Consolidation helpers (find fading, mark superseded)
  • Batch operations and transactions
AdapterLanguagePersistenceVector searchBest for
InMemoryPython, TSNoBrute-force cosineTesting, prototyping
SQLitePythonFileBrute-force cosineLocal development
PostgresPython, TSYespgvectorProduction
RedisPythonOptionalRediSearchFast ephemeral storage
ConvexTypeScriptYesConvex vector searchServerless apps
JSONLTypeScriptFileBrute-force cosineDebugging, audit logs

Testing and prototyping: Use InMemoryAdapter. Zero config, instant startup, no dependencies. Data is lost when the process exits, which is fine for tests.

Local development: Use SQLiteAdapter (Python) or JsonlAdapter (TypeScript). Both persist to a local file. SQLite gives you SQL queries for debugging; JSONL gives you a human-readable append-only log.

Production single-tenant: Use PostgresAdapter with pgvector. Battle-tested, scalable, supports concurrent access. One Postgres instance can handle millions of memories with sub-100ms vector search via HNSW indexes.

Production multi-tenant (serverless): Use ConvexAdapter (TypeScript). Convex handles scaling, real-time sync, and multi-tenancy out of the box. No infrastructure to manage.

Ephemeral / cache layer: Use RedisAdapter. Sub-millisecond reads, optional persistence with RDB/AOF. Good for high-throughput scenarios where you can tolerate data loss.

PriorityRecommended adapter
Simplest setupInMemory
Local persistenceSQLite / JSONL
Production reliabilityPostgres
Lowest latencyRedis
Zero infra managementConvex
Audit trailJSONL
Largest scalePostgres with pgvector
from cognitive_memory import CognitiveMemory
from cognitive_memory.adapters.memory import InMemoryAdapter
mem = CognitiveMemory(adapter=InMemoryAdapter())

If none of the built-in adapters fit, you can write your own by implementing the MemoryAdapter abstract class. See Custom adapters for the full guide.