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.

feat: optimize read query (#2516)

cthomas325e77f81adc
diff --git a/letta/orm/sqlalchemy_base.py b/letta/orm/sqlalchemy_base.py
index 28bc55784..7c24e1e88 100644
--- a/letta/orm/sqlalchemy_base.py
+++ b/letta/orm/sqlalchemy_base.py
@@ -547,8 +547,11 @@ class SqlalchemyBase(CommonSqlalchemyMetaMixins, Base):
query_conditions = []
# If an identifier is provided, add it to the query conditions
- if len(identifiers) > 0:
- query = query.where(cls.id.in_(identifiers))
+ if identifiers:
+ if len(identifiers) == 1:
+ query = query.where(cls.id == identifiers[0])
+ else:
+ query = query.where(cls.id.in_(identifiers))
query_conditions.append(f"id='{identifiers}'")
elif not kwargs:
logger.debug(f"No identifiers provided for {cls.__name__}, returning empty list")