Skip to content

BashExecutor should fallback to local terminal when tmux is not available #87

Closed

Description

@malhotra5

Problem

The BashExecutor in openhands/tools/execute_bash/impl.py currently requires tmux to be installed on the local machine. When tmux is not available, it throws an unhelpful TmuxCommandNotFound exception that confuses users.

Current Error

When tmux is not installed, users see this error:

Traceback (most recent call last):
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/openhands_cli/agent_chat.py", line 74, in setup_agent
    bash = BashExecutor(working_dir=cwd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/openhands/tools/execute_bash/impl.py", line 14, in __init__
    self.session.initialize()
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/openhands/tools/execute_bash/bash_session.py", line 65, in initialize
    self.session = self.server.new_session(
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/libtmux/server.py", line 517, in new_session
    if self.has_session(session_name):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/libtmux/server.py", line 342, in has_session
    if exact and has_gte_version("2.1"):
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/libtmux/common.py", line 354, in has_gte_version
    return get_version() >= LooseVersion(min_version)
           ^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/libtmux/common.py", line 284, in get_version
    proc = tmux_cmd("-V")
           ^^^^^^^^^^^^^^
  File "/Users/rohitmalhotra/Documents/Openhands/OpenHands-CLI/.venv/lib/python3.12/site-packages/libtmux/common.py", line 225, in __init__
    raise exc.TmuxCommandNotFound
libtmux.exc.TmuxCommandNotFound

Proposed Solution

  1. Fallback to local terminal: When tmux is not installed, BashExecutor should automatically fallback to using the local terminal (or subprocess equivalent) instead of failing completely.

  2. User-friendly warning: When falling back to the local terminal, display a clear warning message to the user with instructions on how to install tmux locally for better functionality.

Requirements

  • Detect when tmux is not available (catch TmuxCommandNotFound or similar exceptions)
  • Implement a fallback mechanism using local terminal/subprocess
  • Display a warning message like: "Warning: tmux not found. Using local terminal instead. For better session management, install tmux: [installation instructions]"
  • Ensure the fallback works seamlessly without breaking existing functionality

Context

This issue was originally reported in the OpenHands-CLI repository but belongs in agent-sdk since the BashExecutor implementation is part of the openhands/tools package.

Original issue: OpenHands/OpenHands-CLI#14

Activity

  1. self-assigned this
    on Sep 3, 2025
  2. xingyaoww commented on Sep 5, 2025

    @xingyaoww
    Contributor

    Should solved by #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions