Skip to content
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

Don't incapacitate yourself! #1240

Merged
merged 7 commits into from
Apr 17, 2023

Conversation

lfricken
Copy link
Contributor

@lfricken lfricken commented Apr 14, 2023

Background

If Auto-GPT4 tries to host a server or do another task that can block the current process, it may get stuck if the command never terminates (somewhat common).

Changes

Adds the Execute Shell Command Subprocess command which uses Popen. Auto-GPT now knows to use this if the command will take too long. When I ask it to host a web server or do other tasks that are reasonable for a subprocess, it does so. The PID of the process is returned so Auto-GPT can kill it later if it wants, or if the user asks. In my use cases it was smart enough to save the PIDs to a file and name them to remember for later.

This will encourage it to use more CPU cores for tasks that could otherwise take a while, and help it avoid bottlenecking on anything but API calls. It is of course in theory capable of achieving this with existing commands, but it doesn't. If it were that smart, we would only have needed a single command for it to be able to run python code and it could build its own instruction set. It seems to need these "available command" hints.

Documentation

It is documented as well as the other commands, and Auto-GPT figures it out.

Test Plan

Before and after this dev:

  1. Ask it to localhost a server or start any other long running program

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes

Additional Thoughts

Is Popen the best solution? It's just what GPT4 recommended when I asked ChatGPT4 how to address this problem 😊

@lfricken lfricken changed the title child processes non blocking operations Apr 14, 2023
@lfricken lfricken changed the title non blocking operations Don't incapacitate yourself! Apr 14, 2023
@nponeccop nponeccop mentioned this pull request Apr 14, 2023
1 task
scripts/prompt.py Outdated Show resolved Hide resolved
@nponeccop
Copy link
Contributor

@lfricken There are conflicts now

@lfricken lfricken reopened this Apr 15, 2023
@lfricken
Copy link
Contributor Author

@lfricken There are conflicts now

@nponeccop fixed

nponeccop
nponeccop previously approved these changes Apr 15, 2023
@nponeccop
Copy link
Contributor

@lfricken CI fails

@lfricken
Copy link
Contributor Author

@lfricken CI fails

@nponeccop Fixed linting issues and checked tests

@nponeccop nponeccop mentioned this pull request Apr 16, 2023
1 task
@nponeccop nponeccop added potential plugin This may fit better into our plugin system. B7 Obsolete? and removed potential plugin This may fit better into our plugin system. B7 labels Apr 16, 2023
@@ -38,6 +38,9 @@ def get_prompt() -> str:
prompt_generator.add_constraint(
'Exclusively use the commands listed in double quotes e.g. "command name"'
)
prompt_generator.add_constraint(
"Use subprocesses for commands that will not terminate within a few minutes"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's correct. If the command would terminate within a few minutes (aka quickly) you can use the normal execute command. If it would take more than a few minutes, use subprocess.

@p-i- p-i- merged commit d4860fe into Significant-Gravitas:master Apr 17, 2023
laixiao pushed a commit to laixiao/Auto-GPT-code that referenced this pull request Apr 18, 2023
* subprocesses

* fix lint

* fix more lint

* fix merge

* fix merge again
sindlinger pushed a commit to Orgsindlinger/Auto-GPT-WebUI that referenced this pull request Sep 25, 2024
* subprocesses

* fix lint

* fix more lint

* fix merge

* fix merge again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants