From fffa06f0b119dfb075ced415a08c517d63dc1953 Mon Sep 17 00:00:00 2001 From: anj-s <32556631+anj-s@users.noreply.github.com> Date: Tue, 3 Jun 2025 08:59:17 -0700 Subject: Modify shortenPath and add param validation (#663) --- packages/core/src/tools/edit.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/core/src/tools') diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index 4a337faa..e02ee1c8 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -364,16 +364,21 @@ Expectation for required parameters: } getDescription(params: EditToolParams): string { + if (!params.file_path || !params.old_string || !params.new_string) { + return `Model did not provide valid parameters for edit tool`; + } const relativePath = makeRelative(params.file_path, this.rootDirectory); if (params.old_string === '') { return `Create ${shortenPath(relativePath)}`; } + const oldStringSnippet = params.old_string.split('\n')[0].substring(0, 30) + (params.old_string.length > 30 ? '...' : ''); const newStringSnippet = params.new_string.split('\n')[0].substring(0, 30) + (params.new_string.length > 30 ? '...' : ''); + return `${shortenPath(relativePath)}: ${oldStringSnippet} => ${newStringSnippet}`; } -- cgit v1.2.3