feat(edit): Prevent no-op edits (#3520)

This commit is contained in:
Wen Sun
2025-07-22 06:24:02 +09:00
committed by GitHub
parent 1969d805f2
commit b4d00ab4fb
2 changed files with 18 additions and 0 deletions

View File

@@ -608,6 +608,19 @@ describe('EditTool', () => {
/User modified the `new_string` content/,
);
});
it('should return error if old_string and new_string are identical', async () => {
const initialContent = 'This is some identical text.';
fs.writeFileSync(filePath, initialContent, 'utf8');
const params: EditToolParams = {
file_path: filePath,
old_string: 'identical',
new_string: 'identical',
};
const result = await tool.execute(params, new AbortController().signal);
expect(result.llmContent).toMatch(/No changes to apply/);
expect(result.returnDisplay).toMatch(/No changes to apply/);
});
});
describe('getDescription', () => {