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]
Tools: Delete diff state if diff state fails
Kilian Lieret946a9fac2fa9
diff --git a/tools/diff_state/bin/_state_diff_state b/tools/diff_state/bin/_state_diff_stateindex 05a77367..db7d3b8b 100644--- a/tools/diff_state/bin/_state_diff_state+++ b/tools/diff_state/bin/_state_diff_state@@ -1,15 +1,13 @@#!/usr/bin/env python3-import json-import os-from pathlib import Path-import subprocess---from registry import registry+def main() -> None:+ import json+ import os+ from pathlib import Path+ import subprocess+ from registry import registry-def main() -> None:state_path = Path("/root/state.json")if state_path.exists():state = json.loads(state_path.read_text())@@ -34,5 +32,21 @@ def main() -> None:state_path.write_text(json.dumps(state))+def _del_diff():+ from pathlib import Path+ import json++ state_path = Path("/root/state.json")+ if state_path.exists():+ state = json.loads(state_path.read_text())+ else:+ state = {}+ state["diff"] = ""+ state_path.write_text(json.dumps(state))++if __name__ == "__main__":- main()+ try:+ main()+ except Exception as e:+ _del_diff()\ No newline at end of file