Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
docs improvments
Nick Sweeting495d334e9539
diff --git a/docs/customize/agent-settings.mdx b/docs/customize/agent-settings.mdxindex 97535cd9f..107d4e5f6 100644--- a/docs/customize/agent-settings.mdx+++ b/docs/customize/agent-settings.mdx@@ -299,7 +299,7 @@ The `MemoryConfig` model provides these configuration options:#### Vector Store Settings- `vector_store_provider`: Choose the vector store backend. Supported options include:- `'faiss'` (default), `'qdrant'`, `'pinecone'`, `'supabase'`, `'elasticsearch'`, `'chroma'`, `'weaviate'`, `'milvus'`, `'pgvector'`, `'upstash_vector'`, `'vertex_ai_vector_search'`, `'azure_ai_search'`, `'redis'`.+ `'faiss'` (default), `'qdrant'`, `'pinecone'`, `'supabase'`, `'elasticsearch'`, `'chroma'`, `'weaviate'`, `'milvus'`, `'pgvector'`, `'upstash_vector'`, `'vertex_ai_vector_search'`, `'azure_ai_search'`, `'lancedb'`, `'mongodb'`, `'redis'`, `'memory'` (in-memory, non-persistent).- `vector_store_collection_name`: (Optional) Specify a custom name for the collection or index in your vector store. If not provided, a default name is generated (especially for local stores like FAISS/Chroma) or used by Mem0.- `vector_store_base_path`: Path for local vector stores like FAISS or Chroma (e.g., `/tmp/mem0`). Default is `/tmp/mem0`.- `vector_store_config_override`: (Optional) A dictionary to provide or override specific configuration parameters required by Mem0 for the chosen `vector_store_provider`. This is where you'd put connection details like `host`, `port`, `api_key`, `url`, `environment`, etc., for cloud-based or server-based vector stores.diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdxindex 071540fed..5494c0196 100644--- a/docs/customize/browser-settings.mdx+++ b/docs/customize/browser-settings.mdx@@ -30,8 +30,8 @@ agent = Agent('fill out the form on this page', browser_session=browser_session)## `BrowserSession`-- `BrowserSession(**params)` is Browser Use's object that tracks a connection to a running browser. It sets up:- - the `playwright`, `browser`, `browser_context`, and `page` objects and tracks which tabs the agent/human are focused on+- π `BrowserSession(**params)` is Browser Use's object that tracks a playwright connection to a running browser. It sets up:+ - the `playwright` library, `browser` and/or `browser_context`, and `page` objects and tracks which tabs the agent & human are focused on- methods to interact with the browser window, apply config needed by the Agent, and run the `DOMService` for element detection- it can take a `browser_profile=BrowserProfile(...)` template containing some config defaults, and `**kwargs` session-specific config overrides@@ -163,28 +163,68 @@ await asyncio.gather(agent1.run(), agent2.run())## `BrowserProfile`-A `BrowserProfile` is a static config template for a `BrowserSession()`.+A `BrowserProfile` is a π config template for a π `BrowserSession(...)`.-It can validate and hold all the standard [playwright arguments](#playwright) and the extra config arguments Browser Use provides.+It's basically just a typed + validated version of a `dict` to hold config.-It allows you do do things like start multiple browser processes with *some* shared config:+When you find yourself storing or re-using many browser configs, you can upgrade from:++```diff+- config = {key: val, key: val, ...}+- BrowserSession(**config)+```+To this instead:+```diff++ config = BrowserProfile(key=val, key=val, ...)++ BrowserSession(browser_profile=config)+```++<Tip>+You don't ever *need* to use a `BrowserProfile`, you can always pass config parameters directly to `BrowserSession`:+```python+session = BrowserSession(headless=True, storage_state='auth.json', viewport={...}, ...)+```+</Tip>++`BrowserProfile` is optional, but it provides a number of benefits over a normal `dict` for holding config:++- has type hints and pydantic field descriptions that show up in your IDE+- validates config at runtime quickly without having to start a browser+- provides helper methods to autodetect screen size, set up local paths, save/load config as json, and more...++<Tip>+`BrowserProfiles`s are designed to easily be given π `uuid`s and put in a database + made editable by users.+`BrowserSession`s get their own π `uuid`s and be linked by π foreign key to whatever `BrowserProfiles` they use.++This cleanly separates the per-connection rows from the bulky re-usable config and avoids wasting space in your db.+This is useful because a user may only have 2 or 3 profiles, but they could have 100k+ sessions within a few months.+</Tip>+++`BrowserProfile` and `BrowserSession` can both take any of the:++- [Playwright parameters](#playwright)+- [Browser-Use parameters](#browser-use-parameters) (extra options we provide on top of `playwright`)++The only parameters `BrowserProfile` can NOT take are the session-specific connection parameters and live playwright objects:+`cdp_url`, `wss_url`, `browser_pid`, `page`, `browser`, `browser_context`, `playwright`, etc.++### Basic Example```pythonfrom browser_use.browser import BrowserProfile-base_config = BrowserProfile(- storage_state='/tmp/auth.json',- allowed_domains=['https://*.google.com', 'https://*.example.com'],- headless=True,- viewport={'width': 920, 'height': 674},- device_scale_factor=1,+profile = BrowserProfile(+ stealth=True,+ storage_state='/tmp/google_docs_cookies.json',+ allowed_domains=['docs.google.com', 'https://accounts.google.com'],+ viewport={'width': 396, 'height': 774},# ... playwright args / browser-use config args ...)-# start 3 browser instances with common config + session-specific override:-low_res = BrowserSession(browser_profile=base_config, device_scale_factor=1)-hi_res = BrowserSession(browser_profile=base_config, device_scale_factor=2)-retina = BrowserSession(browser_profile=base_config, device_scale_factor=3)+phone1 = BrowserSession(browser_profile=profile, device_scale_factor=1)+phone2 = BrowserSession(browser_profile=profile, device_scale_factor=2)+phone3 = BrowserSession(browser_profile=profile, device_scale_factor=3)```### Browser-Use Parameters@@ -197,7 +237,14 @@ These parameters control Browser Use-specific features, and are outside the stankeep_alive: bool | None = None```-Keeps the browser alive after the agent has finished running. Useful for running multiple tasks with the same browser instance. If this is left as `None` and the Agent launched its own browser, the default is to close the browser after the agent completes. If the agent connected to an existing browser then it will leave it open.+If `True` it wont close the browser after the first `agent.run()` ends. Useful for running multiple tasks with the same browser instance. If this is left as `None` and the Agent launched its own browser, the default is to close the browser after the agent completes. If the agent connected to an existing browser then it will leave it open.++#### `stealth`++```python+stealth: bool = False+```+Set to `True` to use [`patchright`](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright) to avoid bot-blocking. (Might cause issues with some sites, requires manual testing.)<a name="restrict-urls"></a>@@ -313,16 +360,6 @@ Or run `playwright open https://example.com/ --save-storage=storage_state.json`</Warning>-#### `downloads_dir`--```python-downloads_dir: Path | str = '~/.config/browseruse/downloads'-```--Directory to save browser downloads in.--(previously called `save_downloads_path` in some places)-#### `profile_directory````python@@ -813,10 +850,12 @@ URL filter for HAR recording.#### `downloads_path````python-downloads_path: str | Path | None = None+downloads_path: str | Path | None = '~/.config/browseruse/downloads'```-Directory to save downloads to (used by launch args).+(aliases: `downloads_dir`, `save_downloads_path`)++Local filesystem directory to save downloads to.#### `traces_dir`@@ -859,7 +898,7 @@ from browser_use import BrowserSession, BrowserProfile, Agentbrowser_profile = BrowserProfile(headless=False,- cookies_file="path/to/cookies.json",+ storage_state="path/to/storage_state.json",wait_for_network_idle_page_load_time=3.0,viewport={"width": 1280, "height": 1100},locale='en-US',@@ -904,6 +943,6 @@ Configuration parameters defined in both scopes consumed by these calls dependin- `BrowserLaunchPersistentContextArgs` - args for `playwright.BrowserType.launch_persistent_context(...)`- Browser Use's own internal methods-For more details on Playwright's browser context options, see the [official documentation](https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch-persistent-context).+For more details on Playwright's browser context options, see their [launch args documentation](https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch-persistent-context).---diff --git a/docs/customize/real-browser.mdx b/docs/customize/real-browser.mdxindex 2185508f7..ffdde6231 100644--- a/docs/customize/real-browser.mdx+++ b/docs/customize/real-browser.mdx@@ -233,6 +233,8 @@ await agent2.run()### Sequential Agents, Same Profile, Same BrowserIf you are only running one agent at a time, they can re-use the same active `BrowserSession` and avoid having to relaunch chrome.+Each agent will start off looking at the same tab the last agent ended off on.+You can also pass in a specific playwright page using `Agent(..., page=page)` if you prefer.```pythonfrom browser_use import Agent, BrowserSession@@ -240,20 +242,20 @@ from langchain_openai import ChatOpenAIreused_session = BrowserSession(user_data_dir='~/.config/browseruse/profiles/default',- keep_alive=True,+ keep_alive=True, # dont close browser after 1st agent.run() ends)agent1 = Agent(task="The first task...",llm=ChatOpenAI(model="gpt-4o-mini"),- browser_session=reused_session, # pass the session in+ browser_session=reused_session, # pass a session or page=page)await agent1.run()agent2 = Agent(task="The second task...",llm=ChatOpenAI(model="gpt-4o-mini"),- browser_session=reused_session, # re-use the same session+ browser_session=reused_session, # re-use the same session)await agent2.run()diff --git a/docs/development/contribution-guide.mdx b/docs/development/contribution-guide.mdxindex 6f4c7b54c..ccec248eb 100644--- a/docs/development/contribution-guide.mdx+++ b/docs/development/contribution-guide.mdx@@ -15,8 +15,7 @@ Get started with Browser Use development in minutes:```bashgit clone https://github.com/browser-use/browser-usecd browser-use-uv venv-uv sync --all-extras --dev --upgrade+uv sync --all-extras --dev# or pip install -U git+https://github.com/browser-use/browser-use.git@mainecho "BROWSER_USE_LOGGING_LEVEL=debug" >> .env@@ -28,68 +27,34 @@ For more detailed setup instructions, see our [Local Setup Guide](/development/l### Find Something to Work On-- Browse our [GitHub Issues](https://github.com/browser-use/browser-use/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22help%20wanted%22) for beginner-friendly issues labeled `#help wanted` or `#good first issue`-- Check out our most active issues or ask in [Discord](https://link.browser-use.com/discord) for ideas of what to work on+- Browse our [GitHub Issues](https://github.com/browser-use/browser-use/issues) for beginner-friendly issues labeled `good-first-issue`+- Check out our most active issues or ask in [Discord](https://discord.gg/zXJJHtJf3k) for ideas of what to work on- Get inspiration and share what you build in the [`#showcase-your-work`](https://discord.com/channels/1303749220842340412/1305549200678850642) channel-- Explore or contribute to [`browser-use/awesome-prompts`](https://github.com/browser-use/awesome-prompts)!+- Explore or contribute to [`awesome-browser-use-prompts`](https://github.com/browser-use/awesome-prompts)!-### The Contribution Process+### Making a Great Pull Request+When submitting a pull request, please:-1. Create a [new issue](https://github.com/browser-use/browser-use/issues) and describe your desired change, or comment on an existing issue that you want to work on-2. Create a new [**`Draft` Pull Request**](https://github.blog/news-insights/product-news/introducing-draft-pull-requests/) *immediately* when you start work, and push your commits as you go, don't wait until you finish to open a PR!- - we won't review `Draft` pull requests until you mark them as [`[Ready for Review]`](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests)- - tests & linter don't have to pass for every single draft commit, we only care about final commit when marked ready to review- - draft PRs allow us to provide feedback & guidance on direction *before* you invest a ton of time making a perfect PR- - draft PRs allow others to see your work-in-progress + help test and share comments / avoid merge conflicts with their own work-3. Once it's ready for review and all the CI tests and linters pass, mark it [`[Ready for Review]`](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request)-4. Someone on our team will take a look and merge it or ask for changes- - small PRs are often reviewed and merged hours of being opened! (the smaller your PR is the faster we can merge it)- - large PRs may take days to ~weeks to review and merge- - if you don't get a response within a week, ping `@pirate` or another team member to bump it in our queue---> [!NOTE]-> If it's a very small bugfix or `<20` line change, you can skip some of these steps, use your best judgement.---### How We Prioritize PRs---> [!TIP]->-> - π we like PRs for any issue marked [`#help wanted`](https://github.com/browser-use/browser-use/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22help%20wanted%22) or [`#good first issue`](https://github.com/browser-use/browser-use/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22)-> - π we like PRs that include one or more screenrecordings of the agent running on different sites-> - π we like small `<50` line PRs that focus on a single bugfix, feature, or refactored function--> [!WARNING]-- π we deprioritize PRs that don't include a screenrecording/gif/screenshot proof of the new feature working when run-- π we deprioritize PRs that dont include a test in `tests/ci/test_....py` covering all new code paths-- π we deprioritize PRs that change the default actions / system prompt without evidence that you have spot checked it on a range of real-world tasks--> [!CAUTION]->-> - β we reject typo/style-only PRs, only touch existing code if you are already changing it as part of a bugfix or new feature!-> - β we reject `>200`-line sprawling PRs with mixtures of new features and random bugfixes / refactoring, split it up into separate bugfix and new feature PRs!-> - β we reject any PRs that lower our real-world eval scores (visible only to us, we will comment if this is the case)-+- Include a clear description of what the PR does and why it's needed+- Add tests that cover your changes+- Include a demo screenshot/gif or an example script demonstrating your changes+- Make sure the PR passes all CI checks and tests+- Keep your PR focused on a single issue or feature to make it easier to review+Note: We appreciate quality over quantity. Instead of submitting small typo/style-only PRs, consider including those fixes as part of larger bugfix or feature PRs.### Contribution Process1. Fork the repository-2. Create a new branch for your feature or bugfix, open a draft PR on our repo for it-3. Make your changes and push commits to your draft PR periodically-4. Run `./bin/tests.sh` and `./bin/lint.sh` to ensure everything works-5. Mark your PR "Ready for Review"-6. Respond to any feedback from maintainers, wait for it to be merged-7. Celebrate your contribution on Discord/X/Linkedin!--> [!TIP]-> **If your PR or issue doesn't get a response within a week:**->-> Break your PR up into smaller PRs and submit them individually, or @mention `@pirate` or the last person who touched the code to ping them for a response.-+2. Create a new branch for your feature or bugfix+3. Make your changes+4. Run tests to ensure everything works+5. Submit a pull request+6. Respond to any feedback from maintainers+7. Celebrate your contribution!++Feel free to bump your issues/PRs with comments periodically if you need faster feedback.## Code of Conductdiff --git a/docs/development/local-setup.mdx b/docs/development/local-setup.mdxindex c6d01531b..559060ee7 100644--- a/docs/development/local-setup.mdx+++ b/docs/development/local-setup.mdx@@ -56,7 +56,7 @@ cd browser-use1. Create and activate a virtual environment:```bash-uv venv+uv venv --python 3.11source .venv/bin/activate```@@ -64,7 +64,7 @@ source .venv/bin/activate```bash# Install the package in editable mode with all development dependencies-uv sync --all-extras --upgrade+uv sync --all-extras# Install the default browserplaywright install chromium --with-deps --no-shelldiff --git a/docs/quickstart.mdx b/docs/quickstart.mdxindex 9d30dead0..aea07056a 100644--- a/docs/quickstart.mdx+++ b/docs/quickstart.mdx@@ -13,7 +13,7 @@ Browser Use requires Python 3.11 or higher.First, we recommend using [uv](https://docs.astral.sh/uv/) to setup the Python environment.```bash-uv venv+uv venv --python 3.11```and activate it with:diff --git a/pyproject.toml b/pyproject.tomlindex 55a9973c8..3dfac6cd4 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -2,7 +2,7 @@name = "browser-use"description = "Make websites accessible for AI agents"authors = [{ name = "Gregor Zunic" }]-version = "0.2.6"+version = "0.2.5"readme = "README.md"requires-python = ">=3.11,<4.0"classifiers = [@@ -13,31 +13,32 @@ classifiers = [dependencies = ["anyio>=4.9.0","httpx>=0.27.2",- "pydantic>=2.11.5",+ "pydantic>=2.10.4,<2.11.0","python-dotenv>=1.0.1","requests>=2.32.3","posthog>=3.7.0","playwright>=1.52.0","markdownify==1.1.0",- "langchain-core==0.3.63",- "langchain-openai==0.3.19",- "langchain-anthropic==0.3.14",- "langchain-ollama==0.3.3",- "langchain-google-genai==2.1.5",+ "langchain-core==0.3.49",+ "langchain-openai==0.3.11",+ "langchain-anthropic==0.3.3",+ "langchain-ollama==0.3.0",+ "langchain-google-genai==2.1.2","langchain-deepseek>=0.1.3",- "langchain>=0.3.25",- "langchain-aws>=0.2.24",- "google-api-core>=2.25.0",+ "langchain>=0.3.21",+ "langchain-aws>=0.2.11",+ "google-api-core>=2.24.0","pyperclip>=1.9.0","pyobjc>=11.0; platform_system == 'darwin'","screeninfo>=0.8.1; platform_system != 'darwin'","typing-extensions>=4.12.2","psutil>=7.0.0",- "faiss-cpu>=1.11.0",- "mem0ai>=0.1.104",+ "faiss-cpu>=1.9.0",+ "mem0ai==0.1.93","uuid7>=0.1.0","patchright>=1.52.4",]+# pydantic: >2.11 introduces many pydantic deprecation warnings until langchain-core upgrades their pydantic support lets keep it on 2.10# google-api-core: only used for Google LLM APIs# pyperclip: only used for examples that use copy/paste# pyobjc: only used to get screen resolution on macOS@@ -82,7 +83,7 @@ build-backend = "hatchling.build"[tool.codespell]-ignore-words-list = "bu,wit,dont,cant,wont,re-use,re-used,re-using,thats"+ignore-words-list = "bu,wit,dont,cant,wont,re-use,re-used,re-using,re-usable,thats,doesnt"skip = "*.json"[tool.ruff]