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.
Quick Start
- 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
| Aspect | Conversation Store | Knowledge Store | State Store |
|---|---|---|---|
| What it stores | Chat messages | Documents & chunks | Learned facts & preferences |
| Agent param | memory={"session_id": "..."} | knowledge=[...] | memory=True |
| Lifetime | Persistent | Persistent | Persistent |
| Direction | Read + Write | Read-mostly | Read + Write |
| Search | Sequential | Semantic (RAG) | Text similarity |
| Dependencies | None | chromadb | None (file) / chromadb |
| Use case | Resume conversations | Answer from documents | Remember preferences |
Conversation Store
Saves chat messages so users can resume conversations after app restart.
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.
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.
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:
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?
Using Multiple Stores Together
The most powerful pattern combines all three stores.
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:
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
)
)| Store | Config | Available Backends |
|---|---|---|
| Conversation | MemoryConfig(backend="...") | file, sqlite, postgres, redis, mongodb |
| Knowledge | KnowledgeConfig(vector_store={...}) | ChromaDB, Qdrant, Pinecone, Weaviate, LanceDB, Milvus, PGVector |
| State | MemoryConfig(backend="...", learn=True) | file, sqlite, postgres, redis, mongodb |
Performance
| Store Type | Setup Time | Query Time | Dependencies |
|---|---|---|---|
| Conversation | 0ms | 1-5ms | None |
| Knowledge | 1-5s per doc | 50-200ms | chromadb |
| State (file) | 0ms | 1-5ms | None |
| State (chromadb) | ~100ms | 20-100ms | chromadb |
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.