Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Remove 25 unused parameters

Magnus Müller78cb7e5466a2
diff --git a/.cursor/rules/browser-use-rules.mdc b/.cursor/rules/browser-use-rules.mdc
index eac6ccc7b..58a192f65 100644
--- a/.cursor/rules/browser-use-rules.mdc
+++ b/.cursor/rules/browser-use-rules.mdc
@@ -6,23 +6,7 @@ alwaysApply: true
## 🧠 General Guidelines for Contributing to `browser-use`
-**Browser-Use** is an AI agent that autonomously interacts with the web. It takes a user-defined task, navigates web pages using Chromium via CDP, processes HTML, and repeatedly queries a language model (like `gpt-4o`) to decide the next action—until the task is completed.
-
-### 🗂️ File Documentation
-
-When you create a **new file**:
-
-- **For humans**: At the top of the file, include a docstring in natural language explaining:
-
- - What this file does.
- - How it fits into the browser-use system.
- - If it introduces a new abstraction or replaces an old one.
-
-- **For LLMs/AI**: Include structured metadata using standardized comments such as:
-
- ```python
- # @file purpose: Defines <purpose>
- ```
+**Browser-Use** is an AI agent that autonomously interacts with the web. It takes a user-defined task, navigates web pages using Chromium via CDP, processes HTML, and repeatedly queries a language model (like `gpt-4.1-mini`) to decide the next action—until the task is completed.
---
@@ -48,22 +32,7 @@ uv sync
---
-## ⚙️ Adding New Actions
-To add a new action that your browser agent can execute:
-
-```python
-from playwright.async_api import Page
-from browser_use.core.tools import Tools, ActionResult
-
-tools = Tools()
-
[email protected]("Search the web for a specific query")
-async def search_web(query: str, page: Page):
- # Implement your logic here, e.g., query a search engine and return results
- result = ...
- return ActionResult(extracted_content=result, include_in_memory=True)
-```
### Notes:
diff --git a/browser_use/browser/profile.py b/browser_use/browser/profile.py
index c05906a4c..91e5289f1 100644
--- a/browser_use/browser/profile.py
+++ b/browser_use/browser/profile.py
@@ -4,7 +4,6 @@ from collections.abc import Iterable
from enum import Enum
from functools import cache
from pathlib import Path
-from re import Pattern
from typing import Annotated, Any, Literal, Self
from urllib.parse import urlparse
@@ -250,36 +249,6 @@ def validate_cli_arg(arg: str) -> str:
# ===== Enum definitions =====
-class ColorScheme(str, Enum):
- LIGHT = 'light'
- DARK = 'dark'
- NO_PREFERENCE = 'no-preference'
- NULL = 'null'
-
-
-class Contrast(str, Enum):
- NO_PREFERENCE = 'no-preference'
- MORE = 'more'
- NULL = 'null'
-
-
-class ReducedMotion(str, Enum):
- REDUCE = 'reduce'
- NO_PREFERENCE = 'no-preference'
- NULL = 'null'
-
-
-class ForcedColors(str, Enum):
- ACTIVE = 'active'
- NONE = 'none'
- NULL = 'null'
-
-
-class ServiceWorkers(str, Enum):
- ALLOW = 'allow'
- BLOCK = 'block'
-
-
class RecordHarContent(str, Enum):
OMIT = 'omit'
EMBED = 'embed'
@@ -329,8 +298,6 @@ class BrowserContextArgs(BaseModel):
# Browser context parameters
accept_downloads: bool = True
- offline: bool = False
- strict_selectors: bool = False
# Security options
# proxy: ProxySettings | None = None
@@ -340,14 +307,8 @@ class BrowserContextArgs(BaseModel):
# clipboardReadWrite is for google sheets and pyperclip automations
# notifications are to avoid browser fingerprinting
)
- bypass_csp: bool = False
# client_certificates: list[ClientCertificate] = Field(default_factory=list)
- extra_http_headers: dict[str, str] = Field(default_factory=dict)
# http_credentials: HttpCredentials | None = None
- ignore_https_errors: bool = False
- java_script_enabled: bool = True
- base_url: UrlStr | None = None
- service_workers: ServiceWorkers = ServiceWorkers.ALLOW
# Viewport options
user_agent: str | None = None
@@ -355,26 +316,15 @@ class BrowserContextArgs(BaseModel):
viewport: ViewportSize | None = Field(default=None)
no_viewport: bool | None = None
device_scale_factor: NonNegativeFloat | None = None
- is_mobile: bool = False
- has_touch: bool = False
- locale: str | None = None
# geolocation: Geolocation | None = None
- timezone_id: str | None = None
- color_scheme: ColorScheme = ColorScheme.LIGHT
- contrast: Contrast = Contrast.NO_PREFERENCE
- reduced_motion: ReducedMotion = ReducedMotion.NO_PREFERENCE
- forced_colors: ForcedColors = ForcedColors.NONE
# Recording Options
record_har_content: RecordHarContent = RecordHarContent.EMBED
record_har_mode: RecordHarMode = RecordHarMode.FULL
- record_har_omit_content: bool = False
record_har_path: str | Path | None = Field(default=None, validation_alias=AliasChoices('save_har_path', 'record_har_path'))
- record_har_url_filter: str | Pattern | None = None
record_video_dir: str | Path | None = Field(
default=None, validation_alias=AliasChoices('save_recording_path', 'record_video_dir')
)
- record_video_size: ViewportSize | None = None
class BrowserConnectArgs(BaseModel):
@@ -389,8 +339,6 @@ class BrowserConnectArgs(BaseModel):
model_config = ConfigDict(extra='ignore', validate_assignment=True, revalidate_instances='always', populate_by_name=True)
headers: dict[str, str] | None = Field(default=None, description='Additional HTTP headers to be sent with connect request')
- slow_mo: float = 0.0
- timeout: float = 30_000
class BrowserLaunchArgs(BaseModel):
@@ -440,8 +388,7 @@ class BrowserLaunchArgs(BaseModel):
devtools: bool = Field(
default=False, description='Whether to open DevTools panel automatically for every page, only works when headless=False.'
)
- slow_mo: float = Field(default=0, description='Slow down actions by this many milliseconds.')
- timeout: float = Field(default=30000, description='Default timeout in milliseconds for connecting to a remote browser.')
+
# proxy: ProxySettings | None = Field(default=None, description='Proxy settings to use to connect to the browser.')
downloads_path: str | Path | None = Field(
default=None,
@@ -453,15 +400,7 @@ class BrowserLaunchArgs(BaseModel):
description='Directory for saving playwright trace.zip files (playwright actions, screenshots, DOM snapshots, HAR traces).',
validation_alias=AliasChoices('trace_path', 'traces_dir'),
)
- handle_sighup: bool = Field(
- default=True, description='Whether playwright should swallow SIGHUP signals and kill the browser.'
- )
- handle_sigint: bool = Field(
- default=False, description='Whether playwright should swallow SIGINT signals and kill the browser.'
- )
- handle_sigterm: bool = Field(
- default=False, description='Whether playwright should swallow SIGTERM signals and kill the browser.'
- )
+
# firefox_user_prefs: dict[str, str | float | bool] = Field(default_factory=dict)
@model_validator(mode='after')
@@ -636,17 +575,15 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Bro
)
# --- Page load/wait timings ---
- default_navigation_timeout: float | None = Field(default=None, description='Default page navigation timeout.')
- default_timeout: float | None = Field(default=None, description='Default playwright call timeout.')
+
minimum_wait_page_load_time: float = Field(default=0.25, description='Minimum time to wait before capturing page state.')
wait_for_network_idle_page_load_time: float = Field(default=0.5, description='Time to wait for network idle.')
- maximum_wait_page_load_time: float = Field(default=5.0, description='Maximum time to wait for page load.')
+
wait_between_actions: float = Field(default=0.5, description='Time to wait between actions.')
# --- UI/viewport/DOM ---
- include_dynamic_attributes: bool = Field(default=True, description='Include dynamic attributes in selectors.')
+
highlight_elements: bool = Field(default=True, description='Highlight interactive elements on the page.')
- viewport_expansion: int = Field(default=500, description='Viewport expansion in pixels for LLM context.')
# --- Downloads ---
auto_download_pdfs: bool = Field(default=True, description='Automatically download PDFs when navigating to PDF viewer pages.')
@@ -658,10 +595,6 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Bro
# save_har_path: alias of record_har_path
# trace_path: alias of traces_dir
- cookies_file: Path | None = Field(
- default=None, description='File to save cookies to. DEPRECATED, use `storage_state` instead.'
- )
-
# TODO: finish implementing extension support in extensions.py
# extension_ids_to_preinstall: list[str] = Field(
# default_factory=list, description='List of Chrome extension IDs to preinstall.'
@@ -697,12 +630,10 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Bro
"""Warn when both storage_state and user_data_dir are set, as this can cause conflicts."""
has_storage_state = self.storage_state is not None
has_user_data_dir = (self.user_data_dir is not None) and ('tmp' not in str(self.user_data_dir).lower())
- has_cookies_file = self.cookies_file is not None
- static_source = 'cookies_file' if has_cookies_file else 'storage_state' if has_storage_state else None
- if static_source and has_user_data_dir:
+ if has_storage_state and has_user_data_dir:
logger.warning(
- f'⚠️ BrowserSession(...) was passed both {static_source} AND user_data_dir. {static_source}={self.storage_state or self.cookies_file} will forcibly overwrite '
+ f'⚠️ BrowserSession(...) was passed both storage_state AND user_data_dir. storage_state={self.storage_state} will forcibly overwrite '
f'cookies/localStorage/sessionStorage in user_data_dir={self.user_data_dir}. '
f'For multiple browsers in parallel, use only storage_state with user_data_dir=None, '
f'or use a separate user_data_dir for each browser and set storage_state=None.'
@@ -961,22 +892,6 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Bro
os.unlink(temp_zip.name)
- def kwargs_for_launch_persistent_context(self) -> BrowserLaunchPersistentContextArgs:
- """Return the kwargs for BrowserType.launch()."""
- return BrowserLaunchPersistentContextArgs(**self.model_dump(exclude={'args'}), args=self.get_args())
-
- def kwargs_for_new_context(self) -> BrowserNewContextArgs:
- """Return the kwargs for BrowserContext.new_context()."""
- return BrowserNewContextArgs(**self.model_dump(exclude={'args'}))
-
- def kwargs_for_connect(self) -> BrowserConnectArgs:
- """Return the kwargs for BrowserType.connect()."""
- return BrowserConnectArgs(**self.model_dump(exclude={'args'}))
-
- def kwargs_for_launch(self) -> BrowserLaunchArgs:
- """Return the kwargs for BrowserType.connect_over_cdp()."""
- return BrowserLaunchArgs(**self.model_dump(exclude={'args'}), args=self.get_args())
-
@observe_debug(ignore_input=True, ignore_output=True, name='detect_display_configuration')
def detect_display_configuration(self) -> None:
"""
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 1d96a5781..5176046be 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -224,8 +224,6 @@ class BrowserSession(BaseModel):
# BrowserProfile fields that can be passed directly
# From BrowserConnectArgs
headers: dict[str, str] | None = None,
- slow_mo: float | None = None,
- timeout: float | None = None,
# From BrowserLaunchArgs
env: dict[str, str | float | bool] | None = None,
executable_path: str | Path | None = None,
@@ -237,40 +235,18 @@ class BrowserSession(BaseModel):
devtools: bool | None = None,
downloads_path: str | Path | None = None,
traces_dir: str | Path | None = None,
- handle_sighup: bool | None = None,
- handle_sigint: bool | None = None,
- handle_sigterm: bool | None = None,
# From BrowserContextArgs
accept_downloads: bool | None = None,
- offline: bool | None = None,
- strict_selectors: bool | None = None,
permissions: list[str] | None = None,
- bypass_csp: bool | None = None,
- extra_http_headers: dict[str, str] | None = None,
- ignore_https_errors: bool | None = None,
- java_script_enabled: bool | None = None,
- base_url: str | None = None,
- service_workers: str | None = None,
user_agent: str | None = None,
screen: dict | None = None,
viewport: dict | None = None,
no_viewport: bool | None = None,
device_scale_factor: float | None = None,
- is_mobile: bool | None = None,
- has_touch: bool | None = None,
- locale: str | None = None,
- timezone_id: str | None = None,
- color_scheme: str | None = None,
- contrast: str | None = None,
- reduced_motion: str | None = None,
- forced_colors: str | None = None,
record_har_content: str | None = None,
record_har_mode: str | None = None,
- record_har_omit_content: bool | None = None,
record_har_path: str | Path | None = None,
- record_har_url_filter: str | None = None,
record_video_dir: str | Path | None = None,
- record_video_size: dict | None = None,
# From BrowserLaunchPersistentContextArgs
user_data_dir: str | Path | None = None,
# From BrowserNewContextArgs
@@ -286,18 +262,12 @@ class BrowserSession(BaseModel):
window_size: dict | None = None,
window_position: dict | None = None,
cross_origin_iframes: bool | None = None,
- default_navigation_timeout: float | None = None,
- default_timeout: float | None = None,
minimum_wait_page_load_time: float | None = None,
wait_for_network_idle_page_load_time: float | None = None,
- maximum_wait_page_load_time: float | None = None,
wait_between_actions: float | None = None,
- include_dynamic_attributes: bool | None = None,
highlight_elements: bool | None = None,
- viewport_expansion: int | None = None,
auto_download_pdfs: bool | None = None,
profile_directory: str | None = None,
- cookies_file: Path | None = None,
):
# Following the same pattern as AgentSettings in service.py
# Only pass non-None values to avoid validation errors
@@ -1070,7 +1040,8 @@ class BrowserSession(BaseModel):
# Run a tiny HTTP client to query for the WebSocket URL from the /json/version endpoint
async with httpx.AsyncClient() as client:
- version_info = await client.get(url)
+ headers = self.browser_profile.headers or {}
+ version_info = await client.get(url, headers=headers)
self.browser_profile.cdp_url = version_info.json()['webSocketDebuggerUrl']
assert self.cdp_url is not None
diff --git a/browser_use/mcp/server.py b/browser_use/mcp/server.py
index a736dceb0..0219008db 100644
--- a/browser_use/mcp/server.py
+++ b/browser_use/mcp/server.py
@@ -465,7 +465,6 @@ class BrowserUseServer:
'wait_between_actions': 0.5,
'keep_alive': True,
'user_data_dir': '~/.config/browseruse/profiles/default',
- 'is_mobile': False,
'device_scale_factor': 1.0,
'disable_security': False,
'headless': False,
diff --git a/docs/customize/browser/all-parameters.mdx b/docs/customize/browser/all-parameters.mdx
index 3f884684d..2e6fb5bbf 100644
--- a/docs/customize/browser/all-parameters.mdx
+++ b/docs/customize/browser/all-parameters.mdx
@@ -16,10 +16,8 @@ mode: "wide"
- `viewport`: Content area size, same format as `window_size`. Use `{'width': 1280, 'height': 720}` or `ViewportSize` object
- `no_viewport` (default: `None`): Disable viewport emulation, content fits to window size
- `device_scale_factor`: Device scale factor (DPI). Set to `2.0` or `3.0` for high-resolution screenshots
-- `color_scheme` (default: `'light'`): Preferred color scheme (`'light'`, `'dark'`, `'no-preference'`)
-- `contrast` (default: `'no-preference'`): High contrast mode (`'no-preference'`, `'more'`)
-- `reduced_motion` (default: `'no-preference'`): Motion preference (`'reduce'`, `'no-preference'`)
-- `forced_colors` (default: `'none'`): Forced colors mode (`'active'`, `'none'`)
+
+
## Browser Behavior
- `stealth` (default: `False`): Use stealth techniques to avoid bot detection
@@ -38,16 +36,14 @@ mode: "wide"
- `user_data_dir` (default: auto-generated temp): Directory for browser profile data. Use `None` for incognito mode
- `profile_directory` (default: `'Default'`): Chrome profile subdirectory name (`'Profile 1'`, `'Work Profile'`, etc.)
- `storage_state`: Browser storage state (cookies, localStorage). Can be file path string or dict object
-- `cookies_file`: **DEPRECATED** - Use `storage_state` instead
## Network & Security
- `proxy`: Proxy configuration using `ProxySettings(server='http://host:8080', bypass='localhost,127.0.0.1', username='user', password='pass')`
- `permissions` (default: `['clipboardReadWrite', 'notifications']`): Browser permissions to grant. Use list like `['camera', 'microphone', 'geolocation']`
-- `bypass_csp` (default: `False`): Bypass Content Security Policy (increases bot detection risk)
-- `ignore_https_errors` (default: `False`): Ignore HTTPS certificate errors
-- `extra_http_headers`: Additional HTTP headers sent with every request. Use dict like `{'Accept-Language': 'en-US', 'Custom-Header': 'value'}`
+
- `headers`: Additional HTTP headers for connect requests (remote browsers only)
+
## Browser Launch
- `executable_path`: Path to browser executable for custom installations. Platform examples:
- macOS: `'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'`
@@ -61,19 +57,12 @@ mode: "wide"
- `ignore_default_args`: List of default args to disable, or `True` to disable all. Use list like `['--enable-automation', '--disable-extensions']`
## Timing & Performance
-- `slow_mo` (default: `0.0`): Slow down actions by this many milliseconds
-- `timeout` (default: `30000`): Default timeout for browser operations in milliseconds
-- `default_timeout`: Default timeout for playwright calls in milliseconds
-- `default_navigation_timeout`: Default timeout for page navigation in milliseconds
- `minimum_wait_page_load_time` (default: `0.25`): Minimum time to wait before capturing page state in seconds
- `wait_for_network_idle_page_load_time` (default: `0.5`): Time to wait for network activity to cease in seconds
-- `maximum_wait_page_load_time` (default: `5.0`): Maximum time to wait for page load in seconds
- `wait_between_actions` (default: `0.5`): Time to wait between agent actions in seconds
## AI Integration
- `highlight_elements` (default: `True`): Highlight interactive elements for AI vision
-- `viewport_expansion` (default: `500`): Viewport expansion in pixels for AI context
-- `include_dynamic_attributes` (default: `True`): Include dynamic attributes in selectors for better element identification
## Downloads & Files
- `accept_downloads` (default: `True`): Automatically accept all downloads
@@ -82,10 +71,6 @@ mode: "wide"
## Device Emulation
- `user_agent`: Custom user agent string. Example: `'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)'`
-- `is_mobile` (default: `False`): Enable mobile viewport and touch events
-- `has_touch` (default: `False`): Enable touch events for mobile emulation
-- `locale`: User locale like `'en-GB'`, `'de-DE'`, `'ja-JP'`
-- `timezone_id`: Timezone identifier like `'America/New_York'`, `'Europe/London'`, `'UTC'`
- `screen`: Screen size information, same format as `window_size`
## Recording & Debugging
@@ -98,11 +83,6 @@ mode: "wide"
## Advanced Options
- `disable_security` (default: `False`): ⚠️ **NOT RECOMMENDED** - Disables all browser security features
- `deterministic_rendering` (default: `False`): ⚠️ **NOT RECOMMENDED** - Forces consistent rendering but reduces performance
-- `java_script_enabled` (default: `True`): Enable/disable JavaScript execution
-- `offline` (default: `False`): Start browser in offline mode
-- `strict_selectors` (default: `False`): Use strict selector matching
-- `base_url`: Base URL for relative navigation
-- `service_workers` (default: `'allow'`): Service worker policy (`'allow'`, `'block'`)
---