Persistence Overview
Understanding agent state persistence
Persist agent state to resume sessions and maintain context across runs.
from praisonaiagents import Agent, Session
session = Session(session_id="my-session", persistence="sqlite")
agent = Agent(name="Assistant", session=session)
agent.start("Pick up where we left off.")The user runs the agent again; stored memory and checkpoints avoid repeating earlier steps.
What Gets Persisted
- Memory: Conversation history and context
- Session State: Current task progress
- Checkpoints: Intermediate results
- Configuration: Agent settings
Quick Start
- Simple Usage
python from praisonaiagents import Agent, Session # Create session with persistence session = Session( session_id="my-session", persistence="sqlite" ) agent = Agent( name="Assistant", session=session ) # Run agent agent.start("Hello!") # Later, resume the same session session = Session(session_id="my-session", persistence="sqlite") agent = Agent(name="Assistant", session=session) agent.start("What did we talk about?") # Remembers previous context - With Configuration
python from praisonaiagents import Agent, Session session = Session(session_id="prod-session", persistence="postgresql") agent = Agent(name="Assistant", session=session, llm="gpt-4o-mini") agent.start("Continue from where we left off.")
Persistence Backends
| Backend | Use Case | Setup |
|---|---|---|
| SQLite | Local development | persistence="sqlite" |
| PostgreSQL | Production | persistence="postgresql" |
| Redis | High-performance | persistence="redis" |
| MongoDB | Document storage | persistence="mongodb" |
CLI Session Resume
praisonai session resume <id> is a first-class restore — it brings back chat history, model, and agent name. Use a follow-up prompt to continue immediately:
praisonai session resume my-session "What did we discuss?"See Session Command for the full reference including --transcript and cross-store lookup behaviour.