pref0 vs LangMem

LangMem is LangChain's SDK for adding long-term memory to agents. pref0 is a hosted API for preference learning. Both help agents improve over time, but they differ in scope, output format, and ecosystem requirements.

pref0LangMem
What it storesStructured preferences with confidence scoresSemantic, episodic, and procedural memories
Output formatKey-value preferences with scoresRaw memory fragments and prompt updates
Confidence over timeYes — preferences compound across sessionsNo — memories are stored without scoring
FrameworkFramework-agnostic REST APIPython-only, LangGraph ecosystem
InfrastructureHosted API, no setupSelf-hosted, bring your own vector store
Best forLearning how users want things doneGeneral agent memory within LangGraph

Key differences

Structured preferences vs. raw memory

pref0 extracts structured key-value preferences with confidence scores — 'prefers TypeScript' at 0.85. LangMem stores raw memory fragments (semantic facts, episodic events, procedural rules) without structured preference output.

Framework independence

pref0 is a REST API that works with any language or framework. LangMem is a Python SDK designed for the LangGraph ecosystem. Switching frameworks means reimplementing your memory layer with LangMem, but pref0 preferences carry over.

Hosted vs. self-managed

pref0 is a hosted API — no vector databases, no embedding pipelines, no infrastructure. LangMem requires you to set up and manage your own storage backend (Postgres with pgvector, in-memory stores, etc.).

When to use each

Use pref0 when...

  • You want structured preferences with confidence scoring
  • You need a framework-agnostic solution (not just Python/LangGraph)
  • You prefer a hosted API with no infrastructure to manage
  • Corrections and explicit feedback are your primary signal
  • You want to get started in minutes, not days

Use LangMem when...

  • You're already building within the LangGraph ecosystem
  • You need general-purpose agent memory (facts, episodes, procedures)
  • You want agent-driven memory where the LLM decides what to store
  • You need prompt optimization based on learned behavior

Frequently asked questions

Can I use pref0 and LangMem together?

Yes. Use LangMem for general agent memory within your LangGraph pipeline. Use pref0 for structured preference learning. Inject pref0 preferences into the system prompt alongside LangMem's memory context.

Is LangMem free?

LangMem is open source, but you pay for your own infrastructure (vector database, LLM API calls, hosting). pref0 has a free tier of 100 requests/month with no infrastructure costs.

Does LangMem work outside of LangChain?

LangMem is designed for the LangGraph ecosystem. Using it outside LangChain requires significant workarounds. pref0 works with any framework via REST API.

Other comparisons

Not memory. Preference learning.

Your users are already teaching your agent what they want. pref0 makes sure the lesson sticks.