Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Allow absolute paths when not restricting to workspace root (#4946)

Antonov Maximed12b2c7d603
diff --git a/autogpt/workspace/workspace.py b/autogpt/workspace/workspace.py
index 6d90f85404..07186e7351 100644
--- a/autogpt/workspace/workspace.py
+++ b/autogpt/workspace/workspace.py
@@ -123,7 +123,11 @@ class Workspace:
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}'."
)