Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
Shelley/let 7218 editor should be compatible with typescript [LET-7218] (#9087)
Shelley Pham5dc70e48eb17
diff --git a/dev-compose.yaml b/dev-compose.yamlindex 81d084786..c1127aa02 100644--- a/dev-compose.yaml+++ b/dev-compose.yaml@@ -14,7 +14,7 @@ services:- ./.persist/pgdata-test:/var/lib/postgresql/data- ./init.sql:/docker-entrypoint-initdb.d/init.sqlports:- - "5432:5432"+ - '5432:5432'letta_server:image: letta/letta:latesthostname: letta@@ -25,8 +25,8 @@ services:depends_on:- letta_dbports:- - "8083:8083"- - "8283:8283"+ - '8083:8083'+ - '8283:8283'environment:- LETTA_PG_DB=${LETTA_PG_DB:-letta}- LETTA_PG_USER=${LETTA_PG_USER:-letta}diff --git a/letta/services/tool_manager.py b/letta/services/tool_manager.pyindex f243580bc..0b46d2e90 100644--- a/letta/services/tool_manager.py+++ b/letta/services/tool_manager.py@@ -944,13 +944,28 @@ class ToolManager:# Track if we need to check name uniqueness (check is done inside session with lock)needs_name_conflict_check = new_name != current_tool.name- # NOTE: EXTREMELEY HACKY, we need to stop making assumptions about the source_code- if "source_code" in update_data and f"def {new_name}" not in update_data.get("source_code", ""):- raise LettaToolNameSchemaMismatchError(- tool_name=new_name,- json_schema_name=new_schema.get("name") if new_schema else None,- source_code=update_data.get("source_code"),- )+ # Definitive checker for source code type+ if "source_code" in update_data:+ source_code = update_data.get("source_code", "")+ source_type = update_data.get("source_type", current_tool.source_type)++ # Check for function name based on source type+ if source_type == "typescript":+ # TypeScript: check for "function name" or "export function name"+ if f"function {new_name}" not in source_code:+ raise LettaToolNameSchemaMismatchError(+ tool_name=new_name,+ json_schema_name=new_schema.get("name") if new_schema else None,+ source_code=source_code,+ )+ else:+ # Python: check for "def name"+ if f"def {new_name}" not in source_code:+ raise LettaToolNameSchemaMismatchError(+ tool_name=new_name,+ json_schema_name=new_schema.get("name") if new_schema else None,+ source_code=source_code,+ )# Create a preview of the updated tool by merging current tool with updates# This allows us to compute the hash before the database session