Skip to content

fix(docker): auto-mount host CWD to /workspace#1504

Closed
Bartok9 wants to merge 2 commits into
NousResearch:mainfrom
Bartok9:fix/1445-docker-auto-mount-cwd
Closed

fix(docker): auto-mount host CWD to /workspace#1504
Bartok9 wants to merge 2 commits into
NousResearch:mainfrom
Bartok9:fix/1445-docker-auto-mount-cwd

Conversation

@Bartok9

@Bartok9 Bartok9 commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1445 — When using Docker backend, the user's current working directory is now automatically bind-mounted to /workspace inside the container.

Problem

Users running hermes from their project directory expected their files to be accessible inside the Docker container. Instead, /workspace was either:

  • Empty tmpfs (non-persistent mode)
  • Empty sandbox directory (persistent mode)

The user had to manually configure docker_volumes to mount their directory, which was unintuitive.

Solution

Automatically mount the host's current working directory to /workspace when:

  • Docker backend is selected
  • host_cwd is a valid directory
  • /workspace is not already mounted by user config or persistent mode

New Parameters

DockerEnvironment(
    host_cwd="/path/to/user/project",  # Auto-mount this to /workspace
    auto_mount_cwd=True,                # Enable/disable (default: True)
)

Opt-out

Set TERMINAL_DOCKER_NO_AUTO_MOUNT=true to disable auto-mounting if you prefer the isolated sandbox behavior.

Changes

  • tools/environments/docker.py: Add host_cwd and auto_mount_cwd parameters, auto-mount logic
  • tools/terminal_tool.py: Capture host_cwd in config, pass to _create_environment()
  • tests/tools/test_docker_environment.py: Add tests for auto-mount behavior
  • website/docs/user-guide/configuration.md: Document the feature

Test plan

python3 -m py_compile tools/environments/docker.py tools/terminal_tool.py
python3 -m pytest tests/tools/test_docker_environment.py -v

User Experience

Before:

cd ~/my-project
hermes
> ls /workspace
# (empty)

After:

cd ~/my-project
hermes
> ls /workspace
README.md  src/  tests/  # User's actual project files

Fixes NousResearch#1445 — When using Docker backend, the user's current working
directory is now automatically bind-mounted to /workspace inside the
container. This allows users to run `cd my-project && hermes` and have
their project files accessible to the agent without manual volume config.

Changes:
- Add host_cwd and auto_mount_cwd parameters to DockerEnvironment
- Capture original host CWD in _get_env_config() before container fallback
- Pass host_cwd through _create_environment() to Docker backend
- Add TERMINAL_DOCKER_NO_AUTO_MOUNT env var to disable if needed
- Skip auto-mount when /workspace is already explicitly mounted
- Add tests for auto-mount behavior
- Add documentation for the new feature

The auto-mount is skipped when:
1. TERMINAL_DOCKER_NO_AUTO_MOUNT=true is set
2. User configured docker_volumes with :/workspace
3. persistent_filesystem=true (persistent sandbox mode)

This makes the Docker backend behave more intuitively — the agent
operates on the user's actual project directory by default.
The auto-mount tests require minisweagent to be available for mocking.
In CI environments where the git submodule isn't initialized, these tests
would fail with ModuleNotFoundError.

This follows the pattern used by test_modal_sandbox_fixes.py for checking
minisweagent availability before running tests that depend on it.
@teknium1

Copy link
Copy Markdown
Contributor

Superseded by PR #1534 (merged), which implements CWD workspace mounting as explicit opt-in rather than auto-mount by default. Thanks for the contribution!

@teknium1 teknium1 closed this Mar 17, 2026
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.

[Bug]: Hermes does not map current directory into docker backend automatically.

3 participants