diff options
| author | Leo <[email protected]> | 2025-06-28 19:02:44 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-28 18:02:44 +0000 |
| commit | 601d9ba36d1c8f6d1e180a0c5cc1d5597906d33a (patch) | |
| tree | 4f34dfee0c6391a321b5a259957854ae2743cb3f /packages/core/src/tools/edit.ts | |
| parent | 3518ff766345ba98d90495b46c84439e6fc1a61c (diff) | |
fix edit retrigger (#2306)
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index ddb521be..2515261d 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -49,6 +49,11 @@ export interface EditToolParams { * Use when you want to replace multiple occurrences. */ expected_replacements?: number; + + /** + * Whether the edit was modified manually by the user. + */ + modified_by_user?: boolean; } interface CalculatedEdit { @@ -81,6 +86,8 @@ export class EditTool 'Edit', `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${ReadFileTool.Name} tool to examine the file's current content before attempting a text replacement. + The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response. + Expectation for required parameters: 1. \`file_path\` MUST be an absolute path; otherwise an error will be thrown. 2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.). @@ -414,12 +421,19 @@ Expectation for required parameters: displayResult = { fileDiff, fileName }; } - const llmSuccessMessage = editData.isNewFile - ? `Created new file: ${params.file_path} with provided content.` - : `Successfully modified file: ${params.file_path} (${editData.occurrences} replacements).`; + const llmSuccessMessageParts = [ + editData.isNewFile + ? `Created new file: ${params.file_path} with provided content.` + : `Successfully modified file: ${params.file_path} (${editData.occurrences} replacements).`, + ]; + if (params.modified_by_user) { + llmSuccessMessageParts.push( + `User modified the \`new_string\` content to be: ${params.new_string}.`, + ); + } return { - llmContent: llmSuccessMessage, + llmContent: llmSuccessMessageParts.join(' '), returnDisplay: displayResult, }; } catch (error) { @@ -474,6 +488,7 @@ Expectation for required parameters: ...originalParams, old_string: oldContent, new_string: modifiedProposedContent, + modified_by_user: true, }), }; } |
