Skip to main content
Choose the right storage backend for your knowledge base — from local development with Chroma to multi-tenant production with mem0.
The user asks a question; the agent retrieves from mem0, Chroma, or a custom knowledge store you configured.

How It Works

Quick Start

1

Simple — enable with True

2

With backend config

Available Backends

Scope Identifiers

Knowledge backends support three scope identifiers for multi-tenant isolation:
The mem0 backend requires at least one scope identifier. If none is provided, operations will fail with a ScopeRequiredError.

Example with Scope

Combining Multiple Scopes

Combine user_id, agent_id, and run_id to isolate knowledge down to a specific session for a specific agent and user.
You can also use the direct API for more control:
When you pass more than one scope identifier, PraisonAI automatically combines them using ChromaDB’s $and operator. A single identifier is passed through unchanged. You don’t need to write the $and yourself.
All provided identifiers are required to match (logical AND). Omit an identifier to broaden the scope on that dimension.
Multi-tenant SaaS application flow:
  • Per-customer isolation → set user_id
  • Per-agent isolation (e.g. SupportBot vs. SalesBot share infra but not data) → also set agent_id
  • Per-conversation isolation (e.g. ephemeral session memory) → also set run_id

Direct Knowledge API

For advanced use cases, you can use the Knowledge class directly:

Normalization Guarantees

PraisonAI normalizes all backend results to ensure consistent behavior:
  • metadata is ALWAYS a dict (never None)
  • text field is always present (mapped from memory for mem0)
  • score is always a float (defaults to 0.0)
This means you can safely access metadata without null checks:

Protocol-Driven Architecture

All backends implement the KnowledgeStoreProtocol:

Configuration Options

mem0 Backend (Default)

Chroma Backend

Error Handling

Collection Naming Rules

Enhanced Security (PR #1597): Knowledge stores now validate collection names to prevent SQL injection attacks.
Knowledge stores that interpolate collection names into DDL/DML now require collection names to match ^[A-Za-z0-9_]+$. Affected backends:
  • Cassandra
  • pgvector
  • SingleStore vector
Invalid names raise: ValueError("collection_name must be non-empty and contain only alphanumerics and underscores") Valid examples:
  • my_collection
  • UserData123
  • agent_v2_docs
Invalid examples:
  • my-collection (contains hyphen)
  • user.docs (contains dot)
  • data collection (contains space)
  • ../../etc (path traversal attempt)

Best Practices

The mem0 backend requires at least one scope identifier. Without it, operations raise ScopeRequiredError.
Collection names must match ^[A-Za-z0-9_]+$ for backends that use DDL/DML (Cassandra, pgvector, SingleStore).Valid: my_collection, UserData123. Invalid: my-collection, user.docs.
The Agent API handles scoping, retrieval, and context injection automatically. Use the direct Knowledge class only when you need custom control over indexing or search.
Any class implementing KnowledgeStoreProtocol works as a backend — no base class inheritance needed.

Troubleshooting: silent SQLite fallback

Configure a mem0 or mongodb vector store on a release before 2026-07-14 and get keyword-style results instead of semantic ones? Your Knowledge instance was likely degraded to SQLite without warning. The adapter constructors rejected an internal verbose keyword, and the resulting TypeError was swallowed at debug level (PR #2982 fixes it). Confirm which adapter you actually got:
If it isn’t Mem0Adapter / MongoDBKnowledgeAdapter, upgrade to a release built after commit 69d7ecf. On the fixed release, an explicitly-configured provider that fails to construct emits a WARNING. The exact message to look for:
For the full walkthrough and decision tree, see Knowledge → If your configured backend seems ignored.

Incremental Indexing

Skip unchanged files for fast knowledge base updates

Knowledge

Core knowledge retrieval and agent integration

Vector Store

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