Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: Remove unique name restriction on agents (#592)
Matthew Zhoudee5a71a5f02
diff --git a/alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.py b/alembic/versions/cdb3db091113_remove_unique_name_restriction_on_agents.pynew file mode 100644index 000000000..839401190--- /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.pyindex d72884262..23b8d74ca 100644--- a/letta/orm/agent.py+++ b/letta/orm/agent.py@@ -1,7 +1,7 @@import uuidfrom typing import TYPE_CHECKING, List, Optional-from sqlalchemy import JSON, String, UniqueConstraint+from sqlalchemy import JSON, Stringfrom sqlalchemy.orm import Mapped, mapped_column, relationshipfrom 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