diff --git a/autogpt/workspace/workspace.py b/autogpt/workspace/workspace.py index 6d90f854044..07186e73517 100644 --- a/autogpt/workspace/workspace.py +++ b/autogpt/workspace/workspace.py @@ -123,7 +123,11 @@ def _sanitize_path( logger.debug(f"Resolved root as '{root}'") # Allow exception for absolute paths if they are contained in your workspace directory. - if relative_path.is_absolute() and not relative_path.is_relative_to(root): + if ( + relative_path.is_absolute() + and restrict_to_root + and not relative_path.is_relative_to(root) + ): raise ValueError( f"Attempted to access absolute path '{relative_path}' in workspace '{root}'." )