assistant2: Fail find-replace tool if both strings are equal (#27783)
Models seem to do this ever so often and get very confused. Failing here helps them recover. Release Notes: - N/A Co-authored-by: Richard Feldman <richard@zed.dev>
This commit is contained in:
parent
12c58d01bb
commit
e6c64ebf7e
2 changed files with 6 additions and 0 deletions
|
@ -182,6 +182,10 @@ impl Tool for FindReplaceFileTool {
|
|||
return Err(anyhow!("`find` string cannot be empty. Use a different tool if you want to create a file."));
|
||||
}
|
||||
|
||||
if input.find == input.replace {
|
||||
return Err(anyhow!("The `find` and `replace` strings are identical, so no changes would be made."));
|
||||
}
|
||||
|
||||
let result = cx
|
||||
.background_spawn(async move {
|
||||
replace_exact(&input.find, &input.replace, &snapshot).await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue