Skip to content

fix(gateway): don't clobber resolved TERMINAL_CWD with raw config value#4673

Closed
HenkDz wants to merge 1 commit into
NousResearch:mainfrom
HenkDz:fix/gateway-cwd-clobber
Closed

fix(gateway): don't clobber resolved TERMINAL_CWD with raw config value#4673
HenkDz wants to merge 1 commit into
NousResearch:mainfrom
HenkDz:fix/gateway-cwd-clobber

Conversation

@HenkDz

@HenkDz HenkDz commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4672

When cli.py resolves terminal.cwd: "." to os.getcwd() and sets TERMINAL_CWD to the absolute path, gateway/run.py is later imported as a plugin and its module-level config bridging code re-reads the raw "." from config.yaml, overwriting the resolved value. The subsequent fallback logic then defaults to Path.home().

This causes the terminal to always open in $HOME instead of the directory where hermes was launched.

Change

In gateway/run.py, skip setting cwd in the terminal env bridge when TERMINAL_CWD is already set to an absolute path:

if _cfg_key == "cwd" and os.path.isabs(os.environ.get(_env_var, "")):
    continue

When cli.py imports, it resolves terminal.cwd='.' to os.getcwd() and
sets TERMINAL_CWD to the absolute path. But gateway/run.py is later
imported as a plugin, and its module-level config bridging code
re-reads the raw '.' from config.yaml and overwrites TERMINAL_CWD.
The subsequent fallback logic (line 208-211) then treats '.' as
unresolved and defaults to Path.home().

This causes the terminal to always open in $HOME instead of the
directory where hermes was launched.

Fix: skip setting cwd in the terminal env bridge when TERMINAL_CWD
is already set to an absolute path.
@HenkDz

HenkDz commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by combined fix in #4731 — covers both #4669 and #4672.

@HenkDz HenkDz closed this Apr 3, 2026
malaiwah added a commit to malaiwah/hermes-agent that referenced this pull request Apr 5, 2026
…ge config and invalid workdir bypass

- PR NousResearch#4350: Load config.yaml terminal block as fallback before hardcoded defaults
  - Fixes docker_image in config.yaml not being loaded
  - Adds cfg.get() fallbacks for all terminal config options

- PR NousResearch#4673: Don't clobber already-resolved absolute TERMINAL_CWD
  - Fixes invalid workdir bypassing terminal.cwd config
  - Skips config override when env var already has absolute path
malaiwah added a commit to malaiwah/hermes-agent that referenced this pull request Apr 11, 2026
…ge config and invalid workdir bypass

- PR NousResearch#4350: Load config.yaml terminal block as fallback before hardcoded defaults
  - Fixes docker_image in config.yaml not being loaded
  - Adds cfg.get() fallbacks for all terminal config options

- PR NousResearch#4673: Don't clobber already-resolved absolute TERMINAL_CWD
  - Fixes invalid workdir bypassing terminal.cwd config
  - Skips config override when env var already has absolute path
@HenkDz HenkDz deleted the fix/gateway-cwd-clobber branch April 15, 2026 21:20
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.

gateway/run.py clobbers resolved TERMINAL_CWD with raw config value '.'

1 participant