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]
Enh: Show commands when encountering timeout error (#582)
Kilian Liereted95cf1f260e
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex 929997c8..dd8acb37 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -644,7 +644,12 @@ class SWEEnv(gym.Env):msg = "Failed to communicate with container"raise RuntimeError(msg)- buffer, exit_code = read_with_timeout_experimental(self.container, timeout_duration)+ try:+ buffer, exit_code = read_with_timeout_experimental(self.container, timeout_duration)+ except Exception:+ msg = f"Read with timeout failed on input:\n---\n{input}\n---"+ self.logger.error(msg)+ raiseself.returncode = int(exit_code)return bufferdiff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex 07357f67..e14169ad 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -222,6 +222,7 @@ def read_with_timeout_experimental(container: subprocess.Popen, timeout_durationtry:data = os.read(fd, 4096)except BlockingIOError:+ logger.error("BlockingIOError while reading from subprocess.", exc_info=True)breakif data:buffer += data