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: UnboundLocalError when catching decoding issue (#709)

Kilian Lieret1032274ab2b7
diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.py
index 6e1eff64..f7037c14 100644
--- a/sweagent/environment/utils.py
+++ b/sweagent/environment/utils.py
@@ -230,12 +230,14 @@ def read_with_timeout_experimental(container: subprocess.Popen, timeout_duration
try:
decoded = buffer.decode()
except UnicodeDecodeError:
+ # Should we reset the buffer to skip the byte that causes the error?
n_decode_failures += 1
if n_decode_failures > 30:
msg = "Too many decode failures while reading from subprocess."
raise RuntimeError(msg)
- if PROCESS_DONE_MARKER_START in decoded:
- break
+ else:
+ if PROCESS_DONE_MARKER_START in decoded:
+ break
time.sleep(0.01) # Prevents CPU hogging
if container.poll() is not None: