Removes verbose debug logs from the registry and tools services to improve clarity and reduce noise in the logs.
Co-authored-by: mailmertunsal <mailmertunsal@gmail.com>
Origin of this issue was from the file location :
browser-use/tools/service.py , specifically from the function:
_validate_and_fix_javascript
- The quote fixer was converting double-quoted selectors to template
literals but creating duplicate closing parentheses
- Example: querySelector("div[role='button']") became
querySelector(\div[role='button']`)) with an extra)`
- Regex patterns only matched selectors with exactly one single quote,
missing complex multi-attribute selectors
- This caused "JavaScript execution error: Uncaught" when the agent
tried to execute the "fixed" code
Here is the screenshot of previous regex patterns:
<img width="574" height="667" alt="Screenshot 2025-11-19 at 12 02 56 PM"
src="https://github.com/user-attachments/assets/01a18f4e-9480-4698-89c0-f639a9b9d9f5"
/>
Two bugs in the regex patterns:
- Missing closing delimiter: Patterns stopped at the closing " without
capturing the ) or ,, leaving it behind to create duplicates
- Single-quote requirement: Pattern [^"]*\'[^"]* required exactly one
single quote, failing on selectors like "div[role='button'][pressed]"
with multiple quotes
Changes Made
- Pattern updates: Changed [^"]*\'[^"]* to [^"]* to match any
double-quoted content
- Delimiter capture: Added \s*\) or \s*, to consume closing delimiters
and prevent duplicates
- Affected patterns:
- querySelector/querySelectorAll: Added \s*\)
- document.evaluate: Added \s*,
- .closest(): Added \s*\)
- .matches(): Added \s*\)
Here is the screenshot of changes i made:
<img width="543" height="659" alt="Screenshot 2025-11-19 at 12 06 53 PM"
src="https://github.com/user-attachments/assets/e80b9792-c168-4e16-be4f-b89970be7a81"
/>
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes the JavaScript quote fixer to handle double-quoted selectors and
XPath correctly, preventing malformed code and runtime errors. Addresses
#3620 by updating regex to consume closing delimiters and support
complex selectors.
- **Bug Fixes**
- Updated patterns to match any double-quoted content, not just strings
with a single quote.
- Captured trailing ) or , to prevent duplicate delimiters.
- Applied changes to document.evaluate (captures ,),
querySelector/querySelectorAll, .closest(), and .matches() (capture )).
- Resolves errors like extra ) and "JavaScript execution error:
Uncaught" during evaluation.
<sup>Written for commit 515a42bdac.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is
generating a summary for commit
020af1f5e9. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Enforce screenshot exclusion when `use_vision` is not 'auto', even with
custom tools.
Previously, the `screenshot` action was not consistently excluded if a
user provided custom tools, leading to `screenshot` being available when
it should have been disabled based on the `use_vision` setting. This fix
ensures the exclusion is always applied by calling
`self.tools.exclude_action('screenshot')` after tool initialization.
Additionally, a mutable default argument bug in `Tools` and `Registry`'s
`exclude_actions` parameter was resolved.
---
[Slack
Thread](https://browser-use.slack.com/archives/C08SZRT860M/p1763797970748989?thread_ts=1763797970.748989&cid=C08SZRT860M)
<a
href="https://cursor.com/background-agent?bcId=bc-8a53c0fb-52e8-4c81-a767-e3f0cc9418d7"><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> <a
href="https://cursor.com/agents?id=bc-8a53c0fb-52e8-4c81-a767-e3f0cc9418d7"><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
Enforce screenshot exclusion when use_vision is not "auto", including
when users pass custom Tools. Fix a mutable default argument bug and add
tests to cover the behavior.
- **Bug Fixes**
- Always remove the screenshot action when use_vision != "auto", even
with custom Tools instances.
- Replace mutable default lists for exclude_actions with None and copy
the provided list.
- Add CI tests for all use_vision modes and custom Tools to prevent
regressions.
- **New Features**
- Introduce Tools.exclude_action() and Registry.exclude_action() to
remove actions after init and block re-registration.
<sup>Written for commit e00ad12c40.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Always remove `screenshot` when `use_vision` != `"auto"` (even with
custom tools), add `exclude_action()` to Tools/Registry, fix mutable
default args, and add CI tests.
>
> - **Agent**
> - Enforces `screenshot` exclusion when `use_vision` != `"auto"` by
calling `self.tools.exclude_action('screenshot')`, covering custom
`tools`/`controller`.
> - **Tools/Registry**
> - Add `Tools.exclude_action()` and `Registry.exclude_action()` to
remove actions post-init and prevent re-registration.
> - Fix mutable default list bug: use `exclude_actions: list[str] |
None` and copy inputs; update `Tools` to pass a new list to `Registry`.
> - **Tests**
> - Add CI tests for `use_vision` modes (true/false/auto), with and
without custom `Tools`, direct `exclude_action()` behavior, and
re-registration prevention.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e00ad12c40. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Previously, cache_control was applied to every content block and tool
call in a message, which could exceed Anthropic's limit of [4 cache
breakpoints per
request](https://platform.claude.com/docs/en/build-with-claude/prompt-caching).
This fix ensures cache_control is only applied to the last block in each
message type:
- Last text block in UserMessage/AssistantMessage content
- Last tool_use block when AssistantMessage has tool calls
- Only the last overall block when AssistantMessage has both content and
tools
This prevents exceeding the cache breakpoint limit while maintaining
correct caching behavior.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes cache_control placement so it applies only to the last block in
each Anthropic message, keeping requests within the 4-cache-breakpoint
limit. Prevents cache overflow in messages with multiple content parts
and/or tool calls while preserving correct caching.
- **Bug Fixes**
- Apply cache_control only to the last content/tool block to meet
Anthropic’s 4-breakpoint limit.
- Cover all cases: only content, only tool calls, and mixed content +
tools (last overall block wins).
- Added focused tests to verify last-block-only caching for text parts,
tool_use lists, and mixed messages.
<sup>Written for commit 5a3d340ec4.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is
generating a summary for commit
2ba8e0cef6. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Reduce default `max_actions_per_step` to 3 and add explicit action
limits and step verification instructions to flash prompts.
The added verification rules aim to prevent the agent from taking
premature or consequential actions (like submitting forms or navigating)
before confirming the success of the previous step, thereby improving
agent reliability and reducing errors in multi-step tasks.
---
[Slack
Thread](https://browser-use.slack.com/archives/D092QUQDC56/p1763774897814279?thread_ts=1763774897.814279&cid=D092QUQDC56)
<a
href="https://cursor.com/background-agent?bcId=bc-50d25809-8c25-4ded-b50c-9a0a39474eb9"><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> <a
href="https://cursor.com/agents?id=bc-50d25809-8c25-4ded-b50c-9a0a39474eb9"><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
Lowered the default max actions per step to 3 and added step
verification rules to flash prompts to prevent premature navigation or
form submissions. This improves reliability in multi-step tasks and
reduces errors.
- **New Features**
- Added an action_rules block to flash prompts (including Anthropic)
with a per-step action limit and instructions to verify the previous
step before taking consequential actions and to check page state after
changes.
- **Refactors**
- Set max_actions_per_step to 3 across prompts.py, service.py, and
views.py.
<sup>Written for commit 2df1faabe8.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
Can't pass an IIFE to `Runtime.callFunctionOn`; doing so fails with a
syntax error.
This caused some inputs to clear after the agent blurred them due to
framework events never firing.
## Summary
Fixes framework events not triggering by replacing the IIFE with a
regular function for Runtime.callFunctionOn, preventing syntax errors
and ensuring change/blur events fire correctly. Inputs no longer clear
after the agent blurs them.
## Changes
- Replace IIFE with a function executed via objectId to avoid CDP syntax
error
- Add success/failure logs to help diagnose event triggering
## Based on
Original PR: #3367 by @sophiabits
Merged with latest main branch
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Replace IIFE with a regular function in `Runtime.callFunctionOn` to
reliably trigger framework events and add success/failure logging.
>
> - **Watchdogs
(`browser_use/browser/watchdogs/default_action_watchdog.py`)**:
> - Replace IIFE with a regular `function()` for
`Runtime.callFunctionOn` in `_trigger_framework_events` to avoid syntax
errors and ensure events dispatch.
> - Add debug/warning logs indicating success or failure of framework
event triggering.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d301f629fd. 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
Fixes framework events not firing by avoiding a syntax error in CDP
Runtime.callFunctionOn. Change/blur events now trigger, and inputs no
longer clear after blur.
- **Bug Fixes**
- Execute a regular function via objectId instead of an IIFE in
_trigger_framework_events.
- Add success/failure logs to diagnose event triggering.
<sup>Written for commit d301f629fd.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Restricts auto-configured LLM screenshot size to only `claude-sonnet`
models, removing the `browser-use` model check.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5d525b7e60. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Restricts auto-configuration of llm_screenshot_size to Claude Sonnet
models only. Prevents incorrect screenshot sizing for other models that
include "browser-use" in their name.
- **Bug Fixes**
- Removed the "browser-use" substring check; auto-config now triggers
only when model_name.startswith('claude-sonnet').
<sup>Written for commit 5d525b7e60.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
Content blocks are dictionaries at runtime despite type annotations
indicating Pydantic models. Added type: ignore comments to allow
dictionary-style .get() access which works correctly at runtime.
Previously, cache_control was applied to every content block and tool call
in a message, which could exceed Anthropic's limit of 4 cache breakpoints
per request. This fix ensures cache_control is only applied to the last
block in each message type:
- Last text block in UserMessage/AssistantMessage content
- Last tool_use block when AssistantMessage has tool calls
- Only the last overall block when AssistantMessage has both content and tools
This prevents exceeding the cache breakpoint limit while maintaining
correct caching behavior.
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Fixes the rerun_history example by correcting the ChatOpenAI import
path, updating the model to gpt-4.1-mini, and simplifying summary-LLM
usage to avoid errors when rerunning histories.
- **Bug Fixes**
- Use from browser_use.llm import ChatOpenAI.
- Update example model to gpt-4.1-mini and remove outdated provider
snippets.
- Clarify that summary_llm=None uses the agent’s LLM by default.
<sup>Written for commit 7811c62377.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds an automated rerun summary that analyzes the final screenshot and
step outcomes, then reports success and completion status. Supports an
optional summary_llm to use a specific model; defaults to the agent’s
model.
- **New Features**
- Generates a summary at the end of rerun_history using screenshot +
execution stats; appended as the last ActionResult.
- Adds RerunSummaryAction with summary, success, and completion_status.
- Introduces get_rerun_summary_prompt/message and
_generate_rerun_summary with structured output and text fallback.
- Updates the rerun example and adds tests covering success, errors,
fallback, and statistics.
- **Migration**
- rerun_history now returns an extra final ActionResult containing the
summary; handle results[-1] accordingly.
- Use summary_llm to override the model used for the summary when
needed.
<sup>Written for commit 5e356108f9.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->