Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: Add flag to tools to signify if they are race safe [LET-5611] (#5548)
Matthew Zhouddd1686ad103
diff --git a/alembic/versions/e67961ed7c32_add_enable_parallel_execution_to_tools_table.py b/alembic/versions/e67961ed7c32_add_enable_parallel_execution_to_tools_table.pynew file mode 100644index 000000000..7300157c8--- /dev/null+++ b/alembic/versions/e67961ed7c32_add_enable_parallel_execution_to_tools_table.py@@ -0,0 +1,31 @@+"""Add enable_parallel_execution to Tools table++Revision ID: e67961ed7c32+Revises: 8149a781ac1b+Create Date: 2025-10-17 15:47:00.447066++"""++from typing import Sequence, Union++import sqlalchemy as sa++from alembic import op++# revision identifiers, used by Alembic.+revision: str = "e67961ed7c32"+down_revision: Union[str, None] = "8149a781ac1b"+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("tools", sa.Column("enable_parallel_execution", sa.Boolean(), nullable=True))+ # ### end Alembic commands ###+++def downgrade() -> None:+ # ### commands auto generated by Alembic - please adjust! ###+ op.drop_column("tools", "enable_parallel_execution")+ # ### end Alembic commands ###diff --git a/fern/openapi.json b/fern/openapi.jsonindex 3b06afedc..f27d49bee 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -17124,6 +17124,35 @@],"nullable": true},+ "enable_parallel_execution": {+ "oneOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string",+ "format": "null",+ "nullable": true+ },+ {+ "type": "array",+ "items": {+ "oneOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string",+ "format": "null",+ "nullable": true+ }+ ],+ "nullable": true+ }+ }+ ],+ "nullable": true+ },"created_by_id": {"oneOf": [{@@ -35728,6 +35757,19 @@"title": "Default Requires Approval","description": "Default value for whether or not executing this tool requires approval."},+ "enable_parallel_execution": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "title": "Enable Parallel Execution",+ "description": "If set to True, then this tool will potentially be executed concurrently with other tools. Default False.",+ "default": false+ },"created_by_id": {"anyOf": [{@@ -36203,6 +36245,19 @@],"title": "Default Requires Approval","description": "Whether or not to require approval before executing this tool."+ },+ "enable_parallel_execution": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "title": "Enable Parallel Execution",+ "description": "If set to True, then this tool will potentially be executed concurrently with other tools. Default False.",+ "default": false}},"additionalProperties": false,@@ -36746,6 +36801,19 @@],"title": "Default Requires Approval","description": "Whether or not to require approval before executing this tool."+ },+ "enable_parallel_execution": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "title": "Enable Parallel Execution",+ "description": "If set to True, then this tool will potentially be executed concurrently with other tools. Default False.",+ "default": false}},"type": "object",@@ -38897,6 +38965,19 @@"title": "Default Requires Approval","description": "Default value for whether or not executing this tool requires approval."},+ "enable_parallel_execution": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "title": "Enable Parallel Execution",+ "description": "If set to True, then this tool will potentially be executed concurrently with other tools. Default False.",+ "default": false+ },"created_by_id": {"anyOf": [{diff --git a/letta/orm/tool.py b/letta/orm/tool.pyindex e3bd90815..c6c8d823a 100644--- a/letta/orm/tool.py+++ b/letta/orm/tool.py@@ -50,6 +50,9 @@ class Tool(SqlalchemyBase, OrganizationMixin):)npm_requirements: Mapped[list | None] = mapped_column(JSON, doc="Optional list of npm packages required by this tool.")default_requires_approval: Mapped[bool] = mapped_column(nullable=True, doc="Whether or not to require approval.")+ enable_parallel_execution: Mapped[bool] = mapped_column(+ nullable=True, doc="If set to True, then this tool will potentially be executed concurrently with other tools. Default False."+ )metadata_: Mapped[Optional[dict]] = mapped_column(JSON, default=lambda: {}, doc="A dictionary of additional metadata for the tool.")# relationshipsorganization: Mapped["Organization"] = relationship("Organization", back_populates="tools", lazy="selectin")diff --git a/letta/schemas/tool.py b/letta/schemas/tool.pyindex 475c68cb2..746221921 100644--- a/letta/schemas/tool.py+++ b/letta/schemas/tool.py@@ -63,6 +63,9 @@ class Tool(BaseTool):default_requires_approval: Optional[bool] = Field(None, description="Default value for whether or not executing this tool requires approval.")+ enable_parallel_execution: Optional[bool] = Field(+ False, description="If set to True, then this tool will potentially be executed concurrently with other tools. Default False."+ )# metadata fieldscreated_by_id: Optional[str] = Field(None, description="The id of the user that made this Tool.")@@ -118,6 +121,9 @@ class ToolCreate(LettaBase):pip_requirements: list[PipRequirement] | None = Field(None, description="Optional list of pip packages required by this tool.")npm_requirements: list[NpmRequirement] | None = Field(None, description="Optional list of npm packages required by this tool.")default_requires_approval: Optional[bool] = Field(None, description="Whether or not to require approval before executing this tool.")+ enable_parallel_execution: Optional[bool] = Field(+ False, description="If set to True, then this tool will potentially be executed concurrently with other tools. Default False."+ )@classmethoddef from_mcp(cls, mcp_server_name: str, mcp_tool: MCPTool) -> "ToolCreate":@@ -173,6 +179,9 @@ class ToolUpdate(LettaBase):npm_requirements: list[NpmRequirement] | None = Field(None, description="Optional list of npm packages required by this tool.")metadata_: Optional[Dict[str, Any]] = Field(None, description="A dictionary of additional metadata for the tool.")default_requires_approval: Optional[bool] = Field(None, description="Whether or not to require approval before executing this tool.")+ enable_parallel_execution: Optional[bool] = Field(+ False, description="If set to True, then this tool will potentially be executed concurrently with other tools. Default False."+ )# name: Optional[str] = Field(None, description="The name of the tool (must match the JSON schema name and source code function name).")model_config = ConfigDict(extra="ignore") # Allows extra fields without validation errors