Skip to content

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

better cross-linking between docs

Nick Sweetingf44a6d5be8eb
diff --git a/docs/customize/agent-settings.mdx b/docs/customize/agent-settings.mdx
index cbfc4e4f7..e79fa9548 100644
--- a/docs/customize/agent-settings.mdx
+++ b/docs/customize/agent-settings.mdx
@@ -56,79 +56,62 @@ agent = Agent(
support.
</Note>
-## (Reuse) Browser Configuration
-You can configure how the agent interacts with the browser. To see more `Browser` options refer to the <a href="/customize/browser-settings">Browser Settings</a> documentation.
+### Reuse Existing Browser Context
-### Reuse Existing Browser
+By default browser-use launches its own builtin browser using playwright chromium.
+You can also connect to a remote browser or pass any of the following
+existing playwright objects to the Agent: `page`, `browser_context`, `browser`, `browser_session`, or `browser_profile`.
-`browser`: A Browser Use Browser instance. When provided, the agent will reuse this browser instance and automatically create new contexts for each `run()`.
+These all get passed down to create a `BrowserSession` for the `Agent`:
-```python
-from browser_use import Agent, Browser
-from browser_use.browser.context import BrowserContext
-# Reuse existing browser
-browser = Browser()
+```python
agent = Agent(
- task=task1,
+ task='book a flight to fiji',
llm=llm,
- browser=browser # Browser instance will be reused
+ browser_profile=browser_profile, # use this profile to create a BrowserSession
+ browser_session=BrowserSession( # use an existing BrowserSession
+ cdp_url=..., # remote CDP browser to connect to
+ # or
+ wss_url=..., # remote wss playwright server provider
+ # or
+ browser_pid=... # pid of a locally running browser process to attach to
+ # or
+ executable_path=... # provide a custom chrome binary path
+ # or
+ channel=... # specify chrome, chromium, ms-edge, etc.
+ # or
+ page=page, # use an existing playwright Page object
+ # or
+ browser_context=browser_context, # use an existing playwright BrowserContext object
+ # or
+ browser=browser, # use an existing playwright Browser object
+ ),
)
-
-await agent.run()
-
-# Manually close the browser
-await browser.close()
```
-<Note>
- Remember: in this scenario the `Browser` will not be closed automatically.
-</Note>
-
-### Reuse Existing Browser Context
-
-You can pass any of the following Playwright objects to the Agent: `page`, `browser_context`, `browser`, `browser_session`, or `browser_profile`. These all get passed down to create a `BrowserSession`:
-
+For example, to connect to an existing browser over CDP you could do:
```python
-browser_session = browser_session or BrowserSession(page, browser_context, browser_profile)
+agent = Agent(
+ ...
+ browser_session=BrowserSession(cdp_url='http://localhost:9222'),
+)
```
-`browser_context`: A Playwright browser context. Useful for maintaining persistent sessions. See <a href="/customize/persistent-browser">Persistent Browser</a> for more details.
-
+For example, to connect to a local running chrome instance you can do:
```python
-from browser_use import Agent, Browser
-from playwright.async_api import BrowserContext
-
-# Use specific browser context (preferred method)
-async with await browser.new_context() as context:
- agent = Agent(
- task=task2,
- llm=llm,
- browser_context=context # Use persistent context
- )
-
- # Run the agent
- await agent.run()
-
- # Pass the context to the next agent
- next_agent = Agent(
- task=task2,
- llm=llm,
- browser_context=context
- )
-
+agent = Agent(
...
-
-await browser.close()
+ browser_session=BrowserSession(browser_pid=1234),
+)
```
-For more information about how browser context works, refer to the [Playwright
-documentation](https://playwright.dev/docs/api/class-browsercontext).
+See <a href="/customize/real-browser">Connect to your Browser</a> for more info.
<Note>
- You can reuse the same context for multiple agents. If you do nothing, the
- browser will be automatically created and closed on `run()` completion.
+ You can reuse the same `BrowserSession` after an agent has completed running. If you do nothing, the
+ browser will be automatically closed on `run()` completion only if it was launched by us.
</Note>
## Running the Agent
diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdx
index 674f986fa..8c67e01e6 100644
--- a/docs/customize/browser-settings.mdx
+++ b/docs/customize/browser-settings.mdx
@@ -40,13 +40,13 @@ agent = Agent(
Runs the browser without a visible UI. If None, auto-detects based on display availability.
- **disable_security** (bool, default: `False`)
- Disables browser security features. While this can fix certain functionality issues (like cross-site iFrames), it should be used cautiously.
+ Completely disables all basic browser security features. Allows interacting across cross-site iFrames boundaries, but very INSECURE, don't visit untrusted URLs or use cookies.
- **keep_alive** (bool | None, default: `None`)
Keeps the browser alive after the agent has finished running. Useful for running multiple tasks with the same browser instance.
- **user_data_dir** (str | Path | None, default: `'~/.config/browseruse/profiles/default'`)
- Directory for browser profile data. Set to None for incognito mode.
+ Directory for browser profile data. Set to None to use an ephemeral profile aka incognito mode.
- **channel** (BrowserChannel, default: `'chromium'`)
Browser channel: `'chromium'`, `'chrome'`, `'chrome-beta'`, `'chrome-dev'`, `'chrome-canary'`, `'msedge'`, `'msedge-beta'`, `'msedge-dev'`, `'msedge-canary'`
@@ -72,7 +72,7 @@ agent = Agent(
## Alternative Initialization
-BrowserSession supports multiple ways to connect to browsers:
+`BrowserSession` supports multiple ways to connect to browsers:
### External Browser Provider (wss)