-
Notifications
You must be signed in to change notification settings - Fork 44.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow absolute paths when not restricting to workspace root #4946
Allow absolute paths when not restricting to workspace root #4946
Conversation
#2861 fixed
✅ Deploy Preview for auto-gpt-docs canceled.
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4946 +/- ##
==========================================
- Coverage 51.00% 50.92% -0.08%
==========================================
Files 118 119 +1
Lines 4884 4895 +11
Branches 643 646 +3
==========================================
+ Hits 2491 2493 +2
- Misses 2212 2219 +7
- Partials 181 183 +2
☔ View full report in Codecov by Sentry. |
Hi @antonovmaxim. Thanks for your contribution! Could you please add a test for this in your PR. Ideally the test should fail without your fix and pass with your fix. This helps us verify that we've actually solved the problem and also helps us prevent future changes from introducing this bug again. |
Hi @collijk. Of course! I have added tests. |
I think you may have forgotten to push them |
Oh, you mean those tests. Then I'm sorry, pytest doesn't work for me. I added a description of the tests to the description of my PR. |
…ant-Gravitas#4946) * restrict_to_root fix * Fix formatting --------- Co-authored-by: Reinier van der Leer <[email protected]>
Background
I have RESTRICT_TO_WORKSPACE=False and I'm getting error
Attempted to access absolute path '{relative_path}' in workspace '{root}'.
Changes
Only raise an error if
restrict_to_root
isTrue
.Documentation
Line 125 and 126
Test Plan
I asked Auto-GPT to add file C://text.txt with text '12345'. (in .env file RESTRICT_TO_WORKSPACE=False)
without my fix
I want Auto-GPT to: add file C://text.txt with text '12345' NOTE:All files/directories created by this agent can be found inside its workspace at: C:\Users\max\Desktop\AGI\Auto-GPT\autogpt\workspace\auto_gpt_workspace FileAgentGPT has been created with the following details: Name: FileAgentGPT Role: an autonomous agent that specializes in file management and manipulation, providing efficient and reliable assistance in handling various file-related tasks. Goals: - Receive and process file-related commands to add, modify, or delete files as per your instructions. - Ensure the successful addition of the specified file 'C://text.txt' with the text '12345' as requested. - Verify the accuracy and integrity of the added file by cross-checking the content with the provided text. - Handle any potential errors or exceptions during the file addition process and provide appropriate feedback or solutions. - Maintain a secure and organized file system, adhering to best practices and ensuring the confidentiality and availability of your files. Using memory of type: JSONFileMemory Using Browser: chrome FILEAGENTGPT THOUGHTS: To accomplish the goal of adding the specified file 'C://text.txt' with the text '12345', I will use the 'write_to_file' command. REASONING: The 'write_to_file' command allows me to create a new file or overwrite an existing file with the specified text content. - Use the 'write_to_file' command with the filename 'C://text.txt' and the text '12345'. CRITICISM: I need to ensure that the file 'C://text.txt' does not already exist before using the 'write_to_file' command to avoid overwriting any existing file. SPEAK: I will use the 'write_to_file' command to add the file 'C://text.txt' with the text '12345'.
NEXT ACTION: COMMAND = write_to_file ARGUMENTS = {'filename': 'C://text.txt', 'text': '12345'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for FileAgentGPT...
Asking user via keyboard...
Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=
SYSTEM: Command write_to_file returned: Error: Attempted to access absolute path 'C:\text.txt' in workspace 'C:\Users\max\Desktop\AGI\Auto-GPT\autogpt\workspace\auto_gpt_workspace'.
with my fix
I want Auto-GPT to: add file C://text.txt with text '12345' NOTE:All files/directories created by this agent can be found inside its workspace at: C:\Users\max\Desktop\AGI\Auto-GPT\autogpt\workspace\auto_gpt_workspace FileAgentGPT has been created with the following details: Name: FileAgentGPT Role: an autonomous agent that specializes in file management and manipulation, providing efficient and reliable assistance in handling various file-related tasks. Goals: - Receive and process file-related commands to add, modify, or delete files as per your instructions. - Ensure the successful addition of the specified file 'C://text.txt' with the text '12345' as requested. - Verify the accuracy and integrity of the added file by cross-checking the content with the provided text. - Handle any potential errors or exceptions during the file addition process and provide appropriate feedback or solutions. - Maintain a secure and organized file system, adhering to best practices and ensuring the confidentiality and availability of your files. Using memory of type: JSONFileMemory Using Browser: chrome FILEAGENTGPT THOUGHTS: To accomplish the goal of adding the specified file 'C://text.txt' with the text '12345', I will use the 'write_to_file' command. REASONING: The 'write_to_file' command allows me to create a new file or overwrite an existing file with the specified text content. - Use the 'write_to_file' command with the filename 'C://text.txt' and the text '12345'. CRITICISM: I need to ensure that the file 'C://text.txt' does not already exist before using the 'write_to_file' command to avoid overwriting any existing file. SPEAK: I will use the 'write_to_file' command to add the file 'C://text.txt' with the text '12345'.
NEXT ACTION: COMMAND = write_to_file ARGUMENTS = {'filename': 'C://text.txt', 'text': '12345'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for FileAgentGPT...
Asking user via keyboard...
Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=
SYSTEM: Command write_to_file returned: File written to successfully.
PR Quality Checklist