AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

File Operations logger breaks incremental edits

Open villesau opened this issue 1 year ago • 17 comments

Duplicates

  • [X] I have searched the existing issues

Steps to reproduce 🕹

  1. come up with prompt that writes to a file
  2. it suggest following:
CRITICISM:  I need to ensure that the report is saved correctly and that it is easy to read and understand.
SPEAK:  Let's save the report to a file using the 'write_to_file' command so that we can access it later. What would you like to name the file?
Attempting to fix JSON by finding outermost brackets 
Apparently json was fixed. 
NEXT ACTION:  COMMAND = write_to_file ARGUMENTS = {'file': '<file_name>', 'text': 'Here is the text to write to file'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for ...
Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= 
SYSTEM:  Command write_to_file returned: Error: File has already been updated.
 THOUGHTS:  Let's delete the file we just created using the 'delete_file' command and then save the report again using a different file name.
REASONING:  Deleting the file will allow us to save the report again using a different file name. This will ensure that we have a clean slate to work with and that we don't accidentally overwrite the previous report.

Note that the <file_name> is from the actual output so that's the file name it tries to save to.

Current behavior 😯

Writing to file fails and the filename is weird.

Expected behavior 🤔

It should succeed with correct file name.

Likely relates to this issue: https://github.com/Significant-Gravitas/Auto-GPT/issues/1889 Both are trying to use the same malformed file name.

Your prompt 📝

# Paste your prompt here

villesau avatar Apr 16 '23 14:04 villesau

Unable to repro this

image

autoGPT correctly creates a test file in this case with the right data. Are you on stable or master?

rocks6 avatar Apr 16 '23 14:04 rocks6

I was on master when doing this. I'm not sure what dictates the file names? If it's gpt I guess it resorted to some template name given to it without questioning that it's actually meant just for example. I can report back if I see this in stable as well

villesau avatar Apr 16 '23 14:04 villesau

Ah got it - it looks like this is occurring because somebody introduced a file logging system which results in an infinite loop. I'll have a PR out soon to fix

rocks6 avatar Apr 16 '23 14:04 rocks6

https://github.com/Significant-Gravitas/Auto-GPT/pull/1901

rocks6 avatar Apr 16 '23 14:04 rocks6

I have the same problem. Its always something new, starting to get used to this

sjnt1 avatar Apr 17 '23 18:04 sjnt1

Same issue. I think looking at write_to_file under file_operations.py I saw that check_duplicate_operation() is causing my error where it just updates once in a session and because it was updated once it doesn't allow more data/info to be placed in the created .txt file.

Saw some logging issue was updated with append but I think I'm on 'stable' and still get the error shown here.

smembreno avatar Apr 18 '23 01:04 smembreno

seems like after it has created a text tile it need to use append to file to write on that file

sjnt1 avatar Apr 18 '23 15:04 sjnt1

  • Checks any operation instead of last operation
    • Write -> delete -> write = Error "File has already been updated"
  • Does not allow incremental edits

The only solution I see is hashing the written content and adding that to the log

Pwuts avatar Apr 18 '23 16:04 Pwuts

thanks for working on this - just reporting that i'm seeing it when working on a streamlit app - trying to figure out how to give gpt enough autonomy to build and test on its own

alibama avatar Apr 19 '23 18:04 alibama

I'm also having this issue

calebplum avatar Apr 23 '23 09:04 calebplum

When I manually delete the file_logger.txt before the next write happens, the write is then done correctly.

VirheCZ avatar Apr 23 '23 19:04 VirheCZ

the same issue please check if file exist only append

pencilvania avatar Apr 23 '23 21:04 pencilvania

Append-only isnt the right solution either. Sometimes it may be perfectly valid for it to replace parts of the file contents, not just append

richstokes avatar Apr 23 '23 21:04 richstokes

I've added a powershell script to the folder that automatically delete the file_logger.txt file

$folder = Get-Location $filter = "file_logger.txt"

$fsWatcher = New-Object System.IO.FileSystemWatcher -ArgumentList $folder, $filter $fsWatcher.EnableRaisingEvents = $true

Register-ObjectEvent -InputObject $fsWatcher -EventName Created -SourceIdentifier FileLoggerWatcher -Action { $deletedFile = $EventArgs.FullPath Remove-Item -Path $deletedFile -Force Write-Host "file_logger.txt has been deleted." }

try { Write-Host "Monitoring folder: $($folder.Path)" Write-Host "Press CTRL+C to stop monitoring..." while ($true) { Start-Sleep -Seconds 1 } } finally { Unregister-Event -SourceIdentifier FileLoggerWatcher $fsWatcher.Dispose() }

ataxy avatar Apr 23 '23 23:04 ataxy

image

only comment these 2 lines and seems working well

pencilvania avatar Apr 23 '23 23:04 pencilvania

I think the duplicate checking thing should be removed. Appending to the same file (and even the same content to the same file) is a valid operation, same with writing to the same file etc.

rocks6 avatar Apr 24 '23 01:04 rocks6

Created PR to address the above. https://github.com/Significant-Gravitas/Auto-GPT/pull/3126

rocks6 avatar Apr 24 '23 11:04 rocks6

https://github.com/Significant-Gravitas/Auto-GPT/pull/3489

samuelbutler avatar Apr 30 '23 20:04 samuelbutler