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.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.
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.Quick Start
1
Persistence is on by default
No Default storage:
session: block is required — persistence engages automatically:~/.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 underpersist_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):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: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
Opt out only when you need to
Opt out only when you need to
The default is durable because most conversational bots want continuity. Only set
persist: false for stateless, single-shot flows or ephemeral CI runs.Confirm the on-disk store engaged
Confirm the on-disk store engaged
Expect the transcript DB at
~/.praisonai/sessions/sessions.db. If the doctor or logs report an in-memory fallback, $HOME is unwritable.Always send since on reconnect
Always send since on reconnect
Without
since, the client may miss events between disconnect and resume.Match resume_window to user behaviour
Match resume_window to user behaviour
Too short loses conversations; too long grows disk usage.
Back up persist_path
Back up persist_path
Session files should be included in normal backup rotation.
One gateway per persist_path
One gateway per persist_path
Do not share storage between two gateway processes — see Gateway Overview single-instance guidance.
Related
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

