🙌 OpenHands: AI-Driven Development
fix: Handle invalid exit code conversion (#1915)
மனோஜ்குமார் பழனிச்சாமி4612e107c915
diff --git a/opendevin/controller/agent_controller.py b/opendevin/controller/agent_controller.pyindex 611e73a437..08da45a21f 100644--- a/opendevin/controller/agent_controller.py+++ b/opendevin/controller/agent_controller.py@@ -1,4 +1,5 @@import asyncio+import tracebackfrom typing import Optional, Typefrom opendevin.controller.agent import Agent@@ -109,6 +110,7 @@ class AgentController:logger.info('AgentController task was cancelled')breakexcept Exception as e:+ traceback.print_exc()logger.error(f'Error while running the agent: {e}')await self.report_error('There was an unexpected error while running the agent', exception=ediff --git a/opendevin/runtime/docker/ssh_box.py b/opendevin/runtime/docker/ssh_box.pyindex dd50c38ad3..9cab6ae458 100644--- a/opendevin/runtime/docker/ssh_box.py+++ b/opendevin/runtime/docker/ssh_box.py@@ -474,9 +474,15 @@ class DockerSSHBox(Sandbox):return self._send_interrupt(cmd, command_output, ignore_last_output=True)- exit_code = int(- exit_code_str.replace('echo $?', '').replace('\r\n', '').strip()- )+ cleaned_exit_code_str = exit_code_str.replace('echo $?', '').strip()++ try:+ exit_code = int(cleaned_exit_code_str)+ except ValueError:+ logger.error(f'Invalid exit code: {cleaned_exit_code_str}')+ # Handle the invalid exit code appropriately (e.g., raise an exception or set a default value)+ exit_code = -1 # or some other appropriate default value+return exit_code, command_outputdef copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):