fix: Handle invalid exit code conversion (#1915)

This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி
2024-05-20 21:00:52 +05:30
committed by GitHub
parent 1bc1d306bd
commit 4612e107c9
2 changed files with 11 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import asyncio
import traceback
from typing import Optional, Type
from opendevin.controller.agent import Agent
@@ -109,6 +110,7 @@ class AgentController:
logger.info('AgentController task was cancelled')
break
except 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=e

View File

@@ -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_output
def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):