Persistence
Save and resume agent sessions
Learn how to persist agent state and resume interrupted sessions.
from praisonaiagents import Agent, Session
session = Session(session_id="demo", persistence="sqlite")
agent = Agent(name="Assistant", session=session)
agent.start("Continue our conversation.")The user opens a persistence guide, wires a session store, then resumes work without losing context.
Quick Start
- Simple Usage
Attach a session to the agent so its state survives a restart.
python from praisonaiagents import Agent, Session session = Session(session_id="demo", persistence="sqlite") agent = Agent(name="Assistant", session=session) agent.start("Continue our conversation.") - With Configuration
Reopen the same session ID later to pick up exactly where you left off.
python from praisonaiagents import Agent, Session session = Session(session_id="demo", persistence="sqlite") agent = Agent(name="Assistant", session=session) agent.resume()
How It Works
Guides
Persistence concepts
Database SetupConfigure database backends
Session ResumeResume interrupted sessions
Best Practices
Choose a backend before you scale
SQLite is perfect for a single process; move to PostgreSQL or Redis once several instances need to share the same sessions.
Treat session_id as the resume key
The same session_id reconnects to the same history. Generate it per user or per task, and store it where you can look it up later.
Checkpoint long-running work
Set checkpoint_interval so a crash mid-task resumes from the last checkpoint instead of the beginning.