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: add size async caching (#2532)

cthomas75d1b50f5d45
diff --git a/letta/orm/passage.py b/letta/orm/passage.py
index 76790fc2c..eb38b6917 100644
--- a/letta/orm/passage.py
+++ b/letta/orm/passage.py
@@ -90,4 +90,8 @@ class AgentPassage(BasePassage, AgentMixin):
Index("agent_passages_created_at_id_idx", "created_at", "id"),
{"extend_existing": True},
)
- return (Index("agent_passages_created_at_id_idx", "created_at", "id"), {"extend_existing": True})
+ return (
+ Index("ix_agent_passages_org_agent", "organization_id", "agent_id"),
+ Index("agent_passages_created_at_id_idx", "created_at", "id"),
+ {"extend_existing": True},
+ )
diff --git a/letta/orm/sqlalchemy_base.py b/letta/orm/sqlalchemy_base.py
index 8154a0eac..04e27e11b 100644
--- a/letta/orm/sqlalchemy_base.py
+++ b/letta/orm/sqlalchemy_base.py
@@ -840,7 +840,7 @@ class SqlalchemyBase(CommonSqlalchemyMetaMixins, Base):
**kwargs,
):
logger.debug(f"Calculating size for {cls.__name__} with filters {kwargs}")
- query = select(func.count()).select_from(cls)
+ query = select(func.count(1)).select_from(cls)
if actor:
query = cls.apply_access_predicate(query, actor, access, access_type)