Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix(docs): volumes configuration under [sandbox] in config.toml (#8724)

Xingyao Wang3ccc96d79439
diff --git a/config.template.toml b/config.template.toml
index 7038d03019..30bf1cd5ba 100644
--- a/config.template.toml
+++ b/config.template.toml
@@ -325,6 +325,15 @@ classpath = "my_package.my_module.MyCustomAgent"
# Useful when deploying OpenHands in a remote machine where you need to expose a specific port.
#vscode_port = 41234
+# Volume mounts in the format 'host_path:container_path[:mode]'
+# e.g. '/my/host/dir:/workspace:rw'
+# Multiple mounts can be specified using commas
+# e.g. '/path1:/workspace/path1,/path2:/workspace/path2:ro'
+
+# Configure volumes under the [sandbox] section:
+# [sandbox]
+# volumes = "/my/host/dir:/workspace:rw,/path2:/workspace/path2:ro"
+
#################################### Security ###################################
# Configuration for security features
##############################################################################
diff --git a/docs/modules/usage/configuration-options.md b/docs/modules/usage/configuration-options.md
index e5c15e352d..d806309bdd 100644
--- a/docs/modules/usage/configuration-options.md
+++ b/docs/modules/usage/configuration-options.md
@@ -331,6 +331,8 @@ The agent configuration options are defined in the `[agent]` and `[agent.<agent_
The sandbox configuration options are defined in the `[sandbox]` section of the `config.toml` file.
+
+
To use these with the docker command, pass in `-e SANDBOX_<option>`. Example: `-e SANDBOX_TIMEOUT`.
### Execution
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
index 6fd4b0c6a0..92c8a8dbfc 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -683,6 +683,29 @@ def test_agent_config_condenser_with_no_enabled():
assert isinstance(agent_config.condenser, NoOpCondenserConfig)
+def test_sandbox_volumes_toml(default_config, temp_toml_file):
+ """Test that volumes configuration under [sandbox] works correctly."""
+ with open(temp_toml_file, 'w', encoding='utf-8') as toml_file:
+ toml_file.write("""
+[sandbox]
+volumes = "/home/user/mydir:/workspace:rw,/data:/data:ro"
+timeout = 1
+""")
+
+ load_from_toml(default_config, temp_toml_file)
+ finalize_config(default_config)
+
+ # Check that sandbox.volumes is set correctly
+ assert (
+ default_config.sandbox.volumes
+ == '/home/user/mydir:/workspace:rw,/data:/data:ro'
+ )
+ assert default_config.workspace_mount_path == '/home/user/mydir'
+ assert default_config.workspace_mount_path_in_sandbox == '/workspace'
+ assert default_config.workspace_base == '/home/user/mydir'
+ assert default_config.sandbox.timeout == 1
+
+
def test_condenser_config_from_toml_basic(default_config, temp_toml_file):
"""Test loading basic condenser configuration from TOML."""
with open(temp_toml_file, 'w', encoding='utf-8') as toml_file: