Repository navigation
Fix execute_bash tool to inherit environment variables from parent process - #245
Merged
Merged
Conversation
…ocess - Modified TmuxTerminal to pass environment variables to new_session() and new_window() - Added comprehensive test to verify environment variable inheritance from parent process - SubprocessTerminal already correctly inherited environment variables Fixes #243 Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
…nt inheritance - Added comment in SubprocessTerminal.initialize() to clarify environment variable inheritance - Added specific test for subprocess terminal environment inheritance - Both terminals now have clear documentation and comprehensive tests for environment variable inheritance Co-authored-by: openhands <openhands@all-hands.dev>
xingyaoww
commented
Sep 14, 2025
xingyaoww
enabled auto-merge (squash)
September 14, 2025 02:08
StressTestor
pushed a commit
to StressTestor/software-agent-sdk
that referenced
this pull request
Jun 1, 2026
…ocess (OpenHands#245) Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #243 -
execute_bashtool should be able to inherit current env varsProblem
Previously, when using the
execute_bashtool, environment variables set in the parent process (e.g.,export A=A) were not available in the new terminal session. This was because:new_session()andnew_window()calls didn't pass the parent environment variablesSolution
Changes Made
Modified TmuxTerminal (
openhands/tools/execute_bash/terminal/tmux_terminal.py):import osto access environment variablesenv = os.environ.copy()environment=envparameter to bothnew_session()andnew_window()callsAdded comprehensive test (
tests/tools/execute_bash/test_bash_session.py):test_environment_variable_inheritance_from_parent()Technical Details
The fix leverages the existing
environmentparameter support in thelibtmuxlibrary:libtmux.Server.new_session(environment=env)libtmux.Session.new_window(environment=env)SubprocessTerminal already correctly inherited environment variables via
subprocess.Popen(env=env)whereenv = os.environ.copy().Testing
Verification
You can now:
export TEST_VAR=helloecho $TEST_VARThis ensures that the execute_bash tool maintains the expected behavior of inheriting the parent process environment, making it more intuitive and consistent with standard shell behavior.
@xingyaoww can click here to continue refining the PR