mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Fix host CWD leaking into non-local terminal backends
When using Modal, Docker, SSH, or Singularity as the terminal backend from the CLI, the agent resolved cwd: "." to the host machine's local path (e.g. /Users/rewbs/code/hermes-agent) and passed it to the remote sandbox, where it doesn't exist. All commands failed with "No such file or directory". Root cause: cli.py unconditionally resolved "." to os.getcwd() and wrote it to TERMINAL_CWD regardless of backend type. Every tool then used that host-local path as the working directory inside the remote environment. Fixes: - cli.py: only resolve "." to os.getcwd() for the local backend. For all remote backends (ssh, docker, modal, singularity), leave TERMINAL_CWD unset so the tool layer uses per-backend defaults (/root, /, ~, etc.) - terminal_tool.py: added sanity check -- if TERMINAL_CWD contains a host-local prefix (/Users/, /home/, C:\) for a non-local backend, log a warning and fall back to the backend's default - terminal_tool.py: SSH default CWD is now ~ instead of os.getcwd() - file_operations.py: last-resort CWD fallback changed from os.getcwd() to "/" so host paths never leak into remote file operations
This commit is contained in:
parent
2c7deb41f6
commit
c33feb6dc9
3 changed files with 41 additions and 9 deletions
|
|
@ -257,9 +257,12 @@ class ShellFileOperations(FileOperations):
|
|||
cwd: Working directory (defaults to env's cwd or current directory)
|
||||
"""
|
||||
self.env = terminal_env
|
||||
# Determine cwd from various possible sources
|
||||
# Determine cwd from various possible sources.
|
||||
# IMPORTANT: do NOT fall back to os.getcwd() -- that's the HOST's local
|
||||
# path which doesn't exist inside container/cloud backends (modal, docker).
|
||||
# If nothing provides a cwd, use "/" as a safe universal default.
|
||||
self.cwd = cwd or getattr(terminal_env, 'cwd', None) or \
|
||||
getattr(getattr(terminal_env, 'config', None), 'cwd', None) or os.getcwd()
|
||||
getattr(getattr(terminal_env, 'config', None), 'cwd', None) or "/"
|
||||
|
||||
# Cache for command availability checks
|
||||
self._command_cache: Dict[str, bool] = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue