diff options
| author | Tim Rogers <[email protected]> | 2025-06-29 20:53:59 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-29 19:53:59 +0000 |
| commit | dbe63e7234b0ea2577f84aab774ef011d300745f (patch) | |
| tree | ff8ab733d08a4d75002ab58ef77d8530ce3da6c5 /packages/core/src/tools/edit.ts | |
| parent | 0cfaeedf03f73f427c74184cb08b6779c11bd7d3 (diff) | |
fix: Correct pluralization of the number of occurrences in `EditTool` tool errors (#2463)
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index 2515261d..1e04ab35 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -257,9 +257,12 @@ Expectation for required parameters: raw: `Failed to edit, 0 occurrences found for old_string in ${params.file_path}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${ReadFileTool.Name} tool to verify.`, }; } else if (occurrences !== expectedReplacements) { + const occurenceTerm = + expectedReplacements === 1 ? 'occurrence' : 'occurrences'; + error = { - display: `Failed to edit, expected ${expectedReplacements} occurrence(s) but found ${occurrences}.`, - raw: `Failed to edit, Expected ${expectedReplacements} occurrences but found ${occurrences} for old_string in file: ${params.file_path}`, + display: `Failed to edit, expected ${expectedReplacements} ${occurenceTerm} but found ${occurrences}.`, + raw: `Failed to edit, Expected ${expectedReplacements} ${occurenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`, }; } } else { |
