Skip to main content
The gateway now ships in the praisonai-bot package. praisonai serve gateway still works exactly as documented here; for a standalone install see praisonai-bot Migration.
Persistent sessions keep conversation state alive across gateway restarts and let clients resume mid-conversation with event replay.
This page covers agent session persistence (messages, events, cursors). Gateway sessions additionally preserve pending_inbox and is_executing across disconnects and graceful shutdown — see Gateway Session Continuity.
Gateway Memory-Pressure Eviction relies on this — an unflushed transcript is never evicted, because only a durably persisted cache can be losslessly rebuilt on the next turn.
Channel-originated sessions get a proactive “interrupted — resuming” notice after a gateway restart — see Restart Continuation.
Durable by default (as of PR #3595). session.persist now defaults to true, so a gateway started from the out-of-the-box path writes to ~/.praisonai/sessions/sessions.db on first boot and remembers conversations across restarts. Set session.persist: false in gateway.yaml to keep the old ephemeral, in-memory behaviour.
When a durable write does fail (disk-full / corruption / permission), the turn is not lost — it’s salvaged to ~/.praisonai/state/session_spill/ and re-folded on the next load. Subscribe to the observe-only SESSION_PERSIST_FAILED hook to alert/metric on the failure. See Write-failure salvage for the full spill + re-ingest flow.Similarly, if a session file is found corrupt on the next load (malformed JSON / invalid UTF-8), the corrupt bytes are quarantined to <file>.json.corrupt-<ts> before a fresh session starts, and the same SESSION_PERSIST_FAILED hook fires with the quarantine path in spilled. See Corruption-quarantine on load.
The user returns later; persisted session state reloads so the agent remembers prior turns.

Quick Start

1

Persistence is on by default

No session: block is required — persistence engages automatically:
Default storage: ~/.praisonai/sessions/sessions.dbOpt out for ephemeral, in-memory sessions:
As of PraisonAI PR #3595, session.persist itself defaults to true, so the SqliteTranscriptStore (WAL SQLite, one row per session, indexed lookups) engages out-of-the-box. Set session.store: file to keep the legacy per-session JSON layout. See SQLite Transcript Store for the full picture.
2

Resume as a client

3

Full configuration

When the SQLite and file-store paths can’t be opened (e.g. a read-only or absent $HOME), the gateway degrades to in-memory sessions instead of aborting startup. persist: true therefore never crashes on a constrained host — sessions are kept in memory for the run and lost on restart. If the doctor or logs report an in-memory fallback, $HOME is unwritable.

What gets persisted

The on-disk record under persist_path is the JSON returned by GatewaySession.to_dict(). Key fields:
capabilities and protocol_version are restored on resume so server-side code that branches on either keeps working without re-handshake. A persisted record from before the upgrade (no capabilities key) restores cleanly to [] — no migration required.

How it works

Reconnect protocol

Client join (resume):
Server joined:
Replay frames:
Every response, message, stream_end, and error frame includes a monotonic cursor. Track the highest value for the next reconnect.

Configuration options

Common patterns

Python override:
An explicit session_store always wins over the YAML/default derivation. CLI opt-out now honoured: session.persist: false in gateway.yaml is re-read on start_with_config, so the multi-bot CLI now actually runs ephemeral (previously the flag was silently ignored). Choosing resume_window: minutes for ephemeral chat, 24 h for support bots, up to 7 days for long tasks.

Best Practices

The default is durable because most conversational bots want continuity. Only set persist: false for stateless, single-shot flows or ephemeral CI runs.
Expect the transcript DB at ~/.praisonai/sessions/sessions.db. If the doctor or logs report an in-memory fallback, $HOME is unwritable.
Without since, the client may miss events between disconnect and resume.
Too short loses conversations; too long grows disk usage.
Session files should be included in normal backup rotation.
Do not share storage between two gateway processes — see Gateway Overview single-instance guidance.

Gateway Overview

Gateway setup and configuration

SQLite Transcript Store

The default persistence backend, engaged out-of-the-box

Gateway Session Continuity

Preserve pending inbox and mid-turn state across disconnects

Restart Continuation

Notify channel users after a gateway restart

Write-failure salvage

Spill + re-ingest when a durable session write fails