- Goal: demonstrate autonomous web browsing using Google's Computer Use Agent with Stagehand and Browserbase.
- Uses Stagehand Agent to automate complex workflows with AI powered browser agents
- Leverages Google's gemini-2.5-computer-use-preview model for autonomous web interaction and decision-making.
- agent: create an autonomous AI agent that can execute complex multi-step tasks Docs → https://docs.stagehand.dev/basics/agent#what-is-agent
- uv venv venv
- source venv/bin/activate # On Windows: venv\Scripts\activate
- pip install -r requirements.txt
- cp .env.example .env # Add your Browserbase API key and Google API key to .env
- python main.py
- Initializes Stagehand session with Browserbase
- Navigates to Google search engine
- Executes autonomous search and data extraction task
- Displays live session link for monitoring
- Returns structured results or completion status
- Closes session cleanly
- "ModuleNotFoundError": ensure all dependencies are installed via pip
- Missing credentials: verify .env contains BROWSERBASE_API_KEY and GOOGLE_API_KEY
- Google API access: ensure you have access to Google's gemini-2.5-computer-use-preview model
- Import errors: activate your virtual environment if you created one
• Autonomous research: Let AI agents independently research topics, gather information, and compile reports without manual intervention. • Complex web workflows: Automate multi-step processes that require decision-making, form filling, and data extraction across multiple pages. • Content discovery: Search for specific information, verify data accuracy, and cross-reference sources autonomously.
• Customize instructions: Modify the instruction variable to test different autonomous tasks and scenarios. • Add error handling: Implement retry logic, fallback strategies, and better error recovery for failed agent actions. • Extend capabilities: Add support for file downloads, form submissions, and more complex interaction patterns.
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction 🎮 Browserbase: https://www.browserbase.com 💡 Try it out: https://www.browserbase.com/playground 🔧 Templates: https://www.browserbase.com/templates 📧 Need help? support@browserbase.com 💬 Discord: http://stagehand.dev/discord