Skip to main content

Overview

AsyncPostgresStorage provides an asynchronous PostgreSQL-based storage backend using SQLAlchemy with asyncpg. Ideal for production deployments, multi-node systems, and applications requiring ACID compliance with async support.

Install

Install the PostgreSQL storage optional dependency group:

Basic Usage

Parameters

ParameterTypeDefaultDescription
db_urlstrNonePostgreSQL connection URL (e.g., postgresql+asyncpg://user:pass@host/db)
db_engineAsyncEngineNonePre-configured SQLAlchemy AsyncEngine
db_schemastr"public"PostgreSQL schema to use
session_tablestrNoneCustom name for the session table
user_memory_tablestrNoneCustom name for the user memory table
knowledge_tablestrNoneCustom name for the knowledge registry table (used by KnowledgeBase)
create_schemaboolTrueWhether to create the schema if it doesn’t exist
idstrNoneUnique identifier for this storage instance
Connection pool is automatically configured with pool_pre_ping=True and pool_recycle=3600 for robust connection handling.