From dee5a71a5f024f7d77e4e0b7bfc5b1cb0d125599 Mon Sep 17 00:00:00 2001 From: Matthew Zhou Date: Fri, 10 Jan 2025 13:38:42 -1000 Subject: [PATCH] fix: Remove unique name restriction on agents (#592) --- ...emove_unique_name_restriction_on_agents.py | 29 +++++++++++++++++++ letta/orm/agent.py | 3 +- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.py diff --git a/alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.py b/alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.py new file mode 100644 index 00000000..83940119 --- /dev/null +++ b/alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.py @@ -0,0 +1,29 @@ +"""Remove unique name restriction on agents + +Revision ID: cdb3db091113 +Revises: e20573fe9b86 +Create Date: 2025-01-10 15:36:08.728539 + +""" + +from typing import Sequence, Union + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "cdb3db091113" +down_revision: Union[str, None] = "e20573fe9b86" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint("unique_org_agent_name", "agents", type_="unique") + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_unique_constraint("unique_org_agent_name", "agents", ["organization_id", "name"]) + # ### end Alembic commands ### diff --git a/letta/orm/agent.py b/letta/orm/agent.py index d7288426..23b8d74c 100644 --- a/letta/orm/agent.py +++ b/letta/orm/agent.py @@ -1,7 +1,7 @@ import uuid from typing import TYPE_CHECKING, List, Optional -from sqlalchemy import JSON, String, UniqueConstraint +from sqlalchemy import JSON, String from sqlalchemy.orm import Mapped, mapped_column, relationship from letta.orm.block import Block @@ -27,7 +27,6 @@ if TYPE_CHECKING: class Agent(SqlalchemyBase, OrganizationMixin): __tablename__ = "agents" __pydantic_model__ = PydanticAgentState - __table_args__ = (UniqueConstraint("organization_id", "name", name="unique_org_agent_name"),) # agent generates its own id # TODO: We want to migrate all the ORM models to do this, so we will need to move this to the SqlalchemyBase