Quick Start
1
Simple Usage
2
Resume on Next Run
Which Entry Point?
Pick the style that matches how much control you need.How It Works
Each entry point drives the same orchestrator lifecycle.Entry Points
wrap_agent_with_persistence
Patches chat (and achat, if the agent has it) on the agent you pass in, and returns that same agent.
Helpers added to the agent:
PersistentAgent
Wraps the agent without patching it. Same options and helpers as above, plus a session_id property. Other attributes pass through to the wrapped agent.
await agent.achat(...) works even if the wrapped agent has no achat β it runs chat in a worker thread.
create_persistent_session
A with block for logging messages by hand.
Sessions support the sync
with statement only. There is no async with.Common Patterns
Start fresh every run
Start fresh every run
One session per user
One session per user
Async chat
Async chat
Best Practices
Choose the entry point deliberately
Choose the entry point deliberately
Use
MemoryConfig(db=PraisonAIDB(...)) unless you already have a PersistenceOrchestrator. Use PersistentAgent over wrap_agent_with_persistence when youβd rather not modify the agent object.Use stable session IDs
Use stable session IDs
Resume only works when you reuse the same
session_id. Derive it from your user or conversation ID. Omit it only for throwaway sessions.End sessions and close resources
End sessions and close resources
Call
end_session() when a conversation finishes, and close the agent when youβre done. See Agent Lifecycle Cleanup.Know what auto-resume replaces
Know what auto-resume replaces
On the first chat, resumed history replaces
agent.chat_history. Set auto_resume=False if the agent has history you want to keep.Related
Persistence Overview
Both entry points and who owns the store writes
Async DB Hooks
Sync and async store dispatch
Managed Agent Persistence
The recommended
MemoryConfig(db=PraisonAIDB(...)) pathAgent Lifecycle Cleanup
Closing agents and their resources

