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: agent tags reverse index

Andy Li1700cbeb4f68
diff --git a/alembic/versions/f55542f37641_add_index_for_agent_tags_reversed_order.py b/alembic/versions/f55542f37641_add_index_for_agent_tags_reversed_order.py
new file mode 100644
index 000000000..5a0d13d22
--- /dev/null
+++ b/alembic/versions/f55542f37641_add_index_for_agent_tags_reversed_order.py
@@ -0,0 +1,37 @@
+"""add index for agent_tags reversed order
+
+Revision ID: f55542f37641
+Revises: ddecfe4902bc
+Create Date: 2025-07-24 18:00:30.773048
+
+"""
+
+from typing import Sequence, Union
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision: str = "f55542f37641"
+down_revision: Union[str, None] = "f5d26b0526e8"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+
+def upgrade() -> None:
+ # Note some issues at least with pg8000 with concurrent index creation
+ # with op.get_context().autocommit_block():
+ # op.create_index(
+ # op.f('ix_agent_tags_tag_agent_id'),
+ # "agents_tags",
+ # ['tag', 'agent_id'],
+ # unique=False,
+ # postgresql_concurrently=True,
+ # )
+ op.create_index("ix_agents_tags_tag_agent_id", "agents_tags", ["tag", "agent_id"], unique=False)
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_index("ix_agents_tags_tag_agent_id", table_name="agents_tags")
+ # ### end Alembic commands ###
diff --git a/letta/orm/agents_tags.py b/letta/orm/agents_tags.py
index 438910a34..d71770832 100644
--- a/letta/orm/agents_tags.py
+++ b/letta/orm/agents_tags.py
@@ -9,6 +9,7 @@ class AgentsTags(Base):
__table_args__ = (
UniqueConstraint("agent_id", "tag", name="unique_agent_tag"),
Index("ix_agents_tags_agent_id_tag", "agent_id", "tag"),
+ Index("ix_agents_tags_tag_agent_id", "tag", "agent_id"),
)
# # agent generates its own id
diff --git a/letta/settings.py b/letta/settings.py
index f75377979..3f91b27a9 100644
--- a/letta/settings.py
+++ b/letta/settings.py
@@ -242,7 +242,7 @@ class Settings(BaseSettings):
uvicorn_reload: bool = False
uvicorn_timeout_keep_alive: int = 5
- use_uvloop: bool = Field(default=True, description="Enable uvloop as asyncio event loop.")
+ use_uvloop: bool = Field(default=False, description="Enable uvloop as asyncio event loop.")
use_granian: bool = Field(default=False, description="Use Granian for workers")
sqlalchemy_tracing: bool = False