diff options
| author | anj-s <[email protected]> | 2025-06-03 08:59:17 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-03 08:59:17 -0700 |
| commit | fffa06f0b119dfb075ced415a08c517d63dc1953 (patch) | |
| tree | 09656d53ea4f37a4565f46322312f6f4a797262b /packages/core/src/tools/edit.ts | |
| parent | e9d43b938833f239489a4ff8c70e2701bf178211 (diff) | |
Modify shortenPath and add param validation (#663)
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 5 |
1 files changed, 5 insertions, 0 deletions
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}`; } |
