Skip to main content
Multi-tiered memory with short-term, long-term, entity, and user-specific storage — enhanced by quality scoring and automatic extraction.
The user chats across turns; multi-tier memory stores and scores context for later retrieval.

How It Works

Key Features

Separate short-term and long-term memory systems

4-metric quality assessment for stored memories

User, agent, and run-specific memory scoping

Automatic entity extraction and storage

Optional Neo4j/Memgraph for relationships

Quality-based filtering and relevance ranking

Quick Start

1

Simple — enable with True

2

With config


Direct Memory Access

Memory Tiers

Short-term Memory (STM)

Short-term memory is cleared between sessions and used for immediate context.

Long-term Memory (LTM)

Long-term memory persists across sessions and stores important information.

Entity Memory

Entity memory stores information about specific people, places, or things.

User Memory

User memory stores personalised information and preferences.

Configuration Options

MemoryConfig SDK Reference

Full parameter reference for MemoryConfig
MemoryBackend options:
BackendValueDescription
File"file"JSON files (default, zero dependencies)
SQLite"sqlite"SQLite database
Redis"redis"Redis (requires redis-py)
Valkey"valkey"Valkey (Redis-compatible)
Postgres"postgres"PostgreSQL
Mem0"mem0"Mem0 cloud service (requires mem0ai)
MongoDB"mongodb"MongoDB
Dakera"dakera"Self-hosted decay-weighted memory server (requires praisonaiagents[dakera])
MemoryConfig parameters:
OptionTypeDefaultDescription
backendstr"file"Storage backend (see above)
user_idstr | NoneNoneScope memory to a specific user
session_idstr | NoneNoneScope memory to a specific session
auto_memoryboolFalseAuto-extract and store key facts
claude_memoryboolFalseUse Claude’s native memory (Anthropic models)
configdict | NoneNoneProvider-specific configuration
learnbool | LearnConfig | NoneNoneEnable continuous learning
historyboolFalseAuto-inject session history into context
history_limitint10Max messages to inject from history
auto_savestr | NoneNoneAuto-save session with this name

RAG Configuration (Default)

Mem0 Configuration

Requires the optional memory extras:
If the package is missing, configuring "provider": "mem0" raises:

Dakera Configuration

Requires the optional Dakera extra:
If the package is missing, configuring "provider": "dakera" raises:
See Dakera Memory for the full guide including self-hosted deployment, tier mapping, and delete/reset operations.

Graph Memory Configuration

Requires the optional memory extras:

Backend Fallback

PraisonAI automatically falls back to SQLite when a configured backend (Redis, Valkey, Postgres) is unavailable, so your agent keeps working without crashing.
Configured backendFallback when unavailableSearch/store path
redisSQLite (adapter)memory_adapter.search_* / store_*
valkeySQLite (adapter)memory_adapter.search_* / store_*
postgresSQLite (adapter)memory_adapter.search_* / store_*
sqliten/a (native)memory_adapter.* (direct)
filen/a (native)FileMemory (direct)
mem0raises ImportErrordirect Mem0 client
mongodbraises errordirect Mongo client
Before the fix in PraisonAI PR #2190, configuring backend="redis" without redis-py installed produced sqlite3.OperationalError: no such table: short_mem on the first memory call. The SQLite adapter now owns the correct schema (short_term_memory / long_term_memory), so fallback is transparent.
Cause: You are running a version of PraisonAI before PR #2190. A non-default backend (e.g. redis) was configured but its dependency was not installed, causing a silent fallback to SQLite — which then queried the legacy short_mem table that no longer exists.Fix: Upgrade PraisonAI to the release that includes PR #2190, or install the dependency for your configured backend (e.g. pip install redis for Redis).

Quality Scoring System

Quality Metrics

Completeness

Measures how complete and comprehensive the information is

Relevance

Measures how relevant the information is to the context

Clarity

Measures how clear and understandable the information is

Accuracy

Measures the factual accuracy of the information

Quality Calculation

Advanced Features

Cache-Optimised Context

Memory results are deterministically ordered for prompt caching effectiveness. Use build_context_for_task() with explicit output control for manual prompt assembly.
See Prompt Caching for the full guide.

Context Building

Build comprehensive context for tasks:

Task Output Finalisation

Store task results with quality assessment:

Memory Citations

Automatically cite memory sources:

Memory Reranking

Enhance search results with intelligent reranking based on relevance scores:

Reranking Features

  1. Semantic Reranking: Re-scores results based on semantic similarity
  2. Context-Aware Ranking: Considers current context when ranking
  3. Quality-Weighted Ranking: Combines relevance with quality scores

Custom Reranking Logic

Implement custom reranking strategies:

Reranking Performance

Optimize reranking for large result sets:

Performance Optimisation

Complete Example

Best Practices

Use min_quality=0.8 for critical information retrieval. Use lower thresholds (0.5–0.7) for exploratory searches where recall is more important.
Always pass user_id for user-specific memories, agent_id for agent-scoped shared knowledge, and run_id for ephemeral session context.
Set use_embedding=True in the memory config for semantic (not just keyword) retrieval. Use text-embedding-3-small for cost efficiency.
Enable MemoryConfig(auto_memory=True) to automatically extract preferences, facts, and entities from conversations without manual store_* calls.

AutoMemory

AutoMemory automatically extracts structured information from conversations using configurable patterns — no manual store_* calls needed.

How It Works

AutoMemory wraps FileMemory with a pattern-based extraction engine. After each agent interaction, it scans the conversation for matching patterns (preferences, facts, dates, etc.) and stores them automatically.

Quick Start

Custom Patterns

MemoryConfig Integration

Use MemoryConfig.auto_memory to enable AutoMemory as part of the consolidated memory parameter:
ParameterTypeDefaultDescription
auto_memoryboolFalseEnable automatic memory extraction
backendstr"file"Storage backend (file, sqlite, redis, etc.)
user_idstrNoneUser ID for scoping memories

Knowledge

Integrate with document knowledge bases

Prompt Caching

Optimise memory context for prompt caching

Vector Store

Store and query embeddings with a pluggable, namespace-aware backend