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: Ensure state exists (#1065)

Kilian Lieretfbf258ce48a0
diff --git a/sweagent/tools/tools.py b/sweagent/tools/tools.py
index 50046fec..982eb336 100644
--- a/sweagent/tools/tools.py
+++ b/sweagent/tools/tools.py
@@ -207,6 +207,7 @@ class ToolHandler:
self.logger.info("Resetting tools")
env.set_env_variables(self.config.env_variables)
env.write_file("/root/.swe-agent-env", json.dumps(self.config.registry_variables))
+ env.write_file("/root/state.json", "{}")
env.communicate(" && ".join(self._reset_commands), check="raise", timeout=self.config.install_timeout)
async def _upload_bundles(self, env: SWEEnv) -> None:
diff --git a/tools/defaults/install.sh b/tools/defaults/install.sh
index cc3175dd..c771869a 100644
--- a/tools/defaults/install.sh
+++ b/tools/defaults/install.sh
@@ -12,6 +12,4 @@ _write_env "FIRST_LINE" "${FIRST_LINE:-0}"
_write_env "CURRENT_FILE" "${CURRENT_FILE:-}"
# install jq
-# apt-get update && apt-get install -y jq
-
-echo "{}" > /root/state.json
\ No newline at end of file
+# apt-get update && apt-get install -y jq
\ No newline at end of file
diff --git a/tools/edit_anthropic/install.sh b/tools/edit_anthropic/install.sh
index 34e11990..ba402655 100644
--- a/tools/edit_anthropic/install.sh
+++ b/tools/edit_anthropic/install.sh
@@ -1,3 +1,2 @@
pip install 'tree-sitter==0.21.3'
-pip install 'tree-sitter-languages'
-echo "{}" > /root/state.json
+pip install 'tree-sitter-languages'
\ No newline at end of file