Skip to content

SessionStore

Interface for session persistence backends. Implement this to store sessions in any storage system. Built-in adapters: @agent-express/session-sqlite, session-redis, session-postgres.

add(sessionId, message): Promise<void>

Append a single message without rewriting the full history.

string

Message

Promise<void>


delete(sessionId): Promise<void>

Delete session.

string

Promise<void>


list(sessionId, opts?): Promise<Message[]>

Get messages with pagination.

string

number

Max messages to return.

number

Skip first N messages.

"asc" | "desc"

Sort order. Default: “desc” (newest first).

Promise<Message[]>


load(sessionId): Promise<SessionData | null>

Load full session (state + history). Returns null if not found.

string

Promise<SessionData | null>


save(sessionId, data): Promise<void>

Save full session (state + history).

string

SessionData

Promise<void>