Commit Graph

8459 Commits

Author SHA1 Message Date
Mert Unsal f47d331cfe fix: Cascading element matching for history rerun stability (#3781)
## Problem

History rerun was failing when CSS classes changed between recording and
replay. The `element_hash` includes `class` attribute, but classes like
`gw-focus`, `gw-animation--focus`, `hover`, etc. change dynamically
based on UI state.

**Example:**
- Recording: `class="gw-animation--focus gw-focus"` → hash A
- Replay: `class="gw-focus"` → hash B
- Result: **Match fails**, rerun breaks

## Solution

Implemented a **cascading element matching strategy** with 3 levels:

| Level | Name | Description | Confidence |
|-------|------|-------------|------------|
| 1 | EXACT | Full element_hash match | 100% |
| 2 | STABLE | Hash with dynamic classes filtered | 98% |
| 3 | XPATH | XPath string match | 95% |

### Key Changes

1. **Added `filter_dynamic_classes()`** - Filters out transient CSS
patterns:
   - `focus`, `hover`, `active`, `selected`, `disabled`
   - `animation`, `transition`, `loading`
   - `expanded`, `collapsed`, `visible`, `hidden`, etc.

2. **Added `compute_stable_hash()`** to `EnhancedDOMTreeNode` - Single
source of truth for stable hash computation

3. **Added `stable_hash` field** to `DOMInteractedElement` - Computed at
save time from the source `EnhancedDOMTreeNode`

4. **Updated `_update_action_indices()`** - Tries each match level in
order until success

### Backward Compatibility

- Old history files without `stable_hash` field load fine (defaults to
`None`)
- Falls back to XPATH matching for old files

### Verification

```
NOT_WORKING class: "gw-animation--focus gw-focus"
WORKING class:     "gw-focus"

After filter_dynamic_classes:
NOT_WORKING: ""
WORKING:     ""

EXACT level:  ❌ Different hashes
STABLE level: ✅ Same hash (13488107035447772127)
```

## Files Changed

- `browser_use/dom/views.py` - Added MatchLevel, DYNAMIC_CLASS_PATTERNS,
filter_dynamic_classes, compute_stable_hash, stable_hash field
- `browser_use/agent/service.py` - Updated _update_action_indices with
cascading logic



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Stabilizes history rerun by using cascading element matching when CSS
classes change between record and replay. Filters transient classes to
compute a stable hash and falls back to XPath when needed.

- **Bug Fixes**
- Cascading matching: EXACT hash → STABLE hash (dynamic classes
filtered) → XPATH.
- Added filter_dynamic_classes and compute_stable_hash; stored
stable_hash in DOMInteractedElement.
- Backward compatible: old histories load; XPath used when stable_hash
is missing.
- Improved logs show match level; action indices update when the element
moves.

<sup>Written for commit bc9b51055b.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-17 01:00:20 -08:00
Mert Unsal bc9b51055b Merge branch 'main' into mert/rerunhist 2025-12-17 00:57:55 -08:00
mertunsall 1779e9717d improve hashing of elements using cascading hash 2025-12-17 00:55:27 -08:00
Steven Beverly 97ce4a85b3 Fix glob pattern for Playwright browser paths
playwright 1.57.0 installs chromium to $playwright_path/chromium-*/chrome-linux64/, causing the existing paths to fail to find the browser. globing chrome-linux* will allow watchdog to find playwright installed 32-bit and 64-bit chromium.
2025-12-16 21:40:16 -07:00
Mert Unsal 9af7e0bf47 Dont skip failrues by default (#3777) 2025-12-16 20:05:02 -08:00
mertunsall 05b41f64a9 Dont skip failrues by default 2025-12-16 20:04:28 -08:00
Saurav Panda b607d2fc0b include ax_name for rerun history element hash (#3775)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Improve rerun history matching by including accessibility name in the
element hash and adding an XPath fallback. This reduces mismatches and
fixes action index rebuilds from older history files.

- **Bug Fixes**
- Element hash now includes ax_name to better distinguish similar
elements.
- Matching strategy tries element_hash first, then falls back to XPath
for legacy history.
- DOMInteractedElement now captures and serializes ax_name for
persistence.

<sup>Written for commit 1c57f2a1b2.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-16 17:31:16 -08:00
Saurav Panda 1c57f2a1b2 Merge branch 'main' into fix-rerun-history-find-hash 2025-12-16 17:17:39 -08:00
Saurav Panda e9c047be92 include ax_name for rerun history element hash 2025-12-16 17:05:48 -08:00
Mert Unsal 711dc343f6 Bu_oss example flash mode (#3774)
Enable `flash_mode=True` in the `bu_oss` example to use fast mode,
skipping evaluation, next goal, and thinking for faster execution.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765922746500689?thread_ts=1765922746.500689&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-f71e2229-3750-48fe-907d-3896d29c2398"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-f71e2229-3750-48fe-907d-3896d29c2398"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Turned on flash mode in the bu_oss example so the Agent runs faster. It
skips evaluation, next-goal selection, and thinking steps to return
results quicker.

<sup>Written for commit b79dffeca4.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-16 14:09:28 -08:00
Cursor Agent b79dffeca4 feat: Enable flash mode for Agent in bu_oss example
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-16 22:06:49 +00:00
Mert Unsal a102128317 Pyproject version bump (#3773)
Bump `pyproject.toml` version from `0.11.1` to `0.11.2`.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765922126302929?thread_ts=1765922126.302929&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-4b959505-0303-4830-9e98-bd8765b5d205"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-4b959505-0303-4830-9e98-bd8765b5d205"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Bumped package version in pyproject.toml from 0.11.1 to 0.11.2 to
publish a patch release.

<sup>Written for commit a87c19253d.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
0.11.2
2025-12-16 13:58:08 -08:00
Cursor Agent a87c19253d Bump version to 0.11.2
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-16 21:56:03 +00:00
SK Akram 557b0c016e fix: expose prohibited_domains in BrowserSession 2025-12-16 07:25:35 +00:00
Saurav Panda 7a0fbb89ce fix: prevent unnecessary blank tab creation when closing background tabs (#3766)
Fixes #3755

### Problem
When switching to a newly opened tab and closing background tabs, a new
blank tab was incorrectly created.

### Cause
In
[aboutblank_watchdog.py](https://github.com/browser-use/browser-use/blob/cfccc38d52aa853cd4b9b0c7b181e24ce518185e/browser_use/browser/watchdogs/aboutblank_watchdog.py#L72),
the condition `len(page_targets) <= 1` triggered blank tab creation even
when an active tab remained.

### Fix
Changed condition from `<= 1` to `< 1` on line 72, ensuring blank tabs
are only created when no tabs remain.



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Stops creating a blank tab when closing background tabs. A new
about:blank tab is only created when no tabs remain.

- **Bug Fixes**
- Updated aboutblank_watchdog check from len(page_targets) <= 1 to < 1.
- Prevents extra blank tab after switching to a new tab and closing
background tabs.

<sup>Written for commit b0fe15aeb2.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-15 20:07:39 -08:00
Sk Akram b0fe15aeb2 Merge branch 'main' into fix/aboutblank-unnecessary-tab-creation-3755 2025-12-16 09:30:18 +05:30
Mert Unsal a10e27a320 BU OSS Support :) (#3769)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds support for OSS Browser Use models via 'browser-use/*' names and
includes an example. Also sends the selected model and optional
session_id in API requests (sticky routing), and normalizes 'bu-latest'
to 'bu-1-0'.

- **New Features**
- Accept models that start with 'browser-use/' (e.g.,
'browser-use/bu-30b-a3b-preview').
- Added example script at examples/models/bu_oss.py showing OSS model
usage.

- **Bug Fixes**
- Include 'model' in the request payload so the API uses the selected
model.

<sup>Written for commit 781f6eb95e.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-15 18:38:36 -08:00
mertunsall 781f6eb95e coment 2025-12-15 18:32:52 -08:00
mertunsall dc0db88215 kv caching for BU agents 2025-12-15 18:23:22 -08:00
mertunsall ba9dd88ce1 Merge branch 'main' into mert/rerunhistory 2025-12-15 14:05:00 -08:00
mertunsall a58b9307ab BU OSS IS COMING 2025-12-15 14:04:18 -08:00
SK Akram 948f51b4db fix: prevent unnecessary blank tab creation when closing background tabs 2025-12-15 05:30:39 +00:00
Mert Unsal 50f3576ee4 max wait between execution (#3765)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds a max_step_interval to cap delays between replayed actions,
preventing long pauses from saved step intervals and making reruns more
predictable.

- **New Features**
- Added max_step_interval (default: 5s) to rerun_history and
load_and_rerun; caps saved step_interval when replaying history.
- Improved logs and docs: show when a delay is capped and clarified
kwargs (delay_between_actions, max_step_interval, summary_llm,
ai_step_llm).

<sup>Written for commit a0996ba39e.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-14 13:37:40 -08:00
Mert Unsal dd6aa26301 Merge branch 'main' into mert/rerunhistory 2025-12-14 13:36:12 -08:00
mertunsall a0996ba39e max wait between execution 2025-12-14 13:35:27 -08:00
Mert Unsal dd56615996 Merge branch 'main' into kalil0321/har_watchdog 2025-12-14 13:13:20 -08:00
Mert Unsal ad8911c25e Fix XAI vision check to only disable for grok-3 and grok-code models (#3762)
## Summary
  - Only disable `use_vision` for grok-3 variants and grok-code models
  - grok-2 and grok-4 models now retain vision support

  ## Test plan
  - [x] pyright passes
  - [x] vision-related CI tests pass

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fix XAI vision gating to apply only to unsupported models. use_vision is
now disabled only for grok-3 variants and grok-code; grok-2 and grok-4
keep vision enabled.

<sup>Written for commit cba65772f8.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-14 13:13:09 -08:00
Mert Unsal a8eb91d852 Merge branch 'main' into main 2025-12-14 13:11:55 -08:00
Mert Unsal 1e60ca3466 perf: lazy import for openai and reportlab to reduce startup latency (#3764)
## Summary: Improvement of lazy import
Users who don't use OpenAI provider (e.g., Anthropic, Google, Groq
users) were paying ~0.88s startup penalty due to openai SDK being
imported at module level. This PR eliminates that unnecessary overhead.

Additionally, reportlab was imported at module level in
`filesystem/file_system.py` even though PDF generation is rarely used.
By moving the import inside `sync_to_disk_sync()`, users who don't
generate PDFs avoid the unnecessary import cost.

## Modified files
- **agent/views.py**: Move `RateLimitError` import inside
`format_error()` function to avoid loading openai SDK at module level
- **llm/messages.py**: Replace `openai.BaseModel` with
`pydantic.BaseModel` directly to remove unnecessary openai dependency
- **filesystem/file_system.py**: Move reportlab imports inside
`sync_to_disk_sync()` to avoid startup cost when PDF generation is not
used
- **utils.py**: Convert `OpenAIBadRequestError` and
`GroqBadRequestError` to lazy loaders to avoid loading SDKs at module
level

## Performance Improvement (average of 20 iterations)

| Module | current main | PR (improved lazyimport) | Improvement |
|--------|-------------|-----------|-------------|
| `agent/views.py` | 2.272s  | 1.619s | **28.7% faster** |
| `ChatAnthropic` | 1.377s  | 0.894s | **35.1% faster** |

### Key Changes
- Removed OpenAI SDK loading  when using non-OpenAI providers
- reportlab is only  loaded when PDF generation is actually needed
- No behavioral changes - only import timing affected

## Test plan
- [x] `uv run ruff check` passes
- [x] `uv run pyright` passes (0 errors)
- [x] Runtime verification - lazy loading works correctly
- [x] Benchmark comparison against current main branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)





<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Reduce startup latency by lazily importing OpenAI and reportlab,
removing module-level SDK dependencies. Non-OpenAI providers avoid ~0.9s
overhead with no behavior changes.

- **Refactors**
- Lazy import openai.RateLimitError inside format_error
(agent/views.py).
  - Replace openai.BaseModel with pydantic.BaseModel (llm/messages.py).
- Lazy import reportlab inside sync_to_disk_sync
(filesystem/file_system.py).
  - Add lazy loaders for OpenAI/Groq BadRequestError (utils.py).
- Results: agent/views import 28.7% faster; ChatAnthropic path 35.1%
faster; reportlab loads only when generating PDFs.

<sup>Written for commit 38703d5ad7.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-14 11:48:20 -08:00
hacking-racoon 38703d5ad7 perf: lazy import for openai and reportlab to reduce startup latency
- agent/views.py: Move RateLimitError import inside format_error() function
  to avoid loading openai SDK (~800ms) at module level
- llm/messages.py: Replace openai.BaseModel with pydantic.BaseModel directly
  to remove unnecessary openai dependency
- filesystem/file_system.py: Move reportlab imports inside sync_to_disk_sync()
  to avoid ~40ms startup cost when PDF generation is not used
- utils.py: Convert OpenAIBadRequestError and GroqBadRequestError to lazy
  loaders to avoid loading SDKs at module level

This improves import time for users who don't use OpenAI provider,
especially when using Anthropic, Google, or other providers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 01:48:47 +09:00
bbarwik cba65772f8 Fix XAI vision check to only disable for grok-3 and grok-code models
Previously all grok models had vision disabled. Only grok-3 variants
(grok-3, grok-3-mini, grok-3-fast) and grok-code models don't support
vision. grok-2 and grok-4 models now correctly retain vision support.
2025-12-13 12:40:21 +01:00
Mert Unsal 63004c624e Pyproject version bump (#3760)
Bump pyproject.toml version to 0.11.1.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765582772365859?thread_ts=1765582772.365859&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-76ceb7a9-0457-4f46-bbf3-61004bef603d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-76ceb7a9-0457-4f46-bbf3-61004bef603d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Bumped the package version in pyproject.toml from 0.11.0 to 0.11.1 to
prepare the next patch release. This ensures the published artifact
reflects the latest changes.

<sup>Written for commit 06997afaa8.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
0.11.1
2025-12-12 15:40:56 -08:00
Cursor Agent 06997afaa8 Bump version to 0.11.1
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-12 23:40:21 +00:00
Mert Unsal a0095f918e Fix structured output for sandboxes (#3759)
# Fix: `output_model_schema` not working with `@sandbox`

## Problem

When using `output_model_schema` with an Agent inside a `@sandbox`
decorated function, the `history.structured_output` property always
returned `None`.

```python
@sandbox()
async def my_task(browser: Browser) -> AgentHistoryList[MyModel]:
    agent = Agent(task="...", browser=browser, llm=llm, output_model_schema=MyModel)
    return await agent.run()

result = await my_task()
result.structured_output  # Always None ❌
```

## Root Cause

`AgentHistoryList` stores the output schema in `_output_model_schema` —
a **Pydantic private attribute** (underscore prefix). Private attributes
are **not serialized** when converting to JSON.

When sandbox executes remotely:

1. Agent runs and sets `history._output_model_schema = MyOutputModel` ✅
2. Result is serialized to JSON for transport → **private attribute
dropped** ❌
3. Client reconstructs `AgentHistoryList` but `_output_model_schema` is
`None`
4. `structured_output` property returns `None` (schema missing)

## Solution

### 1. Added `get_structured_output(output_model)` method

Users can explicitly pass their schema to parse the result:

```python
result.get_structured_output(MyModel)  # Works even without type annotation
```

### 2. Enhanced sandbox parsing for Pydantic generics

When return type is `AgentHistoryList[MyModel]`, the sandbox now:
- Detects Pydantic generic metadata via `__pydantic_generic_metadata__`
- Extracts the type parameter (`MyModel`)
- Auto-sets `_output_model_schema` on the reconstructed object

### 3. Fixed import extraction for Pydantic generics

The sandbox's import extraction wasn't detecting `AgentHistoryList` from
return types like `AgentHistoryList[MyModel]`, causing `NameError` on
remote execution.

## Usage

### Option 1: Generic return type (recommended)

```python
@sandbox()
async def task(browser: Browser) -> AgentHistoryList[MyModel]:
    agent = Agent(task="...", browser=browser, llm=llm, output_model_schema=MyModel)
    return await agent.run()

result = await task()
result.structured_output  # ✅ Works automatically
```

### Option 2: Non-generic return type with explicit method

```python
@sandbox()
async def task(browser: Browser) -> AgentHistoryList:
    agent = Agent(task="...", browser=browser, llm=llm, output_model_schema=MyModel)
    return await agent.run()

result = await task()
result.structured_output  # None (expected)
result.get_structured_output(MyModel)  # ✅ Works
```

## Files Changed

- `browser_use/agent/views.py` - Added `get_structured_output()` method
- `browser_use/sandbox/sandbox.py` - Enhanced
`_parse_with_type_annotation()` and `_get_imports_used_in_function()`
for Pydantic generics
- `tests/ci/test_sandbox_structured_output.py` - Unit tests
- `examples/sandbox/structured_output.py` - Example demonstrating both
approaches



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes structured output when agents run inside @sandbox.
structured_output now works with AgentHistoryList[Model], and a new
helper lets you parse results without type annotations.

- **Bug Fixes**
- Preserve output model schema in sandbox results by detecting Pydantic
generics and setting it on AgentHistoryList.
- Improve import extraction to include generic types like
AgentHistoryList[MyModel] and prevent NameError.
- Enhance _parse_with_type_annotation to reconstruct AgentHistoryList[T]
and set _output_model_schema correctly.

- **New Features**
- Added AgentHistoryList.get_structured_output(schema) to parse the
final result explicitly when no generic return type is used.

<sup>Written for commit 9b894150d5.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-12 15:39:23 -08:00
mertunsall 9b894150d5 fix structured output for sandboxes 2025-12-12 15:35:34 -08:00
Mert Unsal 8a18ff3580 make coordinates optionally available (#3757)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Enable coordinate-based clicking only for supported models, keeping
clicks index-only by default. This reduces misclicks and keeps the API
simpler.

- **New Features**
- Auto-enable coordinate clicking for models matching: claude-sonnet-4,
claude-opus-4, gemini-3-pro, and browser-use/*.
- Added set_coordinate_clicking(enabled) to toggle coordinate support
and re-register the click action accordingly.
- New ClickElementActionIndexOnly model for index-only clicks;
coordinate and index handlers are retained and shared.

<sup>Written for commit 8c9e3b272c.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-12 14:47:20 -08:00
mertunsall 8c9e3b272c add tests 2025-12-12 14:37:24 -08:00
mertunsall 20247d5c56 make coordinates optionally available 2025-12-12 14:26:13 -08:00
Mert Unsal 463aa200d0 Browser logging constant documentation (#3756)
Update `BROWSER_USE_LOG_LEVEL` to `BROWSER_USE_LOGGING_LEVEL` in docs
and issue templates to reflect the correct environment variable.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765568387594429?thread_ts=1765568387.594429&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-1026a73d-001f-4cf3-9b58-fdc4d76051c4"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-1026a73d-001f-4cf3-9b58-fdc4d76051c4"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Use the correct env var name for debug logging across docs and issue
templates: BROWSER_USE_LOGGING_LEVEL. This fixes confusion when enabling
DEBUG logs.

- **Bug Fixes**
- Updated element detection and general bug report templates to use
BROWSER_USE_LOGGING_LEVEL.
- Corrected MCP server docs example to export
BROWSER_USE_LOGGING_LEVEL=DEBUG.

<sup>Written for commit db36243b5f.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-12 11:43:28 -08:00
Cursor Agent db36243b5f Fix typo in logging level environment variable
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-12 19:40:54 +00:00
Mert Unsal cfccc38d52 Filter sensitive data in history (#3750)
Re-enable sensitive data filtering for state messages to prevent real
sensitive values from action results leaking into LLM messages.

State messages, specifically the `agent_history_description`, include
action results which contain actual sensitive values (e.g., passwords)
after they've been replaced from placeholders during action execution.
The `_filter_sensitive_data` method was previously not called for state
messages, leading to these real values being sent to the LLM. This PR
ensures that state messages are properly filtered, replacing real
sensitive data with placeholder tags before being sent to the LLM. New
integration tests confirm the end-to-end filtering.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765410795078139?thread_ts=1765410795.078139&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-97cd8546-fd39-4e4f-84af-8882815d705b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-97cd8546-fd39-4e4f-84af-8882815d705b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>





<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Restored sensitive data filtering for state messages so real values from
action results never reach the LLM. Sensitive values like passwords and
API keys are replaced with placeholder tags in
agent_history_description.

- **Bug Fixes**
- Filter state messages in MessageManager when sensitive_data is
present; system/context messages remain unfiltered.
- Replace real values in action results with <secret>...</secret>
placeholders before sending to the LLM.
- Added integration tests covering global and domain-specific formats
(e.g., password, api_key) to prevent leaks.

<sup>Written for commit 201b990591.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-10 16:52:22 -08:00
Mert Unsal 201b990591 Merge branch 'main' into cursor/filter-sensitive-data-in-history-5b05 2025-12-10 16:14:01 -08:00
Mert Unsal 9273902621 Fix short line removal bug (#3749)
Fixes `_preprocess_markdown_content` to prevent silent removal of
legitimate short lines, ensuring complete markdown extraction for LLM
processing.

The previous logic `len(stripped) > 2` incorrectly filtered out valid
content like single letters, short words, and numbers, leading to data
loss in markdown output. The fix changes the condition to `if stripped:`
to only remove truly empty or whitespace-only lines, and new tests have
been added to verify this behavior.

---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1765410993261629?thread_ts=1765410993.261629&cid=D092QUQDC56)

<a
href="https://cursor.com/background-agent?bcId=bc-b30ef5cf-f84b-468d-80ff-eb0a1900291c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-b30ef5cf-f84b-468d-80ff-eb0a1900291c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixed markdown preprocessing to preserve legitimate short lines and
prevent data loss during markdown extraction.

- **Bug Fixes**
- Change len(stripped) > 2 to stripped to only remove empty/whitespace
lines.
- Continue dropping large JSON-like lines (>100 chars); keep small JSON.
- Added tests for short lines, digits, list items, newline compression,
stripping, and chars filtered count.

<sup>Written for commit 24e276d5f4.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-10 16:04:12 -08:00
Cursor Agent 8ba95aefa8 Fix: Filter sensitive data from state messages
This change ensures that sensitive data in action results is filtered before being included in state messages sent to the LLM. This prevents accidental leakage of private information. New tests are added to verify this functionality.

Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-11 00:00:37 +00:00
Cursor Agent 24e276d5f4 Refactor markdown preprocessing and add tests
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
2025-12-11 00:00:21 +00:00
Saurav Panda 71034cacc1 docs fix ChatOpenAI import path (#3748)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Fixed ChatOpenAI import path in actor docs to
browser_use.llm.openai.chat so code examples import correctly.

<sup>Written for commit ab48cc51df.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-10 15:54:02 -08:00
Saurav Panda ab48cc51df docs fix ChatOpenAI import path 2025-12-10 15:34:27 -08:00
Mert Unsal 87ac8493f0 update system prompts (#3746)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add support for browser-use fine-tuned models with simplified,
JSON-first system prompts, and reorganize prompt templates into a
dedicated package for reliable loading and packaging.

- **New Features**
- Auto-detect browser-use models (model name contains "browser-use/")
and select simplified prompts for thinking, no-thinking, and flash
modes.
- Plumb is_browser_use_model through MessageManager to load the correct
template.

- **Refactors**
- Moved all prompt templates to browser_use/agent/system_prompts and
load via importlib.resources for package-safe access.
- Updated pyproject to include the new prompt directory and remove old
file paths.

<sup>Written for commit 110b96dc8d.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-10 14:18:06 -08:00
mertunsall 110b96dc8d update system prompts 2025-12-10 18:50:10 +00:00
Saurav Panda b9a37d7ad6 docs: fix default action count in docs (#3741)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Corrected the documented default for max_actions_per_step to 3 to match
current behavior. Cleaned minor formatting in AGENTS.md (removed
trailing spaces and fixed a tips blockquote).

<sup>Written for commit 2e887d0076.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-12-10 00:59:35 -08:00