From 5dc70e48eb17144397337d304ce2a0f8bdf5d68c Mon Sep 17 00:00:00 2001 From: Shelley Pham Date: Mon, 26 Jan 2026 16:19:52 -0800 Subject: [PATCH] Shelley/let 7218 editor should be compatible with typescript [LET-7218] (#9087) * fix python icon not showing up * make typescript compatible for updating tools in typescript * Update flags.ts * display tools properly in navigation * add default json schema to newly created tools * add typescript to code editor * make editor typescript compatible * Update ToolsEditor.tsx * typescript ocmpatible editor * sandbox stuff * update breadcrumb icon * pass in source type to tool simulator * undo * Update tool-editor.cy.ts --- dev-compose.yaml | 6 +++--- letta/services/tool_manager.py | 29 ++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dev-compose.yaml b/dev-compose.yaml index 81d08478..c1127aa0 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.sql ports: - - "5432:5432" + - '5432:5432' letta_server: image: letta/letta:latest hostname: letta @@ -25,8 +25,8 @@ services: depends_on: - letta_db ports: - - "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.py index f243580b..0b46d2e9 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