8170 Commits

Author SHA1 Message Date
Laith Weinberger e552b6de34 fix(openai): handle proxy responses with missing/null choices; undo test change
Avoid indexing response.choices[0] when proxies return choices=null/empty; raise a clear ModelProviderError (with base_url hint) and use the validated first choice for content/finish_reason
2026-02-08 15:31:42 -05:00
sudhanshu112233shukla bf056b69b4 style: fix formatting in tests/ci/conftest.py 2026-01-16 21:01:34 +00:00
sudhanshu112233shukla ddb8a93b2f test: increase event bus timeout to 60s to fix CI flakes 2026-01-16 20:58:13 +00:00
sudhanshu112233shukla 4c81648d68 fix(llm): handle missing choices in openai proxy response 2026-01-16 20:21:53 +00:00
Saurav Panda 728ec50536 Add menu retry for agent rerun if fails (#3891)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds a menu-aware retry to agent reruns: if a menu item can’t be
matched, the agent re-opens the dropdown and retries quickly. This
reduces flaky failures in multi-level dropdown flows.

- **Bug Fixes**
- Detects menu openers (aria-haspopup, toggleSubMenu, expand-button,
role with aria-expanded).
- Detects menu items (menuitem roles, gw-action--inner, menu-related
classes, stable ax_name).
- Re-executes the opener step with a short delay and retries without
consuming a retry attempt.
  - Improves logging and preserves existing backoff behavior.
  - Adds unit tests for opener/item detection.

<sup>Written for commit 147db04c1c.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-01-15 11:36:19 -08:00
Saurav Panda 147db04c1c Merge branch 'main' into add-ax-name-fallback-rerun 2026-01-15 11:03:27 -08:00
Saurav Panda ac118718d0 Added docs for timeout env variables. (#3894)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Added an Environment Variables section to the Agent parameters docs that
lists all timeout env vars with defaults and clear descriptions, plus
example usage. This lets users tune agent and browser behavior and
troubleshoot slow networks or complex pages without code changes.

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

<!-- End of auto-generated description by cubic. -->
2026-01-15 11:03:12 -08:00
Saurav Panda 050cea627a make event bus timeout configurable using env (#3893)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Made the Agent event bus stop timeout configurable via the
TIMEOUT_AgentEventBusStop env var (default 3s) to let tests and
deployments tune shutdown wait time. This connects to Linear 3076 by
allowing environments to adjust the idle wait instead of using a fixed
value.

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

<!-- End of auto-generated description by cubic. -->
2026-01-15 11:01:28 -08:00
Saurav Panda b71894b97b fixed parameter name in docs 2026-01-15 10:57:03 -08:00
Saurav Panda 9339935c1f added check for history item state 2026-01-15 10:50:07 -08:00
Saurav Panda 730ae0fda4 Added docs for timeout env variables. 2026-01-15 10:48:08 -08:00
Saurav Panda 9c042d7d98 make event bus timeout configurable using env 2026-01-15 10:44:44 -08:00
Saurav Panda 97d71b84fa added a fix for multi menu dropdown 2026-01-15 10:17:59 -08:00
Magnus Müller 612d8c49e4 fix-scroll-action (#3869)
Auto-generated PR for branch: fix-scroll-action

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Unifies scrolling terminology and simplifies guidance to reduce
over-scrolling and clarify browser state output.
> 
> - Rename `SCROLL`/"scroll containers" to `scroll element` across DOM
serialization (`serializer.py`), system/code prompts, and `ScrollAction`
docs/descriptions (`service.py`, `views.py`)
> - Simplify page info in `prompts.py`: output `<page_info>` as `X
above, Y below`; drop total pages; prepend `[Start of page]` only when
no content above
> - Streamline `<page_stats>`: remove scroll container count from
summary text; minor formatting/whitespace fixes across prompts
> - Update code-use/system prompts to reflect new marker `|scroll
element|` and tidy guidance/examples
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6bccc224ca. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Standardize “scroll element” terminology and reduce over-priming about
scrolling to prevent unnecessary scroll actions and improve clarity in
browser state output.

- **Refactors**
- Renamed “SCROLL”/“scroll containers” to “scroll element” in DOM
serialization, tool docs, and code-use prompt.
- Trimmed scrolling guidance in system prompts (removed offscreen scroll
advice and pages=10 chaining examples).
- Simplified browser state: removed scroll_containers from stats; page
info now “X above, Y below”; only add “[Start of page]” when there’s no
content above.
  - Minor phrasing and whitespace fixes across prompts.

<sup>Written for commit 6bccc224ca.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-01-10 20:18:44 -08:00
Magnus Müller 6bccc224ca Remove comma 2026-01-10 20:01:14 -08:00
Magnus Müller aac5cad62a Fix system prompt code use 2026-01-10 20:00:18 -08:00
Magnus Müller 5652ba5dd9 Small comment 2026-01-10 19:03:35 -08:00
Magnus Müller c4b9710a84 Less priming for scroll 2026-01-10 18:33:17 -08:00
Magnus Müller 680d2551df Scroll element 2026-01-10 18:20:32 -08:00
Magnus Müller 1e0fd4d814 Remove CTA 2026-01-10 17:36:43 -08:00
Magnus Müller 9609aa10e5 Prompt 2026-01-10 17:25:36 -08:00
Magnus Müller fc2dc27c63 Prompts 2026-01-10 17:24:07 -08:00
Magnus Müller 31ed79d6c9 Add support for multi-tab video recording (#3728)
This PR upgrades the Recording Watchdog to listen for
`AgentFocusChangedEvent`. This change ensures that when the agent
switches tabs, the video recording follows the agent's view, thus
supporting multi-tab tasks. Additionally, the video recorder currently
spawns a new ffmpeg subprocess for every single frame, which creates
massive overhead due to process initialization and I/O piping. This was
an attempt to avoid using the PIL dependency, but ended up not being
worth it. This PR fixes that by using Pillow to handle resizing and
padding in-memory before passing the numpy array to the video writer,
which is significantly faster and CPU-friendly.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Enable multi-tab video recording by switching the screencast to the
focused tab. Speed up frame processing by using Pillow for in-memory
resize and padding instead of spawning ffmpeg per frame.

- **New Features**
- Listen for AgentFocusChangedEvent and switch screencast to the focused
target/session.
- Stop screencast on the previous session and ignore stale frames to
avoid race conditions.

- **Performance**
- Replace per-frame ffmpeg subprocess with PIL-based resize/padding and
direct numpy writes via imageio.
- Reduce CPU overhead and I/O; use BICUBIC resize and apply black
padding only when needed.

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

<!-- End of auto-generated description by cubic. -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Enables recording to follow the focused tab and streamlines frame
processing for better performance and reliability.
> 
> - **Multi-tab recording**: Listen to `AgentFocusChangedEvent`, switch
screencast to the focused session via `_start_screencast`, stop previous
session, and ignore stale frames in `on_screencastFrame`.
> - **Session management**: Track `_current_session_id` and cache
`_screencast_params`; reset state on stop.
> - **Performance**: In `video_recorder.py`, replace per-frame `ffmpeg`
subprocess with Pillow-based in-memory resize/padding and direct NumPy
writes to `imageio`; remove `imageio_ffmpeg`/`subprocess` usage.
> - **Compatibility**: Pre-pad to macro-block size and set writer
`pixelformat='yuv420p'` with `macro_block_size=None`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d9943a0246. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-01-07 17:51:21 +01:00
Magnus Müller d9943a0246 Merge branch 'main' into feat/multi-tab-recording 2026-01-07 17:49:16 +01:00
Saurav Panda 2b61886093 Added ax-name fallback for history rerun. (#3849)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds AX_NAME (accessible name) fallback to history rerun element
matching to reduce failures on dynamic pages. Improves reliability when
hashes or XPath change, especially in SPAs and menu UIs.

- **New Features**
- Added Level 4 AX_NAME matching before ATTRIBUTE in the fallback order:
EXACT → STABLE → XPATH → AX_NAME → ATTRIBUTE.
- AX_NAME matching requires the same node type; logs available ax_names
when no match is found.
  - Updated MatchLevel enum to include AX_NAME=4 and ATTRIBUTE=5.
- Added CI tests covering success cases, node-type constraints, and
matching order.
- Tweaked example rerun timing (max_step_interval=20,
delay_between_actions=1).

- **Bug Fixes**
- Corrected match-level reporting to use ATTRIBUTE for attribute-based
matches.

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

<!-- End of auto-generated description by cubic. -->
2026-01-06 13:07:03 -08:00
Saurav Panda 2c06eabf5f Added ax-name fallback for history rerun. 2026-01-06 12:07:10 -08:00
Saurav Panda c9b6fe76dd docs: add missing video recording dependency notice (#3842)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add a warning to the Browser recording docs that video capture requires
optional dependencies, with install commands: pip install
"browser-use[video]" or pip install imageio[ffmpeg] numpy. Addresses
Linear 3803 by adding the missing dependency install alert to the
recording section.

<sup>Written for commit 4c151c214c.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-01-05 11:22:29 -08:00
Saurav Panda 4c151c214c docs: add missing video recording dependency notice 2026-01-05 10:56:01 -08:00
Saurav Panda 9cfec600d4 fixed broken links in docs (#3841)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Fixed broken links in the docs to restore navigation and remove 404s.
Addresses Linear 3836.

- **Bug Fixes**
  - Agent basics: updated Supported Models link to /supported-models.
- CodeAgent basics: linked ChatBrowserUse to /supported-models and
updated API key URL to https://cloud.browser-use.com/new-api-key.
- MCP server: replaced v2 API Reference link with
https://docs.cloud.browser-use.com.

<sup>Written for commit 75b5a0dffd.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-01-05 10:47:47 -08:00
Saurav Panda 75b5a0dffd fixed broken links in docs 2026-01-05 10:45:14 -08:00
Larsen Cundrič 630f85dd05 Remove search from v1 (#3834) 2026-01-03 14:28:20 +01:00
LarsenCundric 10b2623f17 Remove search from v1 2026-01-03 14:26:57 +01:00
Saurav Panda 6b4ed25347 refactor: Replace print with logger.debug in actor/page.py (#3814)
## Background
The page.py file in the browser_use/actor directory was using a print
statement for debugging purposes, which is inconsistent with the
project's logging strategy. The project already has a centralized
logging system using Python's logging module, configured through
browser_use/logging_config.py .

## Changes
1. File Modified : browser_use/actor/page.py
2. Change : Replaced the debug print statement on line 134 with a
logger.debug call
3. Logger Used : The existing logger imported from browser_use
4. Log Level : debug (matching the original debug print intent)
## Benefits
- Unified Logging : Aligns with the project's existing logging system
- Flexible Configuration : Debug logs can be easily enabled/disabled via
environment variables or code configuration
- Better Context : Logs include component name and timestamp when
configured
- Structured Output : Consistent log format across the project
- Reduced Console Clutter : Users can control log verbosity based on
their needs
- Improved Debugging : Better integration with logging tools and
services
## Impact
- No Breaking Changes : This is a refactoring change that preserves
functionality
- Minimal Scope : Only affects one debug statement in a single file
- Backward Compatible : Existing functionality remains unchanged
## Testing
- ✅ Python syntax check passed ( python -m py_compile
browser_use/actor/page.py )
- ✅ No other print statements left in the file (verified via grep )
- ✅ Uses existing project logger (no new dependencies)
- ✅ Log level appropriately set to debug for debugging purposes

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Switched the debug print in browser_use/actor/page.py to logger.debug to
align with the project’s logging system. This keeps behavior the same
while providing structured logs and configurable verbosity.

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

<!-- End of auto-generated description by cubic. -->
2025-12-26 13:07:45 -08:00
constx1337 6b77410683 refactor: Replace print with logger.debug in actor/page.py 2025-12-25 14:39:05 +08:00
Saurav Panda 310bc12c3e feat: added exp backoff retry and minimum element load (#3808)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds exponential backoff retries to rerun_history and an opt-in wait for
a minimum number of DOM elements before actions that need element
matching. This improves reliability on dynamic/SPAs and avoids tight
retry loops.

- **New Features**
- Exponential backoff for step retries: 5s base, doubles each retry,
capped at 30s.
- Optional wait_for_elements: waits for a minimum element count before
click/input/hover/select/drag; count inferred from action indices
(capped at 50), with polling and timeout.
- Continues with the last known state if the minimum isn’t reached
within the timeout.

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

<!-- End of auto-generated description by cubic. -->
2025-12-23 20:22:52 -08:00
Saurav Panda 1073fc9e7a Merge branch 'main' into rerun-history-add-exp-retry 2025-12-23 20:16:27 -08:00
Saurav Panda 9c90ff0081 feat: add support for openai responses model (#3805)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add Azure OpenAI Responses API support with auto-detection and
structured output, so Codex and computer-use-preview models work with
api_version 2025-03-01-preview. Addresses Linear 3771.

- **New Features**
- Route ainvoke to Responses API when use_responses_api is True or
'auto' for supported models; fallback to Chat Completions otherwise.
- Added ResponsesAPIMessageSerializer to convert existing message types
(text, images, assistant) to Responses API input.
- Structured output via text.format + JSON schema, with optional schema
injection into the system prompt and support for
dont_force_structured_output.
- Usage mapping and robust error handling (rate limits,
connection/status errors). Updated docs, example, and tests.

- **Migration**
- For Codex/computer-use models, set api_version to 2025-03-01-preview;
'auto' will use Responses API.
  - Override behavior with use_responses_api = True/False/'auto`.

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

<!-- End of auto-generated description by cubic. -->
2025-12-23 19:31:18 -08:00
Saurav Panda 319d0acd45 fixed the edge case for handling max index 2025-12-23 19:29:43 -08:00
Saurav Panda 2f6a18a64e Merge branch 'main' into 3771-feature-request-add-support-for-openai-responses-api-for-azure-openai 2025-12-23 19:28:17 -08:00
Saurav Panda fe6e8d47e1 fixed azure openai chat with gpt-5.1-codex 2025-12-23 18:04:30 -08:00
Saurav Panda 2aa23f01dc fixed backend_node_id based element counting. 2025-12-23 17:25:38 -08:00
Saurav Panda 0da9457f6b feat: added exp backoff retry and minimum element load 2025-12-23 17:02:28 -08:00
Saurav Panda a25bd42124 feat: remove redundant retry step from history (#3807)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Skips redundant retry steps during history reruns when the previous step
already succeeded on the same element and action. This avoids replay
failures after navigation and speeds up reruns.

- **New Features**
- Detect redundant retries by matching element (hash/stable_hash/xpath)
and action type.
- Track previous step success and skip the duplicate, adding a “Skipped
- redundant retry of previous step” result.
  - Added tests for rerun behavior and the detection helper.

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

<!-- End of auto-generated description by cubic. -->
2025-12-23 16:31:21 -08:00
Saurav Panda bb13679f85 feat: remove redundant retry step from history 2025-12-23 16:25:52 -08:00
Saurav Panda 29c9f1a416 feat: add support for openai responses model 2025-12-22 22:16:56 -08:00
Saurav Panda 1849730d9f fix: resolve Gemini API error on empty action schemas (#3804)
Fixes #3786.

When using the Gemini API (via LiteLLM or directly), the request fails
with a `BadRequestError`. This is because Gemini's API strictly enforces
that any parameter defined as `type: OBJECT` in the `response_schema`
must have a non-empty `properties` map.

The `go_back` action (and others using `NoParamsAction`) previously
generated an empty object schema (`{"type": "object", "properties":
{}}`), causing this validation failure.

**Error Message:**
> `GeminiException BadRequestError - *
GenerateContentRequest.generation_config.response_schema.properties["action"].items.any_of[3].properties["go_back"].properties:
should be non-empty for OBJECT type`

## Changes
- Modified `NoParamsAction` in `browser_use/tools/service.py` to include
an optional `description` field.
- This ensures Pydantic generates a valid schema (e.g., `{"properties":
{"description": {"type": "string"}}}`) instead of an empty one.
- The new field is optional (`None` by default) and is explicitly
ignored by the action logic (`_`), ensuring no side effects on existing
functionality.

- Verified that `NoParamsAction.model_json_schema()` now produces a
schema with properties, satisfying the Gemini API requirement.





<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Prevent Gemini BadRequestError by ensuring actions with no params
produce a non-empty object schema. Adds an optional description field to
NoParamsAction so Pydantic includes properties in the response_schema.

- **Bug Fixes**
- Added description: str | None = Field(None, ...) to NoParamsAction in
browser_use/tools/views.py to satisfy Gemini’s OBJECT-type schema
requirement.
- Field is optional and ignored by action logic, so behavior remains
unchanged.

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

<!-- End of auto-generated description by cubic. -->
2025-12-22 19:40:22 -08:00
nitesh-77 bd6c1d76e2 style: use single quotes to satisfy ruff formatter 2025-12-23 06:06:33 +05:30
nitesh-77 d17f10fe45 fix: use str | None type hint to satisfy linter 2025-12-23 06:00:22 +05:30
nitesh-77 285995ecce fix: resolve Gemini API error on empty action schemas 2025-12-23 05:48:12 +05:30
Enzo Biondo c4c5875ad0 Merge branch 'main' into feat/multi-tab-recording 2025-12-22 09:28:00 -03:00