Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix(db): Disable Prepared Statements to Satisfy the Connection Pooler (#2449)

Kian Jones25403dcde8d1
diff --git a/letta/server/db.py b/letta/server/db.py
index fc2fa3e24..1e9a94633 100644
--- a/letta/server/db.py
+++ b/letta/server/db.py
@@ -1,5 +1,6 @@
import os
import threading
+import uuid
from contextlib import asynccontextmanager, contextmanager
from typing import Any, AsyncGenerator, Generator
@@ -165,6 +166,17 @@ class DatabaseRegistry:
if not is_async:
base_args["pool_use_lifo"] = settings.pool_use_lifo
+ elif is_async:
+ # For asyncpg, statement_cache_size should be in connect_args
+ base_args.update(
+ {
+ "connect_args": {
+ "prepared_statement_name_func": lambda: f"__asyncpg_{uuid.uuid4()}__",
+ "statement_cache_size": 0,
+ "prepared_statement_cache_size": 0,
+ }
+ }
+ )
return base_args
def _wrap_sqlite_engine(self, engine: Engine) -> None: