Article
autonomous-agentsopen-sourcetask-automationpythonopenaiagentic-workflowstask-decomposition
Run Your First Autonomous Task with AutoGPT
Set up and run the original autonomous AI agent, AutoGPT. Learn to assign a complex goal, let it create and execute a plan using web browsing and file operations, and review the results. Master both continuous and manual approval modes.
intermediate30 min5 steps
The play
- Clone and Install AutoGPTFirst, get the AutoGPT source code from its official repository and install the required Python packages. This sets up the necessary environment for the agent to run locally.
- Configure Environment VariablesAutoGPT requires API keys to function. Copy the template environment file and add your OpenAI API key. This is essential for allowing AutoGPT to use an LLM for reasoning and task generation.
- Run in Manual Mode (Safe Default)Run AutoGPT with a specific goal. In the default manual mode, it will prompt you for authorization before each action (e.g., 'y' to approve). This gives you full control and is recommended for your first run.
- Run in Continuous ModeTo see full autonomy, use the '--continuous' flag. AutoGPT will attempt to complete its goal without asking for your approval for each step. Use this with caution, especially for complex tasks that may consume many API calls.
- Review the OutputAutoGPT saves all its work, including logs and created files, in a specific directory. Check the 'auto_gpt_workspace' folder to find the files generated during its execution and verify the results of the assigned task.
Starter code
#!/bin/bash # This script sets up and runs AutoGPT with a simple research task. # Prerequisites: git, python3, and pip must be installed. # 1. Clone the repository and navigate into it echo "Cloning AutoGPT repository..." git clone https://github.com/Significant-Gravitas/AutoGPT.git cd AutoGPT # 2. Install dependencies echo "Installing required packages..." pip install -r requirements.txt # 3. Set up environment file # IMPORTANT: Replace YOUR_OPENAI_API_KEY with your actual key. echo "Creating .env file..." cp .env.template .env # Use sed to insert the API key (works on macOS and Linux) # For Windows, you'll need to edit the .env file manually. API_KEY="YOUR_OPENAI_API_KEY" if [[ "$API_KEY" == "YOUR_OPENAI_API_KEY" ]]; then echo "\nWARNING: Please replace 'YOUR_OPENAI_API_KEY' in this script with your actual OpenAI API key." exit 1 fi sed -i.bak "s/your-openai-api-key/$API_KEY/g" .env # 4. Run AutoGPT echo "Running AutoGPT. Approve the first few steps by typing 'y' and pressing Enter." python -m autogpt --prompt "Find today's date and write it to a file named 'today.txt'"