cel-memory-postgres
PostgreSQL + pgvector memory backend for AI agents. Implements
cel-memory's MemoryProvider trait with
hybrid vector + full-text retrieval.
Status: v0.1.0 starter — Phase 0–1: connect/migrate, write/get, hybrid
retrieve, sessions, stats. Summarization, aging, export, and bulk mutations
return NotImplemented until later phases (see BACKENDS.md).
Purpose
Use cel-memory-postgres when you need durable agent memory in a shared
PostgreSQL deployment — multi-tenant services, team backends, or production
hosts that already run Postgres. Swap it in wherever code holds
Arc<dyn MemoryProvider> today (e.g. beside cel-memory-sqlite).
Requirements
- PostgreSQL 14+ with the pgvector extension
- Embedding width 384 (matches
MockEmbedder/ bge-small)
Example
use Arc;
use ;
let provider = connect.await?;
// Use as cel_memory::MemoryProvider — same trait as BasicMemoryProvider.
Run the complete example (requires CEL_MEMORY_POSTGRES_URL):
CEL_MEMORY_POSTGRES_URL=postgres://postgres:postgres@localhost:5432/cel_memory \
Testing
Integration tests use the same URL:
What's included (Phase 0–1)
PostgresMemoryProvider::connect— pool + sqlx migrationswrite/get/write_batch- Hybrid
retrieve— pgvector cosine distance +tsvectorFTS, fused with RRF - Session lifecycle —
open_session,close_session,rename_session,get_session,list_sessions stats
Roadmap
| Phase | Methods |
|---|---|
| 2 | pin, delete, purge_all, run_aging_sweep, export, … |
| 3 | summarize_session, rollup_day, rollup_rule_week (via injected Summarizer) |
| 4 | re_embed_all, HNSW/IVFFlat indexes |
License
Apache-2.0