Skip to main content
Configure different database backends for agent persistence.
The user saves sessions to a database so the same person can reconnect after a restart.

Quick Start

1

Simple Usage

Store sessions in a local SQLite file — no setup required.
2

With Configuration

Point the same session at PostgreSQL for multi-instance deployments.

How It Works


SQLite (Default)

PostgreSQL

Or via environment variable:

Redis

MongoDB

Best Practices

persistence="sqlite" needs no server and stores everything in a single file. Switch to a networked backend only when multiple instances share sessions.
PostgreSQL, Redis, and MongoDB accept a URL. Keep credentials in DATABASE_URL rather than hard-coding them in the Session call.
Redis suits short-lived, high-throughput sessions; PostgreSQL suits durable, queryable history; MongoDB suits flexible document state.
The session_id is the key that ties writes together. Pass the same ID on reconnect to continue the earlier conversation.

Persistence Overview

Persistence concepts

Session Resume

Resume saved sessions