This page documents the execution environment backends that implement the common execute() interface defined in the environment abstraction layer. Each backend provides command execution in a different context: local machine, Docker containers, Singularity containers, Modal cloud sandboxes, remote SSH hosts, or Daytona workspaces.
For the common interface and lifecycle management (environment creation, cleanup, activity tracking), see 6.1 Environment Abstraction For details on command execution through the terminal tool and process management, see 5.2 Terminal and File Operations and 5.3 Process Management
Backend selection and configuration are controlled by environment variables and the ~/.hermes/config.yaml file. The TERMINAL_ENV environment variable or the configuration logic determines which backend is instantiated tools/terminal_tool.py9-13
The environment variable or config key controls which backend is instantiated:
| Value | Backend | Use Case |
|---|---|---|
local | LocalEnvironment | Direct execution on host machine (default, fastest) tools/environments/local.py1 |
docker | DockerEnvironment | Isolated Docker containers with security hardening tools/environments/docker.py1-6 |
singularity | SingularityEnvironment | HPC-friendly containers with overlay filesystems tools/environments/singularity.py65-69 |
modal | ModalEnvironment | Cloud sandboxes via Modal.com SDK tools/terminal_tool.py12 |
ssh | SSHEnvironment | Remote execution over SSH with ControlMaster tools/environments/ssh.py36-43 |
daytona | DaytonaEnvironment | Daytona development environment workspaces tools/environments/daytona.py30-36 |
The following diagram maps environment variables and configuration keys to the internal structures used during backend initialization.
"Natural Language Space to Code Entity Space: Configuration Mapping"
Sources: tools/environments/docker.py38-60 tools/environments/ssh.py45-51 tools/environments/daytona.py40-50
The LocalEnvironment backend executes commands directly on the host machine. It is the default option and provides the lowest latency but offers no process or filesystem isolation.
_popen_bash to spawn a subprocess with standard I/O setup tools/environments/base.py136-157_msys_to_windows_path tools/environments/local.py24-50_resolve_safe_cwd tools/environments/local.py154-172_sanitize_subprocess_env which filters out variables matching _HERMES_PROVIDER_ENV_BLOCKLIST tools/environments/local.py127-132Sources: tools/environments/base.py136-157 tools/environments/local.py24-172
The DockerEnvironment provides a security-hardened container execution environment.
Hermes applies strict security flags to every container to prevent host breakout:
cap-drop ALL, no-new-privileges, and PID limits tools/environments/docker.py1-6reap_orphan_containers, which targets containers labeled hermes-agent=1 with status=exited tools/environments/docker.py143-173/workspace tools/environments/docker.py50-52_normalize_forward_env_names tools/environments/docker.py43-63Sources: tools/environments/docker.py1-63 tools/environments/docker.py143-173
The SSHEnvironment allows the agent to execute commands on a remote server.
To avoid the overhead of establishing a new SSH connection for every tool call, Hermes uses ControlMaster tools/environments/ssh.py1-2:
tempfile.gettempdir() / "hermes-ssh". The filename is a stable hash of the connection triple to stay under the 104-byte Unix domain socket limit on macOS tools/environments/ssh.py53-66The SSHEnvironment uses a FileSyncManager to synchronize local ~/.hermes files to the remote host tools/environments/ssh.py72-79
tar pipe over the existing SSH connection for efficient bulk transfers via _ssh_bulk_upload tools/environments/ssh.py188-210echo $HOME tools/environments/ssh.py117-137Sources: tools/environments/ssh.py36-137 tools/environments/ssh.py188-210
The SingularityEnvironment (also known as Apptainer) provides containerized execution, often used in HPC environments. It leverages an overlay filesystem for persistent changes within the container.
_get_scratch_dir tools/terminal_tool.py69DISK_USAGE_WARNING_THRESHOLD_GB tools/terminal_tool.py115-149 This helps prevent issues in environments with strict storage quotas.Sources: tools/terminal_tool.py65-69 tools/terminal_tool.py115-149
The ModalEnvironment integrates with Modal.com to provide cloud-based sandboxed execution. It supports both direct Modal usage and managed gateway modes.
coerce_modal_mode to determine the appropriate Modal execution context (e.g., direct or managed) tools/terminal_tool.py71-75has_direct_modal_credentials tools/terminal_tool.py72managed_nous_tools_enabled to leverage Nous Research's managed tool gateway for simplified setup tools/terminal_tool.py73resolve_modal_backend_state determines the operational state of the Modal backend, including potential unavailability messages tools/terminal_tool.py74Sources: tools/terminal_tool.py71-75
The DaytonaEnvironment integrates with the Daytona cloud development platform tools/environments/daytona.py30-36
_daytona_bulk_upload using sandbox.fs.upload_files() for optimized multi-file transfers tools/environments/daytona.py154-181Sources: tools/environments/daytona.py30-181
The execute_code tool allows the LLM to write Python scripts that call Hermes tools via RPC, collapsing multi-step tool chains into a single turn tools/code_execution_tool.py3-7
The system supports two RPC transports depending on the backend:
hermes_tools.py stub tools/code_execution_tool.py10-14env.execute(), dispatches them, and writes response files back to the remote environment tools/code_execution_tool.py16-22Default limits are enforced to prevent runaway scripts:
DEFAULT_TIMEOUT: 300 seconds tools/code_execution_tool.py73DEFAULT_MAX_TOOL_CALLS: 50 calls tools/code_execution_tool.py74MAX_STDOUT_BYTES: 50 KB tools/code_execution_tool.py75Sources: tools/code_execution_tool.py3-75
The ProcessRegistry manages background processes spawned via terminal(background=true) tools/process_registry.py4-10
ProcessSession.output_buffer tools/process_registry.py58processes.json for gateway reset protection tools/process_registry.py55-56write_stdin, handling platform-specific differences (e.g., str for Windows PTY, bytes for POSIX PTY) tests/tools/test_process_registry.py68-104request_close_terminal method allows the UI to signal that a terminal view should be closed without necessarily killing the underlying process, especially in desktop environments tests/tools/test_process_registry.py155-170Sources: tools/process_registry.py1-139 tests/tools/test_process_registry.py68-104 tests/tools/test_process_registry.py155-170
The following diagram illustrates the path a command takes from the agent to a specific backend implementation.
"Code Entity Space: Command Execution Flow"
Sources: tools/environments/base.py136-157 tools/environments/daytona.py30-40 tools/environments/ssh.py36-43 tools/environments/docker.py1-6 tools/terminal_tool.py9-13
Refresh this wiki
This wiki was recently refreshed. Please wait 2 days to refresh again.