Skip to content

Add option to replaceAll occurances in multi_replace_string tool #268585

@bhavyaus

Description

@bhavyaus

Current Behavior
The multi_replace_string_tool currently fails when attempting to replace a string that appears multiple times in a file, throwing the error:

String replacement failed: Multiple matches found for the text to replace. Multiple exact matches found. Make your search string more specific.

Expected Behavior
When multiple occurrences are detected, the tool should provide clearer guidance and support the ability to replace all occurrences.


Proposed Solution
Add an optional replaceAll parameter to multi_replace_string_in_file tool

Improve error message: When multiple matches are found and replaceAll is not set, the error message should:
Suggest using replaceAll: true to replace all occurrences

Include line numbers where duplicates were found so the model can verify the edit is valid

Benefits
Reduces friction when making repetitive changes across a file
Provides actionable guidance instead of just failing

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions