From 677b11d84c8bd03c0ede39ba4bcb56be41114817 Mon Sep 17 00:00:00 2001 From: Teknium Date: Tue, 24 Mar 2026 08:03:04 -0700 Subject: [PATCH] fix: reject relative cwd paths for container terminal backends When TERMINAL_CWD is set to '.' or any relative path (common when the CLI config defaults to cwd='.'), container backends (docker, modal, singularity, daytona) would pass it directly to the container where it's meaningless. This caused 'docker run -d -w .' to fail. Now relative paths are caught alongside host paths and replaced with the default '/root' for container backends. --- tools/terminal_tool.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py index 67283e2f..f4869bc2 100644 --- a/tools/terminal_tool.py +++ b/tools/terminal_tool.py @@ -483,10 +483,12 @@ def _get_env_config() -> Dict[str, Any]: host_cwd = candidate cwd = "/workspace" elif env_type in ("modal", "docker", "singularity", "daytona") and cwd: - # Host paths that won't exist inside containers - if any(cwd.startswith(p) for p in host_prefixes) and cwd != default_cwd: + # Host paths and relative paths that won't work inside containers + is_host_path = any(cwd.startswith(p) for p in host_prefixes) + is_relative = not os.path.isabs(cwd) # e.g. "." or "src/" + if (is_host_path or is_relative) and cwd != default_cwd: logger.info("Ignoring TERMINAL_CWD=%r for %s backend " - "(host path won't exist in sandbox). Using %r instead.", + "(host/relative path won't work in sandbox). Using %r instead.", cwd, env_type, default_cwd) cwd = default_cwd