Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
chore: Deprecate module field on tool (#600)
Matthew Zhou7d04ddc580db
diff --git a/alembic/versions/22a6e413d89c_remove_module_field_on_tool.py b/alembic/versions/22a6e413d89c_remove_module_field_on_tool.pynew file mode 100644index 000000000..8d05aabea--- /dev/null+++ b/alembic/versions/22a6e413d89c_remove_module_field_on_tool.py@@ -0,0 +1,31 @@+"""Remove module field on tool++Revision ID: 22a6e413d89c+Revises: 88f9432739a9+Create Date: 2025-01-10 17:38:23.811795++"""++from typing import Sequence, Union++import sqlalchemy as sa++from alembic import op++# revision identifiers, used by Alembic.+revision: str = "22a6e413d89c"+down_revision: Union[str, None] = "88f9432739a9"+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_column("tools", "module")+ # ### end Alembic commands ###+++def downgrade() -> None:+ # ### commands auto generated by Alembic - please adjust! ###+ op.add_column("tools", sa.Column("module", sa.VARCHAR(), autoincrement=False, nullable=True))+ # ### end Alembic commands ###diff --git a/letta/orm/tool.py b/letta/orm/tool.pyindex 9d744f44d..0b443d27c 100644--- a/letta/orm/tool.py+++ b/letta/orm/tool.py@@ -40,9 +40,6 @@ class Tool(SqlalchemyBase, OrganizationMixin):source_type: Mapped[ToolSourceType] = mapped_column(String, doc="The type of the source code.", default=ToolSourceType.json)source_code: Mapped[Optional[str]] = mapped_column(String, doc="The source code of the function.")json_schema: Mapped[Optional[dict]] = mapped_column(JSON, default=lambda: {}, doc="The OAI compatable JSON schema of the function.")- module: Mapped[Optional[str]] = mapped_column(- String, nullable=True, doc="the module path from which this tool was derived in the codebase."- )# relationshipsorganization: Mapped["Organization"] = relationship("Organization", back_populates="tools", lazy="selectin")diff --git a/letta/schemas/message.py b/letta/schemas/message.pyindex ea46f3f87..ea04ec107 100644--- a/letta/schemas/message.py+++ b/letta/schemas/message.py@@ -708,8 +708,6 @@ class Message(BaseMessage):},]for tc in self.tool_calls:- # TODO better way to pack?- # function_call_text = json.dumps(tc.to_dict())function_name = tc.function["name"]function_args = json.loads(tc.function["arguments"])function_args_str = ",".join([f"{k}={v}" for k, v in function_args.items()])diff --git a/letta/schemas/tool.py b/letta/schemas/tool.pyindex 5c38467e0..fe5c4cc9e 100644--- a/letta/schemas/tool.py+++ b/letta/schemas/tool.py@@ -8,7 +8,6 @@ from letta.functions.helpers import generate_composio_tool_wrapper, generate_lanfrom letta.functions.schema_generator import generate_schema_from_args_schema_v2from letta.orm.enums import ToolTypefrom letta.schemas.letta_base import LettaBase-from letta.schemas.openai.chat_completions import ToolCallclass BaseTool(LettaBase):@@ -32,7 +31,6 @@ class Tool(BaseTool):tool_type: ToolType = Field(ToolType.CUSTOM, description="The type of the tool.")description: Optional[str] = Field(None, description="The description of the tool.")source_type: Optional[str] = Field(None, description="The type of the source code.")- module: Optional[str] = Field(None, description="The module of the function.")organization_id: Optional[str] = Field(None, description="The unique identifier of the organization associated with the tool.")name: Optional[str] = Field(None, description="The name of the function.")tags: List[str] = Field([], description="Metadata tags.")@@ -81,24 +79,11 @@ class Tool(BaseTool):return self- def to_dict(self):- """- Convert tool into OpenAI representation.- """- return vars(- ToolCall(- tool_id=self.id,- tool_call_type="function",- function=self.module,- )- )-class ToolCreate(LettaBase):name: Optional[str] = Field(None, description="The name of the function (auto-generated from source_code if not provided).")description: Optional[str] = Field(None, description="The description of the tool.")tags: List[str] = Field([], description="Metadata tags.")- module: Optional[str] = Field(None, description="The source code of the function.")source_code: str = Field(..., description="The source code of the function.")source_type: str = Field("python", description="The source type of the function.")json_schema: Optional[Dict] = Field(@@ -212,7 +197,6 @@ class ToolUpdate(LettaBase):description: Optional[str] = Field(None, description="The description of the tool.")name: Optional[str] = Field(None, description="The name of the function.")tags: Optional[List[str]] = Field(None, description="Metadata tags.")- module: Optional[str] = Field(None, description="The source code of the function.")source_code: Optional[str] = Field(None, description="The source code of the function.")source_type: Optional[str] = Field(None, description="The type of the source code.")json_schema: Optional[Dict] = Field(diff --git a/letta/services/tool_manager.py b/letta/services/tool_manager.pyindex 1992f2134..f2672d962 100644--- a/letta/services/tool_manager.py+++ b/letta/services/tool_manager.py@@ -39,7 +39,7 @@ class ToolManager:tool = self.get_tool_by_name(tool_name=pydantic_tool.name, actor=actor)if tool:# Put to dict and remove fields that should not be reset- update_data = pydantic_tool.model_dump(exclude={"module"}, exclude_unset=True, exclude_none=True)+ update_data = pydantic_tool.model_dump(exclude_unset=True, exclude_none=True)# If there's anything to updateif update_data:diff --git a/tests/test_v1_routes.py b/tests/test_v1_routes.pyindex 7d0e65e32..b39ae8496 100644--- a/tests/test_v1_routes.py+++ b/tests/test_v1_routes.py@@ -49,7 +49,6 @@ def create_integers_tool(add_integers_tool):name=add_integers_tool.name,description=add_integers_tool.description,tags=add_integers_tool.tags,- module=add_integers_tool.module,source_code=add_integers_tool.source_code,source_type=add_integers_tool.source_type,json_schema=add_integers_tool.json_schema,@@ -63,7 +62,6 @@ def update_integers_tool(add_integers_tool):name=add_integers_tool.name,description=add_integers_tool.description,tags=add_integers_tool.tags,- module=add_integers_tool.module,source_code=add_integers_tool.source_code,source_type=add_integers_tool.source_type,json_schema=add_integers_tool.json_schema,