Skip to main content
You need PostgreSQL 14+ with pgvector 0.8+, an OpenAI key, and LiveKit Agents 1.6 or 1.7.
1

Install

2

Start a database

Any PostgreSQL with pgvector works. For local development:
docker-compose.yml
3

Create the schema

Migrations are a deliberate step, not something that runs at startup. Twenty workers booting at once and racing DDL is a real failure: CREATE TABLE IF NOT EXISTS is not race-safe in PostgreSQL.
Migration 0002 creates an unprivileged voicemem_app role. Give it a password and point your agent at that, not at the admin role:
Row-level security only protects a role that can be constrained. Superusers and BYPASSRLS roles walk straight through the policies no matter what they say. voicemem-db status reports whether isolation is actually in force for the role you connected as.
4

Wire it into your agent

agent.py
Four lines do the work:
preemptive_generation is enabled by default. Injecting memory invalidates the speculative generation LiveKit already started, so leaving it on means paying for a discarded LLM call every single turn. Disable it as shown above.
5

Confirm it remembers

Run the agent, say something about yourself, hang up, then reconnect and ask about it.
First call
A later call, new session
Nothing was passed between the two sessions. The second one retrieved from Postgres.

What it costs

Measured, not estimated. 8 stored turns, 12 queries, text-embedding-3-small and gpt-4o-mini, against a same-host pgvector/pgvector:pg17 container. The single embedding call is almost all of it. Everything this package does costs about 19 ms. That is why retrieval prefetches on interim transcripts: on a hit, the round trip already happened while the caller was still speaking. Writing runs in the background at 3.8 s p50 and 2 LLM calls per ingested turn, dropping to 1 when the store is empty and conflict resolution is skipped.