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]

Enh: Show commands when encountering timeout error (#582)

Kilian Liereted95cf1f260e
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index 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)
+ raise
self.returncode = int(exit_code)
return buffer
diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.py
index 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_duration
try:
data = os.read(fd, 4096)
except BlockingIOError:
+ logger.error("BlockingIOError while reading from subprocess.", exc_info=True)
break
if data:
buffer += data