fix(local): respect configured cwd in init_session()#12983
Closed
WuTianyi123 wants to merge 1 commit into
Closed
Conversation
LocalEnvironment._run_bash() spawned subprocess.Popen without a cwd argument, so init_session()'s pwd -P ran in the gateway process's startup directory and overwrote self.cwd. Pass cwd=self.cwd so the initial snapshot captures the user-configured working directory. Tested: - pytest tests/ -q (255 env-related tests passed) - Full suite: 13,537 passed; 70 pre-existing failures unrelated to local env
1 task
Collaborator
|
Likely duplicate of #9798 — same root cause: local terminal init_session() ignores configured cwd. |
1 similar comment
Collaborator
|
Likely duplicate of #9798 — same root cause: local terminal init_session() ignores configured cwd. |
Contributor
|
Thanks @WuTianyi123! Your fix was cherry-picked and merged via #14242. Your original commit email was an unlinked gmail, so we re-authored to your GitHub noreply email so the contribution attributes to your profile. |
This was referenced Apr 24, 2026
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.
What does this PR do?
LocalEnvironment._run_bash()spawnssubprocess.Popen()without acwdargument. This causesinit_session()— which runspwd -Pto capture the initial working directory — to execute in the gateway process's startup directory instead of the user-configuredterminal.cwd. The result is then written back toself.cwd, silently overwriting the correct path.This PR adds
cwd=self.cwdto thesubprocess.Popen()call so the initial session snapshot correctly captures the working directory fromconfig.yaml'sterminal.cwdsetting.Related Issue
No existing issue filed, but this bug is reproducible by:
terminal.cwd: /some/absolute/pathinconfig.yaml~/.hermes/hermes-agent)pwdvia the terminal tool — it returns the gateway directory, not the configured oneType of Change
Changes Made
tools/environments/local.py: Addcwd=self.cwdtosubprocess.Popen()in_run_bash()(line 268)How to Test
Reproduce the bug (before this fix):
config.yaml, set:~/.hermes/hermes-agent)pwd— observe it returns~/.hermes/hermes-agentinstead of/tmp/test-workspaceVerify the fix (after this PR):
pwd— it now correctly returns/tmp/test-workspaceChecklist
Code
fix(local): ...)pytest tests/ -qand all tests pass (13,537 passed; 70 pre-existing failures unrelated to local env)Documentation & Housekeeping
cli-config.yaml.example— or N/ACONTRIBUTING.mdorAGENTS.md— or N/Acwdparameter is standardsubprocess.Popenbehavior, works on Windows/macOS/Linux