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.

fix: prevent cross tenancy attaching sources

Ari Webb015a209f407f
diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.py
index ce883bae8..64754f521 100644
--- a/letta/services/agent_manager.py
+++ b/letta/services/agent_manager.py
@@ -1568,7 +1568,7 @@ class AgentManager:
actor: User performing the action
Raises:
- ValueError: If either agent or source doesn't exist
+ NoResultFound: If either agent or source doesn't exist or actor lacks permission to access them
IntegrityError: If the source is already attached to the agent
"""
@@ -1576,6 +1576,9 @@ class AgentManager:
# Verify both agent and source exist and user has permission to access them
agent = await AgentModel.read_async(db_session=session, identifier=agent_id, actor=actor)
+ # Verify the actor has permission to access the source
+ await SourceModel.read_async(db_session=session, identifier=source_id, actor=actor)
+
# The _process_relationship helper already handles duplicate checking via unique constraint
await _process_relationship_async(
session=session,