mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix: Handle invalid exit code conversion (#1915)
This commit is contained in:
committed by
GitHub
parent
1bc1d306bd
commit
4612e107c9
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user