session_id to your agent’s memory configuration.
Quick Start
1
Install PraisonAI Agents
2
Create Agent with Session
3
Resume Later
Default Storage:
~/.praisonai/sessions/{session_id}.jsonHow It Works
Configuration Options
Using MemoryConfig (Recommended)
For full control, use theMemoryConfig class:
Using Dict Shorthand
For quick setup, use a dictionary:Database Persistence
For production apps, persist sessions to a database:Multi-User Sessions
For apps with multiple users, includeuser_id to isolate conversations:
Using the Session Class
For advanced control over memory and knowledge, use theSession class:
Advanced Topics
Hierarchical Sessions (Forking & Snapshots)
Hierarchical Sessions (Forking & Snapshots)
For complex workflows, use hierarchical sessions with forking and snapshots:See Session Hierarchy for full documentation.
Remote Agent Sessions
Remote Agent Sessions
Connect to agents running on remote machines:
Custom Database Adapter
Custom Database Adapter
Direct Session Store Access
Direct Session Store Access
For low-level control, access the session store directly:Atomic batch replace — when you need to rewrite the whole history under a single lock (compaction, redaction, multi-worker bot saves):Safer than
clear_session() + a loop of add_message() — there is no window where another worker can read an empty history.Best Practices
Use Meaningful Session IDs
Include user ID or task context:
user-123-main, task-456-researchIsolate Users
Always include
user_id in multi-user apps to prevent data leakageChoose Right Backend
JSON for dev, SQLite for single-server, PostgreSQL for production
Set Message Limits
Use
max_messages to prevent unbounded growthSession ID Patterns
CLI Commands
Session Lifecycle & Cleanup
Session.close() now properly invokes memory.close_connections(), which closes the underlying adapter (ChromaDB references, MongoDB client, etc.):
Automatic Cleanup Example
Troubleshooting
Session not restoring
Session not restoring
- Verify
session_idis exactly the same - Check storage directory exists:
~/.praisonai/sessions/ - Ensure file permissions allow read/write
- Try invalidating cache:
store.invalidate_cache(session_id)
File lock timeout
File lock timeout
- Another process may be holding the lock
- Increase
lock_timeoutparameter - Check for stale
.lockfiles and remove them
Memory issues with large sessions
Memory issues with large sessions
- Set
max_messageslimit on DefaultSessionStore - Use
get_chat_history(max_messages=50)to limit retrieval - Consider using SQLite backend for better performance
Remote session connection failed
Remote session connection failed
- Verify agent URL is correct and accessible
- Check firewall/network settings
- Ensure remote agent has
/healthendpoint - Increase
timeoutparameter for slow networks
API Reference
Agent Session Parameters
Thememory parameter on Agent accepts these session-related options:
Session Class Parameters
Related Documentation
Session Persistence
Detailed persistence options
Session Hierarchy
Forking and snapshots
Memory System
Memory integration
CLI Commands
Command-line management

