pgmem
Examples

Examples

Runnable example apps that show pgmem end to end.

Working code you can run and read. Each example lives in the repo and points at your own Postgres (with the schema applied) — set DB_URL and go.

Session walk-through — every tier, no keys

examples/voice_session_demo.py

Walks one "voice call" through all five tiers, runs the promotion worker, and prints claim-derived projections being refreshed — using deterministic, self-contained providers (a hashing embedder + a rule-based LLM), so it runs with no API keys and no model downloads.

DB_URL=postgresql://user:pass@host:5432/db uv run python examples/voice_session_demo.py

Swap the stand-in providers for real ones (OpenAILLM / an embedder) and the pgmem code is identical. Best starting point for seeing the whole model move.

Deciding what to remember — the ClaimPolicy seam

examples/memory_policy_litmus.py

The canonical reference for the events-vs-state rule as your code: a ClaimPolicy that routes current state to live context and uses the default authority/evidence policy for durable event claims.

DB_URL=postgresql://user:pass@host:5432/db uv run python examples/memory_policy_litmus.py

Pairs with the guide Decide what to remember.

Full voice agent — LiveKit + Ollama

examples/livekit-voice-agent/

A complete realtime voice assistant (an aged-care agent) built on LiveKit with a local Ollama model and pgmem for memory — a monorepo with app, infra, and observability wiring. The reference for the stateless-worker pattern in a real deployment.

See its README.md and ARCHITECTURE.md in the repo to run it, and the guide LiveKit / voice agents for how pgmem slots in.

On this page