From 5e43291436385502233e5d502f2310b977ce14a8 Mon Sep 17 00:00:00 2001 From: cthomas Date: Thu, 23 Oct 2025 12:13:14 -0700 Subject: [PATCH] feat: remove relationship fields on identities (#5691) --- fern/openapi.json | 6 ++++-- letta/orm/agent.py | 2 +- letta/orm/identity.py | 20 ++++++++++---------- letta/schemas/identity.py | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/fern/openapi.json b/fern/openapi.json index e5d55c24..694964aa 100644 --- a/fern/openapi.json +++ b/fern/openapi.json @@ -22962,7 +22962,8 @@ }, "type": "array", "title": "Agent Ids", - "description": "The IDs of the agents associated with the identity." + "description": "The IDs of the agents associated with the identity.", + "deprecated": true }, "block_ids": { "items": { @@ -22970,7 +22971,8 @@ }, "type": "array", "title": "Block Ids", - "description": "The IDs of the blocks associated with the identity." + "description": "The IDs of the blocks associated with the identity.", + "deprecated": true }, "properties": { "items": { diff --git a/letta/orm/agent.py b/letta/orm/agent.py index 7f5e1c62..fc1f17a8 100644 --- a/letta/orm/agent.py +++ b/letta/orm/agent.py @@ -412,7 +412,7 @@ class Agent(SqlalchemyBase, OrganizationMixin, ProjectMixin, TemplateEntityMixin ) state["blocks"] = [m.to_pydantic() for m in memory] state["identity_ids"] = [i.id for i in identities] - state["identities"] = [] # TODO: fix this + state["identities"] = [i.to_pydantic() for i in identities] state["multi_agent_group"] = multi_agent_group state["managed_group"] = multi_agent_group state["tool_exec_environment_variables"] = tool_exec_environment_variables diff --git a/letta/orm/identity.py b/letta/orm/identity.py index bf172d14..dd7ae51c 100644 --- a/letta/orm/identity.py +++ b/letta/orm/identity.py @@ -44,15 +44,15 @@ class Identity(SqlalchemyBase, OrganizationMixin, ProjectMixin): "Block", secondary="identities_blocks", lazy="selectin", passive_deletes=True, back_populates="identities" ) - @property - def agent_ids(self) -> List[str]: - """Get just the agent IDs without loading the full agent objects""" - return [agent.id for agent in self.agents] + # @property + # def agent_ids(self) -> List[str]: + # """Get just the agent IDs without loading the full agent objects""" + # return [agent.id for agent in self.agents] - @property - def block_ids(self) -> List[str]: - """Get just the block IDs without loading the full agent objects""" - return [block.id for block in self.blocks] + # @property + # def block_ids(self) -> List[str]: + # """Get just the block IDs without loading the full agent objects""" + # return [block.id for block in self.blocks] def to_pydantic(self) -> PydanticIdentity: state = { @@ -61,8 +61,8 @@ class Identity(SqlalchemyBase, OrganizationMixin, ProjectMixin): "name": self.name, "identity_type": self.identity_type, "project_id": self.project_id, - "agent_ids": self.agent_ids, - "block_ids": self.block_ids, + "agent_ids": [], + "block_ids": [], "organization_id": self.organization_id, "properties": self.properties or [], } diff --git a/letta/schemas/identity.py b/letta/schemas/identity.py index 83bd879f..9318d00c 100644 --- a/letta/schemas/identity.py +++ b/letta/schemas/identity.py @@ -46,8 +46,8 @@ class Identity(IdentityBase): name: str = Field(..., description="The name of the identity.") identity_type: IdentityType = Field(..., description="The type of the identity.") project_id: Optional[str] = Field(None, description="The project id of the identity, if applicable.") - agent_ids: List[str] = Field(..., description="The IDs of the agents associated with the identity.") - block_ids: List[str] = Field(..., description="The IDs of the blocks associated with the identity.") + agent_ids: List[str] = Field(..., description="The IDs of the agents associated with the identity.", deprecated=True) + block_ids: List[str] = Field(..., description="The IDs of the blocks associated with the identity.", deprecated=True) organization_id: Optional[str] = Field(None, description="The organization id of the user") properties: List[IdentityProperty] = Field(default_factory=list, description="List of properties associated with the identity")