Store Types

Choose the right store type: Conversation, Knowledge, or State

PraisonAI uses three store types to manage different kinds of information for your agents.

Diagram

Store Types

💬 Conversation Store\nChat history

📚 Knowledge Store\nDocuments & RAG

🧠 State Store\nLearning & memory

🤖 Agent

Quick Start

  1. Use All Three Stores
    python
    from praisonaiagents import Agent
    
    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant",
        memory={"session_id": "chat-123"},  # Conversation Store
        knowledge=["docs/manual.pdf"],       # Knowledge Store
    )
    
    agent.start("What does the manual say about setup?")

Quick Comparison

AspectConversation StoreKnowledge StoreState Store
What it storesChat messagesDocuments & chunksLearned facts & preferences
Agent parammemory={"session_id": "..."}knowledge=[...]memory=True
LifetimePersistentPersistentPersistent
DirectionRead + WriteRead-mostlyRead + Write
SearchSequentialSemantic (RAG)Text similarity
DependenciesNonechromadbNone (file) / chromadb
Use caseResume conversationsAnswer from documentsRemember preferences

Conversation Store

Saves chat messages so users can resume conversations after app restart.

Diagram

message

save

restore

👤 User

🤖 Agent

💬 Session Store

python
from praisonaiagents import Agent

# Session 1: Start a conversation
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant",
    memory={"session_id": "my-session-123"}
)
agent.start("My name is Alice and I love Python")

# Session 2 (later): History restored automatically
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant",
    memory={"session_id": "my-session-123"}
)
agent.start("What's my name?")  # Remembers: "Alice"

Supported Databases


Knowledge Store

Pre-loads documents into a vector database for semantic search (RAG). Agents find relevant information by meaning, not keywords.

Diagram

Load

chunk & embed

search

📄 PDF

Knowledge

📝 TXT

🌐 URL

🔍 Vector DB

🤖 Agent

python
from praisonaiagents import Agent

agent = Agent(
    name="Support Agent",
    instructions="Answer questions using the documentation",
    knowledge=["docs/manual.pdf", "docs/faq.txt"]
)

agent.start("How do I reset my password?")

Supported Databases


State Store

Stores learned facts, preferences, and entities across sessions. Agents get smarter over time.

Diagram

Session 2

Session 1

learn

recall

🤖 Agent

🧠 Memory

🤖 Agent

python
from praisonaiagents import Agent

# Session 1: Agent learns
agent = Agent(
    name="Assistant",
    instructions="Remember user preferences",
    memory=True
)
agent.start("I prefer dark mode and formal responses")

# Session 2: Agent recalls
agent = Agent(
    name="Assistant",
    instructions="Remember user preferences",
    memory=True
)
agent.start("What are my preferences?")
# Remembers: "dark mode and formal responses"

Database Configuration

By default, State Store uses JSON files. To use a database backend:

python
from praisonaiagents import Agent, MemoryConfig

# State Store with Redis
agent = Agent(
    name="Assistant",
    instructions="Remember user preferences",
    memory=MemoryConfig(
        backend="redis",     # or "sqlite", "postgres", "mongodb"
        learn=True           # Enable learning from interactions
    )
)

# State Store with MongoDB
agent = Agent(
    name="Assistant",
    instructions="Remember user preferences",
    memory=MemoryConfig(
        backend="mongodb",
        auto_memory=True      # Auto-extract facts from conversations
    )
)

Supported Databases


Which Store Do I Need?

Diagram

Yes

No

Yes

No

Yes

No

🤔 What do I need?

Resume conversations\nafter restart?

💬 Conversation Store\nmemory={session_id: ‘…’}

Search documents\nfor answers?

📚 Knowledge Store\nknowledge=[‘file.pdf’]

Agent should learn\nand remember?

🧠 State Store\nmemory=True

No store needed\nContext flows automatically


Using Multiple Stores Together

The most powerful pattern combines all three stores.

python
from praisonaiagents import Agent, AgentTeam, MemoryConfig

# Agent with all three store types
support = Agent(
    name="Support",
    instructions="Answer questions using docs. Remember user issues.",
    knowledge=["docs/manual.pdf"],    # Knowledge Store
    memory=MemoryConfig(              # Conversation + State Store
        session_id="support-123",
        auto_memory=True
    )
)

escalation = Agent(
    name="Escalation",
    instructions="Handle complex issues based on support findings"
)

team = AgentTeam(
    agents=[support, escalation],
    process="sequential"
)

team.start("My account is locked")

Different Databases Per Store

Each store type can use a different database independently:

python
from praisonaiagents import Agent, MemoryConfig, KnowledgeConfig

agent = Agent(
    name="Support",
    instructions="Answer questions using docs. Remember user issues.",

    # Knowledge Store → Qdrant vector DB
    knowledge=KnowledgeConfig(
        sources=["docs/manual.pdf"],
        vector_store={
            "provider": "qdrant",
            "url": "http://localhost:6333"
        }
    ),

    # Conversation + State Store → PostgreSQL
    memory=MemoryConfig(
        backend="postgres",           # Conversations persisted to PostgreSQL
        session_id="support-123",
        learn=True                    # State/learning also stored in PostgreSQL
    )
)
StoreConfigAvailable Backends
ConversationMemoryConfig(backend="...")file, sqlite, postgres, redis, mongodb
KnowledgeKnowledgeConfig(vector_store={...})ChromaDB, Qdrant, Pinecone, Weaviate, LanceDB, Milvus, PGVector
StateMemoryConfig(backend="...", learn=True)file, sqlite, postgres, redis, mongodb
Diagram

Conversation Store

State Store

Context (Runtime)

Knowledge Store

RAG

findings

learn

recall

save

restore

📚 Docs

Support

Escalation

🧠 Memory

💬 History


Performance

Store TypeSetup TimeQuery TimeDependencies
Conversation0ms1-5msNone
Knowledge1-5s per doc50-200mschromadb
State (file)0ms1-5msNone
State (chromadb)~100ms20-100mschromadb

Best Practices

Start simple, add stores as needed

Most agents only need one store type. Add memory={"session_id": "..."} for chat apps, knowledge=[...] for document Q&A, or memory=True for learning agents. Combine only when your use case requires it.

Use meaningful session IDs

Include user context in session IDs: user-123-main, support-ticket-456. This isolates conversations and makes debugging easier.

Choose the right database for production

JSON files work for development. For production: PostgreSQL for conversation stores, ChromaDB or Qdrant for knowledge stores, Redis for fast state stores.

Keep knowledge stores focused

Load only relevant documents per agent. A support agent needs FAQs, not engineering specs. Smaller knowledge bases give faster, more accurate results.


Related