Skip to main content
Memory lets agents remember past conversations, user preferences, and context across sessions.
A subset of Memory is now callable directly over MCP — see MCP Memory Tools.
Replaces the deprecated auto_save="name" kwarg — see Legacy Agent Parameters.

Grow memory autonomously

With self_improve="background" and memory=True, the same guarded post-turn review that autonomously grows skills can also autonomously persist durable facts and preferences via store_memory — off the hot path, with zero cost to reply latency and zero context pollution during the live turn. See Self-Improving Agents.
The user shares preferences in chat; the agent recalls them in later sessions via the configured memory backend.
Breaking change: backend no longer accepts redis/postgres/valkey.MemoryConfig(backend="redis"), backend="postgres", and backend="valkey" now raise a ValueError instead of silently substituting a local file store. Earlier releases accepted these values but stored data locally — so any code that “worked” was already not reaching Redis/Postgres.Valid backends: file, sqlite, chroma, mem0, mongodb, dakera, in_memory.Two supported ways to use Redis / Postgres:
  1. Recommended — pass a live db() store:
    db is imported from praisonaiagents.db, not from praisonaiagents — the top-level name is the module, not the factory.
  2. Advanced — register a custom adapter:
See Redis persistence for the full db(state_url=...) guide.

Quick Start

1

Level 1 — Bool (simplest)

Turn on memory with a single flag — the agent remembers across turns using the default file backend.
memory=True and memory="file" are truly zero-dependency — the agent skips importing the heavier Memory module on this path, so Agent(memory=True) starts as fast as an agent with no memory. Heavier backends (sqlite, chroma, mem0, mongodb, dakera, or learn=True) load their dependencies lazily and raise a friendly ImportError if the praisonaiagents[memory] extra isn’t installed.
2

Level 2 — String (pick a backend)

Pass a backend name to choose where memories are stored.
3

Level 3 — Config class (full control)

Use MemoryConfig to scope memory per user and auto-extract facts.
4

Level 4 — Config with continuous learning

Add LearnConfig to build a long-term persona alongside session memory.

How It Works

Turn on prefetch=True on MemoryConfig to have relevant long-term memories injected into the system prompt at the start of every turn — no explicit recall() call required.

Which Backend to Choose?


Configuration Options

Full list of options, types, and defaults — MemoryConfig
The most common options at a glance:
Turn on prefetch=True on MemoryConfig to have relevant long-term memories injected into the system prompt at the start of every turn — no explicit recall() call required. See Memory Prefetch for the full guide.

Common Patterns

Pattern 1 — User-scoped memory

Pattern 2 — History injection for conversation continuity

Default sessions are workspace-scoped — the same agent name in a different project is a different session. See Where sessions live for details and the PRAISONAI_GLOBAL_SESSIONS opt-out.

Pattern 3 — Recalled context at turn start

The agent sees a ## Recalled memories block in its system prompt before the first model call — no extra tool call needed.

Quick API — remember, recall, forget

Three verbs give you explicit control over long-term facts — store, look up, and delete. An agent with memory=True exposes its memory instance directly, so you can store and recall facts on demand.
Use Memory() standalone in a plain script — no config, no agent required.

Parameters

remember() and recall() operate on long-term memory only, and forget(query=...) is scoped to long-term memory to match. forget() requires exactly one of memory_id or query — passing neither, both, or an empty query raises ValueError.

Which memory API?

Interaction flow


Best Practices

As of PraisonAI PR #3614, Agent(memory=True) without a user_id generates a fresh per-instance identifier (agent-<uuid>) and logs a warning. Memory is isolated per Agent object by default — safe, but not what you want if you re-create the agent between requests and expect it to remember the last conversation.Pass user_id="alice" (or "tenant-42", "project-climate", etc.) to opt into a shared / persistent store that survives across processes.
Enable auto_memory=True to have the agent automatically identify and store important facts from each conversation — names, preferences, decisions — without extra code.
Set learn=True inside MemoryConfig to enable continuous learning alongside session memory. This gives agents both short-term context (memory) and long-term pattern recognition (learn).
Start with file, move to sqlite when you need durability, then mongodb (or chroma for vector search) when you deploy multiple agent instances that share memory. For Redis or Postgres, use memory=MemoryConfig(db=db(state_url="redis://...")) or db(database_url="postgresql://...") — see Redis persistence.
Agent(memory=True) auto-captures every conversation turn. remember() / recall() / forget() give you explicit control for fact storage — use them for structured knowledge you want to look up later. Both share the same long-term store when the agent’s memory instance is used.

Learn

Learn — continuous learning from conversations

Knowledge

Knowledge — add documents and URLs as agent knowledge

Memory Flush on Compaction

Preserve facts before compaction — save durable facts before older messages are dropped