Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions openhands/runtime/action_execution_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from openhands.runtime.mcp.proxy import MCPProxyManager
from openhands.runtime.plugins import ALL_PLUGINS, JupyterPlugin, Plugin, VSCodePlugin
from openhands.runtime.utils import find_available_tcp_port
from openhands.runtime.utils.bash import BashSession
from openhands.runtime.utils.efficient_bash import ThreadedEfficientBashSession
from openhands.runtime.utils.files import insert_lines, read_lines
from openhands.runtime.utils.memory_monitor import MemoryMonitor
from openhands.runtime.utils.runtime_init import init_user_and_working_directory
Expand Down Expand Up @@ -187,7 +187,7 @@ def __init__(
if _updated_user_id is not None:
self.user_id = _updated_user_id

self.bash_session: BashSession | 'WindowsPowershellSession' | None = None # type: ignore[name-defined]
self.bash_session: ThreadedEfficientBashSession | 'WindowsPowershellSession' | None = None # type: ignore[name-defined]
self.lock = asyncio.Lock()
self.plugins: dict[str, Plugin] = {}
self.file_editor = OHEditor(workspace_root=self._initial_cwd)
Expand Down Expand Up @@ -277,7 +277,7 @@ def _create_bash_session(self, cwd: str | None = None):
max_memory_mb=self.max_memory_gb * 1024 if self.max_memory_gb else None,
)
else:
bash_session = BashSession(
bash_session = ThreadedEfficientBashSession(
work_dir=cwd or self._initial_cwd,
username=self.username,
no_change_timeout_seconds=int(
Expand Down Expand Up @@ -390,7 +390,10 @@ async def run(
if action.is_static:
bash_session = self._create_bash_session(action.cwd)
assert bash_session is not None
obs = await call_sync_from_async(bash_session.execute, action)
execute_fn = getattr(bash_session, 'execute_sync', None)
if execute_fn is None:
execute_fn = bash_session.execute
obs = await call_sync_from_async(execute_fn, action)
return obs
except Exception as e:
logger.exception(f'Error running command: {e}')
Expand Down
2 changes: 1 addition & 1 deletion openhands/runtime/utils/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import bashlex
import libtmux

from openhands.core.logger import openhands_logger as logger
from openhands.events.action import CmdRunAction
from openhands.events.observation import ErrorObservation
Expand All @@ -28,6 +27,7 @@
'y',
'on',
)
BASH_BACKEND = os.getenv('OPENHANDS_BASH_BACKEND', 'tmux').lower()


def split_bash_commands(commands: str) -> list[str]:
Expand Down
Loading
Loading