mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Additional logs to debug container working directories (#10902)
Co-authored-by: Chuck Butkus <chuck@all-hands.dev>
This commit is contained in:
@@ -358,6 +358,11 @@ class ActionExecutor:
|
||||
|
||||
INIT_COMMANDS.append(no_pager_cmd)
|
||||
|
||||
# Hack: for some reason when you set the openhands user to anything but root, tmux changes out
|
||||
# of the mount directory on the first invocation.
|
||||
if self.user_id != 0:
|
||||
INIT_COMMANDS.append(f'cd {self._initial_cwd}')
|
||||
|
||||
logger.info(f'Initializing by running {len(INIT_COMMANDS)} bash commands...')
|
||||
for command in INIT_COMMANDS:
|
||||
action = CmdRunAction(command=command)
|
||||
|
||||
@@ -206,7 +206,9 @@ class BashSession:
|
||||
# else:
|
||||
window_command = _shell_command
|
||||
|
||||
logger.debug(f'Initializing bash session with command: {window_command}')
|
||||
logger.debug(
|
||||
f'Initializing bash session in {self.work_dir} with command: {window_command}'
|
||||
)
|
||||
session_name = f'openhands-{self.username}-{uuid.uuid4()}'
|
||||
self.session = self.server.new_session(
|
||||
session_name=session_name,
|
||||
@@ -331,6 +333,9 @@ class BashSession:
|
||||
|
||||
# Update the current working directory if it has changed
|
||||
if metadata.working_dir != self._cwd and metadata.working_dir:
|
||||
logger.debug(
|
||||
f'directory_changed: {self._cwd}; {metadata.working_dir}; {command}'
|
||||
)
|
||||
self._cwd = metadata.working_dir
|
||||
|
||||
logger.debug(f'COMMAND OUTPUT: {pane_content}')
|
||||
@@ -598,8 +603,12 @@ class BashSession:
|
||||
logger.debug(
|
||||
f'PANE CONTENT GOT after {time.time() - _start_time:.2f} seconds'
|
||||
)
|
||||
logger.debug(f'BEGIN OF PANE CONTENT: {cur_pane_output.split("\n")[:10]}')
|
||||
logger.debug(f'END OF PANE CONTENT: {cur_pane_output.split("\n")[-10:]}')
|
||||
cur_pane_lines = cur_pane_output.split('\n')
|
||||
if len(cur_pane_lines) <= 20:
|
||||
logger.debug('PANE_CONTENT: {cur_pane_output}')
|
||||
else:
|
||||
logger.debug(f'BEGIN OF PANE CONTENT: {cur_pane_lines[:10]}')
|
||||
logger.debug(f'END OF PANE CONTENT: {cur_pane_lines[-10:]}')
|
||||
ps1_matches = CmdOutputMetadata.matches_ps1_metadata(cur_pane_output)
|
||||
current_ps1_count = len(ps1_matches)
|
||||
|
||||
|
||||
@@ -567,7 +567,8 @@ class DockerNestedConversationManager(ConversationManager):
|
||||
env_vars['SERVE_FRONTEND'] = '0'
|
||||
env_vars['RUNTIME'] = 'local'
|
||||
# TODO: In the long term we may come up with a more secure strategy for user management within the nested runtime.
|
||||
env_vars['USER'] = 'root'
|
||||
env_vars['USER'] = 'openhands' if config.run_as_openhands else 'root'
|
||||
env_vars['SANDBOX_USER_ID'] = str(config.sandbox.user_id)
|
||||
env_vars['SESSION_API_KEY'] = self._get_session_api_key_for_conversation(sid)
|
||||
# We need to be able to specify the nested conversation id within the nested runtime
|
||||
env_vars['ALLOW_SET_CONVERSATION_ID'] = '1'
|
||||
|
||||
Reference in New Issue
Block a user