stagehand-python  by browserbase

AI-powered framework for reliable browser automation

Created 8 months ago
256 stars

Top 98.7% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

Stagehand is an AI-powered browser automation framework designed to address the trade-offs between low-level, rigid automation tools and unpredictable high-level AI agents. It offers developers a flexible hybrid approach, allowing them to integrate AI for navigating unfamiliar web pages or executing complex tasks while using traditional code (Playwright) for predictable, known actions. This enables more reliable and controllable browser automation for production environments.

How It Works

Stagehand bridges the gap between low-level browser automation frameworks and unpredictable high-level AI agents. It empowers developers to selectively use AI for navigating unfamiliar web pages or complex tasks, while leveraging direct code (Playwright) for predictable, known actions. This hybrid model enhances reliability and control in production environments. Key functionalities include act for AI-driven actions, extract for Pydantic-validated data retrieval, observe for action preview and selector identification, and agent for orchestrating multi-step LLM-powered tasks.

Quick Start & Requirements

  • Primary install command: pip install stagehand. uv is recommended for package management.
  • Prerequisites: Requires environment variables for Browserbase (BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID) and LLM model API keys (MODEL_API_KEY).
  • Documentation: Mentions availability of full documentation and a contributing guide, but direct URLs are not provided in the README text.

Highlighted Details

  • Hybrid Control: Dynamically choose between AI and code execution for optimal reliability and flexibility.
  • Action Preview & Caching: observe provides a JSON representation of AI-suggested actions, allowing preview and caching to reduce LLM calls and improve performance.
  • Self-Healing: Automatically re-runs AI action loops when website DOM changes, enhancing script resilience.
  • LLM Integration: Seamlessly integrates state-of-the-art LLMs (OpenAI, Anthropic) for complex tasks with minimal boilerplate.
  • Structured Data Extraction: Utilizes Pydantic models for robust and validated data extraction from web pages.

Maintenance & Community

  • Community: Encourages engagement via Slack. Contributions are welcomed through issues or discussions, with a contributing guide mentioned but not linked.

Licensing & Compatibility

  • License: MIT License. This permissive license allows for broad compatibility with commercial and closed-source projects.

Limitations & Caveats

No explicit limitations are detailed in the provided README. The framework's effectiveness may depend on the quality of the underlying LLMs and the clarity of natural language instructions.

Health Check
Last Commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
12
Issues (30d)
8
Star History
39 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Luis Capelo Luis Capelo(Cofounder of Lightning AI), and
15 more.

stagehand by browserbase

0.5%
17k
AI browser automation framework for production
Created 1 year ago
Updated 1 day ago
Feedback? Help us improve.