Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: support project and template on core (#847)
cthomas50ef87642752
diff --git a/alembic/versions/f922ca16e42c_add_project_and_template_id_to_agent.py b/alembic/versions/f922ca16e42c_add_project_and_template_id_to_agent.pynew file mode 100644index 000000000..e2f6d9ba9--- /dev/null+++ b/alembic/versions/f922ca16e42c_add_project_and_template_id_to_agent.py@@ -0,0 +1,35 @@+"""add project and template id to agent++Revision ID: f922ca16e42c+Revises: 6fbe9cace832+Create Date: 2025-01-29 16:57:48.161335++"""++from typing import Sequence, Union++import sqlalchemy as sa++from alembic import op++# revision identifiers, used by Alembic.+revision: str = "f922ca16e42c"+down_revision: Union[str, None] = "6fbe9cace832"+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.add_column("agents", sa.Column("project_id", sa.String(), nullable=True))+ op.add_column("agents", sa.Column("template_id", sa.String(), nullable=True))+ op.add_column("agents", sa.Column("base_template_id", sa.String(), nullable=True))+ # ### end Alembic commands ###+++def downgrade() -> None:+ # ### commands auto generated by Alembic - please adjust! ###+ op.drop_column("agents", "base_template_id")+ op.drop_column("agents", "template_id")+ op.drop_column("agents", "project_id")+ # ### end Alembic commands ###diff --git a/letta/orm/agent.py b/letta/orm/agent.pyindex 515f77c2e..39db57d23 100644--- a/letta/orm/agent.py+++ b/letta/orm/agent.py@@ -56,6 +56,9 @@ class Agent(SqlalchemyBase, OrganizationMixin):embedding_config: Mapped[Optional[EmbeddingConfig]] = mapped_column(EmbeddingConfigColumn, doc="the embedding configuration object for this agent.")+ project_id: Mapped[Optional[str]] = mapped_column(String, nullable=True, doc="The id of the project the agent belongs to.")+ template_id: Mapped[Optional[str]] = mapped_column(String, nullable=True, doc="The id of the template the agent belongs to.")+ base_template_id: Mapped[Optional[str]] = mapped_column(String, nullable=True, doc="The base template id of the agent.")# Tool rulestool_rules: Mapped[Optional[List[ToolRule]]] = mapped_column(ToolRulesColumn, doc="the tool rules for this agent.")@@ -146,6 +149,9 @@ class Agent(SqlalchemyBase, OrganizationMixin):"created_at": self.created_at,"updated_at": self.updated_at,"tool_exec_environment_variables": self.tool_exec_environment_variables,+ "project_id": self.project_id,+ "template_id": self.template_id,+ "base_template_id": self.base_template_id,}return self.__pydantic_model__(**state)diff --git a/letta/schemas/agent.py b/letta/schemas/agent.pyindex 3214307ac..ec9880d42 100644--- a/letta/schemas/agent.py+++ b/letta/schemas/agent.py@@ -81,6 +81,9 @@ class AgentState(OrmMetadataBase, validate_assignment=True):tool_exec_environment_variables: List[AgentEnvironmentVariable] = Field(default_factory=list, description="The environment variables for tool execution specific to this agent.")+ project_id: Optional[str] = Field(None, description="The id of the project the agent belongs to.")+ template_id: Optional[str] = Field(None, description="The id of the template the agent belongs to.")+ base_template_id: Optional[str] = Field(None, description="The base template id of the agent.")def get_agent_env_vars_as_dict(self) -> Dict[str, str]:# Get environment variables for this agent specifically