-
Notifications
You must be signed in to change notification settings - Fork 44.5k
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
Stop execute_shell
going interactive
#1327
Comments
lol, yeah i just ran into it trying to use nano as well. I forced nano to quit, and was able to resume though. |
|
Ya a few different interactive shark commands that seem to break the loop. Hope there's a solution |
though it would be nice if it could remote control an editor so we can watch it write the code ;-) |
yeah, i just ran into this too, and went to see if it was fixed, I wonder if it is possible to give AutoGPT the ability to use nano |
I think the new popen shell is for interactive commands now. going to try it out |
it seems to work... as in it leaves the subprocess open... but it doesnt seem to interact with it after it opens it. In the code, it looks like it doesn't accept output. Not sure this could work for interactive commands, might need something more like pexpect? |
Same issue here. So far I told it about the problem, it then installed notepad++ (which requires a Y prompt it did not put in the choco command and so I had to type it in for it) and then it opened Notepad++ and also could not interact with it. Finally it used an echo command to write to the file which did work.......and then resumed attempting to use nano ignoring that it was failing to write to the file. Until this is fixed will test out telling it to either use the write_to_file command exclusively or to use echo to create/append texts. |
@TheNitzel : may i ask how you told auto-GTP about the problem ? via shell ? I tried to add "not to use nano or vi" to the initial goals but that doesn't seem to work. I don't understand how auto-GPT is not able to write in or create a file, seems to me it's doing that all the time, i mean it's succesfully creating and updating auto-gpt.json for instance. |
There isn't a command that AUTOGPT AI is using to update the auto-gpt.json file, that's hardcoded in the script. write_to_file works as does append. Asking it to use interactive shells or GUIs is like asking a blind and deaf person to be a stenographer at this point in time. Until OCR, mouse and keyboard emulation are supported, it can't interact with any GUI. Everything it can do needs to be done via command line.
You can try various prompting strategies, but if you see "Next Action: Execute Shell" and it's trying to use nano/vi or anything you don't want it to do, give it human feedback. |
OK thanks, i never asked it to use interactive shells or GUIs, it's going on a GUI tour all by itself, hmm, I will put some more into reading the issues and documentation, I haven't got my mind yet around the exact way this auto-GPT is working, probably have a wrong image of it. Looks to me it's starting up agents for all sorts of tasks and in my case one of the agents is trying to create a python script, that initially seems to go well, until he opens nano / vi to write to or append a file and get's stuck. Dunno why it just doesn't just stick to command line then. Hope I can somehow let it use only command line for files. It would probably saved me 10 restarts :) |
execute_shell
going interactive
some editors, like vim, definitely support a client/server mode - it would probably be a dedicated plugin to make that work, and it would have to work via popen probably, and it would benefit from the concept of "channels" to talk to other "server-like" processes. In the meantime, one could probably use some strace-like script to look for problematic API calls and make such processes return control to Auto-GPT if they are exhibiting "blocking" behavior: To deal with binaries that may optionally use blocking calls on a Linux system where only non-blocking binaries are permitted, you can take several approaches. One option is to wrap the binary with a script that intercepts any blocking calls and terminates the process if it becomes blocked, using a tool like "strace" to trace system calls. Another option is to redirect blocking calls to non-blocking equivalents using the "fcntl" system call to set file descriptors to non-blocking mode. |
why does it need to use an editor though? it can write everything to files on it's own according to syntax. what would the use of an editor even be? |
Fun!
…On Sun, Apr 30, 2023 at 07:27 katmai ***@***.***> wrote:
why does it need to use an editor though? it can write everything to files
on it's own according to syntax. what would the use of an editor even be?
—
Reply to this email directly, view it on GitHub
|
makes sense :D |
I've seen it (successfully!) using sed to edit/patch existing files - then again, "an editor" (nano, vi etc) is probably just lingo for any interactive "app" (#346) here? It getting stuck inside nano/vim seems to happen for some folks - thus, the heuristics to detect such binaries/situations would potentially still be worthwhile ? Also, if the sub-agent approach is pursued, a parent-agent would be in a position to monitor what's going on and it could observe/terminate a sub-agent as needed, including if it's obviously got stuck invoking a system call that is blocking. |
Hi there, I don't like the timeout solution, I am using a special character to detect the input prompt. You can have a look https://stackoverflow.com/q/76097868/10294022 |
For future reference, here's what GPT-4 came up with to detect an idle child process that seems to be blocking because it's waiting for I/O without actually changing its RAM/CPU utilization and without sending data to the parent process:import ctypes libc = ctypes.CDLL('libc.so.6') def hooked_read(fd, buf, count): libc.read.restype = ctypes.c_ssize_t Replace the read function with the hooked versionlibc.read = hooked_read Launch the target process using popenprocess = os.popen('ls') Monitor the process's CPU and RAM utilization and outputwhile process.poll() is None:
Wait for the process to finish and print its outputoutput = process.read() |
saw it once again today, despite previously having used sed successfully, it wanted to start nano and vim. Also, another user is currently working on a new "update_file" command which should hopefully help. |
I believe ai tries to open editors because it can't find a useful command in its own code. Since I am using my update_file, I have not been getting attempts to open editors unless I specifically ask for it. My PR #3643 |
We probably need a bunch of aliases to cover all cases (edit, update, rewrite, change, modify etc) and redirect the llm to use a BIF |
I am ready for @Boostrix PR you're all up in these issues and from what I've seen you have the right idea 83% or more. |
It's now possible to configure which shell commands are permitted or prohibited, which can be useful in preventing the use of interactive commands. |
Keep in mind that interactive programs can go non interactive and vice versa... |
Duplicates
Steps to reproduce 🕹
I ran a setup last night to assist in writing some proposals. It got to a point where it thought it needed to edit files and ran
gedit
(and it's not even running on a desktop OS), then tried to runnano
- neither of which would work since it's not capable of using tools like that.Is there some way to constrain or tell it that using interactive tools like that won't work?
Current behavior 😯
Expected behavior 🤔
The AI should know, or even infer, that it can't use programs like that.
Your prompt 📝
The text was updated successfully, but these errors were encountered: