Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: temp remove disabling enable_seqscan setting (#3443)
cthomasd85d275f6f2f
diff --git a/letta/orm/sqlalchemy_base.py b/letta/orm/sqlalchemy_base.pyindex 3c60ab25f..f9ee74529 100644--- a/letta/orm/sqlalchemy_base.py+++ b/letta/orm/sqlalchemy_base.py@@ -5,7 +5,7 @@ from functools import wrapsfrom pprint import pformatfrom typing import TYPE_CHECKING, List, Literal, Optional, Tuple, Union-from sqlalchemy import Sequence, String, and_, delete, func, or_, select, text+from sqlalchemy import Sequence, String, and_, delete, func, or_, selectfrom sqlalchemy.exc import DBAPIError, IntegrityError, TimeoutErrorfrom sqlalchemy.ext.asyncio import AsyncSessionfrom sqlalchemy.orm import Mapped, Session, mapped_column@@ -512,14 +512,9 @@ class SqlalchemyBase(CommonSqlalchemyMetaMixins, Base):query, query_conditions = cls._read_multiple_preprocess(identifiers, actor, access, access_type, check_is_deleted, **kwargs)if query is None:raise NoResultFound(f"{cls.__name__} not found with identifier {identifier}")- if is_postgresql_session(db_session):- await db_session.execute(text("SET LOCAL enable_seqscan = OFF"))- try:- result = await db_session.execute(query)- item = result.scalar_one_or_none()- finally:- if is_postgresql_session(db_session):- await db_session.execute(text("SET LOCAL enable_seqscan = ON"))++ result = await db_session.execute(query)+ item = result.scalar_one_or_none()if item is None:raise NoResultFound(f"{cls.__name__} not found with {', '.join(query_conditions if query_conditions else ['no conditions'])}")diff --git a/letta/services/user_manager.py b/letta/services/user_manager.pyindex 0f05e41f2..ea3919537 100644--- a/letta/services/user_manager.py+++ b/letta/services/user_manager.py@@ -1,6 +1,6 @@from typing import List, Optional-from sqlalchemy import select, text+from sqlalchemy import selectfrom letta.constants import DEFAULT_ORG_IDfrom letta.data_sources.redis_client import get_redis_client@@ -8,7 +8,6 @@ from letta.helpers.decorators import async_redis_cachefrom letta.log import get_loggerfrom letta.orm.errors import NoResultFoundfrom letta.orm.organization import Organization as OrganizationModel-from letta.orm.sqlalchemy_base import is_postgresql_sessionfrom letta.orm.user import User as UserModelfrom letta.otel.tracing import trace_methodfrom letta.schemas.user import User as PydanticUser@@ -157,16 +156,9 @@ class UserManager:async def get_actor_by_id_async(self, actor_id: str) -> PydanticUser:"""Fetch a user by ID asynchronously."""async with db_registry.async_session() as session:- # Turn off seqscan to force use pk index- if is_postgresql_session(session):- await session.execute(text("SET LOCAL enable_seqscan = OFF"))- try:- stmt = select(UserModel).where(UserModel.id == actor_id)- result = await session.execute(stmt)- user = result.scalar_one_or_none()- finally:- if is_postgresql_session(session):- await session.execute(text("SET LOCAL enable_seqscan = ON"))+ stmt = select(UserModel).where(UserModel.id == actor_id)+ result = await session.execute(stmt)+ user = result.scalar_one_or_none()if not user:raise NoResultFound(f"User not found with id={actor_id}")