-
Notifications
You must be signed in to change notification settings - Fork 104
Add Windows terminal backend support #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Introduces WindowsTerminal for PowerShell-based command execution on Windows systems. Updates factory and init logic to conditionally import and use platform-specific terminal backends, ensuring compatibility across Windows and Unix-like platforms.
xingyaoww
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should rename the tool execute_bash into execute_terminal because of the powershell here? 🤔
And we tell the agent if it is using powershell vs bash. But we can do this in subsequent pr
Simplifies the code by unconditionally importing fcntl and pty, removing the platform-specific logic and dummy assignments for Windows. This module is intended for Unix-like systems only.
Deleted scripts/demo.py as it is no longer needed. The demo script previously demonstrated basic usage of the OpenHands SDK and agent setup.
Eliminated an erroneous 'n' character from the import block in terminal_session.py to clean up the code and prevent potential syntax errors.
Changed assertions in test_windows_terminal_close_and_reopen to check 'obs.text' instead of 'obs.output' for command results. This aligns the test with the updated observation object structure.
|
@SmartManoj can you resolve merge conflicts/ |
Update the terminal module's __init__.py to conditionally import WindowsTerminal on Windows and SubprocessTerminal/TmuxTerminal on other platforms. This change ensures only relevant terminal classes are exposed based on the operating system.
Removed the deprecated execute_bash.terminal package and updated all relevant imports to use the new openhands.tools.terminal.terminal structure. This change consolidates terminal-related code under a single module for improved maintainability and clarity.
|
[Automatic Post]: This PR seems to be currently waiting for review. @ryanhoangt, could you please take a look when you have a chance? |
ryanhoangt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. When testing the PR on the examples/01_hello_world.py and adjusting the message to something like "Please check the current directory, list all files and then exit.", I saw it first attempted to run a bash command with &&, which failed in PowerShell. However, it didn't fail instantly, it got stuck in soft timeout observation loop and the agent decided to reset the terminal. Do you have any ideas why it happened?
| ] | ||
| # Conditionally import platform-specific terminals | ||
| if platform.system() == "Windows": | ||
| from openhands.tools.terminal.terminal.windows_terminal import WindowsTerminal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we export things conditionally like this? I think it might break several test files like tests/tools/terminal/test_session_factory.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else, it will raise ModuleNotFoundError: No module named 'fcntl'
https://github.com/OpenHands/OpenHands/issues/11629
| logger.info("Using forced TmuxTerminal") | ||
| terminal = TmuxTerminal(work_dir, username) | ||
| return TerminalSession(terminal, no_change_timeout_seconds) | ||
| elif terminal_type == "subprocess": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since SubprocessTerminal depends on fcntl which isn't available on Windows, should we add a if platform.system() == "Windows": check here and raise RuntimeError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 86 will run only when terminal_type== "subprocess" is specified and None is the default value for that.
Does this tool description need to be updated?
|
Yes we should either phrase it so the description is general enough, OR we should implement a switch (i.e., only change the description if windows is selected as the terminal implementation) |
Introduces TOOL_DESCRIPTION_FOR_WINDOWS for PowerShell commands and updates TerminalTool to select the appropriate description based on the platform. This improves clarity and guidance for users on both Unix and Windows systems.
|
[Automatic Post]: It has been a while since there was any activity on this PR. @SmartManoj, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @SmartManoj, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
Hi @xingyaoww , @ryanhoangt , @enyst you all are assigned as reviewers here, are you still reviewing? If so, could you please complete the review? If you'd prefer someone else (e.g. me) to do it feel free to reassign. |
Eliminates duplicate passing of exit_code to TerminalObservation.from_text, ensuring exit_code is only provided once and simplifying the method call.
Added tests/tools/terminal/test_terminal_exit_code_top_level.py to the list of ignored tests in the Windows test workflow. This prevents the test from running on Windows CI, likely due to platform-specific issues.
|
[Automatic Post]: It has been a while since there was any activity on this PR. @SmartManoj, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
Added tests/tools/test_working_dir_standardization.py to the list of ignored tests in the Windows CI workflow to prevent it from running during automated test jobs.
Updates env_parser to inject the KIND environment variable into the parsed data for DiscriminatedUnionMixin types. Adjusts related tests to account for Pydantic validation errors when 'kind' is missing, and refines OpenAPI schema duplicate detection to allow expected Input/Output variants.
Introduces TypeVar T and updates from_env to use generic typing for improved type safety and inference. The function now returns type T, matching the input target_type.
Adds a check to ensure json_data is a dict before assigning the 'kind' key from the environment variable. This prevents potential errors if json_data is not a dictionary.
Update the test to also allow module-qualified schema names (with double underscores) as expected duplicates, in addition to Input/Output pairs. This prevents false positives when the same type appears from different modules.
Added generic type parameter to the from_env function in env_parser.py for better type hinting. Improved code formatting and readability in test_models.py and test_openapi_no_duplicates.py by splitting long lines and clarifying comments.
Reformatted the import of typing module components to use multi-line style for improved readability and consistency.
|
@OpenHands Merge origin main into this PR, fix the conflicts, and push the merge. Summarize what you did. Note that the PR is from a fork, so make sure you use the correct remote. |
|
I'm on it! enyst can track my progress at all-hands.dev |
…ds@all-hands.dev>
Final summary (since the last update)✅ Request coverage checklist
Changes introduced by the merge
Conciseness check
Push status
|
|
I'll take reviewing on this one since I'll have a windows machine soon. |


Introduces
WindowsTerminalfor PowerShell-based command execution on Windows systems. Updatesfactoryandinitlogic to conditionally import and use platform-specific terminal backends, ensuring compatibility across Windows and Unix-like platforms.