Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Fix(tools): Don't attempt to edit if repl strs are the same

Kilian Lieret248c485223c1
diff --git a/tools/edit_anthropic/bin/str_replace_editor b/tools/edit_anthropic/bin/str_replace_editor
index d28f1bfc..93d664b3 100644
--- a/tools/edit_anthropic/bin/str_replace_editor
+++ b/tools/edit_anthropic/bin/str_replace_editor
@@ -195,6 +195,10 @@ class EditTool:
)
sys.exit(16)
+ if new_str == old_str:
+ print(f"No replacement was performed, old_str `{old_str}` is the same as new_str `{new_str}`.")
+ sys.exit(161)
+
# Replace old_str with new_str
new_file_content = file_content.replace(old_str, new_str)