Skip to content

Conversation

@SmartManoj
Copy link
Contributor

@SmartManoj SmartManoj commented Nov 4, 2025

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.

image

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 xingyaoww requested a review from ryanhoangt November 4, 2025 15:42
Copy link
Collaborator

@xingyaoww xingyaoww left a 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.
@SmartManoj
Copy link
Contributor Author

image

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.
@xingyaoww
Copy link
Collaborator

@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.
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Nov 10, 2025

[Automatic Post]: This PR seems to be currently waiting for review. @ryanhoangt, could you please take a look when you have a chance?

@SmartManoj SmartManoj requested a review from xingyaoww November 15, 2025 11:12
Copy link
Collaborator

@ryanhoangt ryanhoangt left a 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
Copy link
Collaborator

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.

Copy link
Contributor Author

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":
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@SmartManoj
Copy link
Contributor Author

SmartManoj commented Nov 17, 2025

I saw it first attempted to run a bash command

Does this tool description need to be updated?

TOOL_DESCRIPTION = """Execute a bash command in the terminal within a persistent shell session.

@xingyaoww
Copy link
Collaborator

@SmartManoj

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.
@SmartManoj
Copy link
Contributor Author

image

@ryanhoangt ryanhoangt self-requested a review November 18, 2025 14:36
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Dec 18, 2025

[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.

@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Dec 27, 2025

[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.

@neubig
Copy link
Contributor

neubig commented Dec 28, 2025

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.
@all-hands-bot
Copy link
Collaborator

[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.
@enyst
Copy link
Collaborator

enyst commented Jan 3, 2026

@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.

@openhands-ai
Copy link

openhands-ai bot commented Jan 3, 2026

I'm on it! enyst can track my progress at all-hands.dev

@openhands-ai
Copy link

openhands-ai bot commented Jan 3, 2026

Final summary (since the last update)

✅ Request coverage checklist

  • Merged upstream origin/main into the PR branch terminal
  • Resolved the merge conflict(s)
  • Committed the merge with the required Co-authored-by: openhands <openhands@all-hands.dev>
  • Pushed the merge to the fork remote (PR is from SmartManoj/OpenHands-SDK)
  • Verified working tree is clean (git status shows no pending changes)

Changes introduced by the merge

  • Created merge commit: 4cd331b2 on branch terminal
  • Resolved one conflict by accepting upstream deletion of:
    • tests/agent_server/test_openapi_no_duplicates.py (deleted in origin/main, removed in the merge)

Conciseness check

  • git diff is empty locally after the merge (no extra/uncommitted changes)
  • Only conflict resolution needed for the merge was applied; no unrelated edits were introduced.

Push status

  • Already pushed to the correct remote/branch:
    • fork/terminal updated to include merge commit 4cd331b2

View full conversation

@neubig neubig requested review from neubig and removed request for enyst, ryanhoangt and xingyaoww January 8, 2026 12:47
@neubig
Copy link
Contributor

neubig commented Jan 8, 2026

I'll take reviewing on this one since I'll have a windows machine soon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants