Auto-generated PR for: disable telemetry logs for chatbrowseruse
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Passes `anonymized_telemetry` from `CONFIG.ANONYMIZED_TELEMETRY` in
`ChatBrowserUse.ainvoke` request payload to control telemetry behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1f6d606fac. 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
Disables telemetry logging for ChatBrowserUse by sending the
anonymized_telemetry flag from CONFIG in the ainvoke request payload.
Telemetry now respects the global ANONYMIZED_TELEMETRY setting, allowing
logs to be suppressed when disabled.
<sup>Written for commit 1f6d606fac.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
change logging level from info to debug in BrowserSession methods
Updated the logging level for session management methods in
BrowserSession to debug for more granular logging. This change applies
to the reset, kill, and stop methods, enhancing the clarity of log
outputs during browser session operations without cluttering the info
logs.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Lowered the log level for BrowserSession reset(), kill(), and stop()
messages from info to debug. This reduces noise in info logs while
keeping detailed session lifecycle events available for troubleshooting.
- **Refactors**
- Replaced logger.info with logger.debug in reset(), kill(), and stop().
- No runtime behavior changes; logging only.
<sup>Written for commit 2d433dca4b.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
Updated the logging level for session management methods in BrowserSession to debug for more granular logging. This change applies to the reset, kill, and stop methods, enhancing the clarity of log outputs during browser session operations without cluttering the info logs.
Enhance SessionManager and BrowserSession with defensive checks and
connection management
- Added defensive checks in SessionManager to skip target attachment and
focus recovery if the browser is shutting down (i.e., _cdp_client_root
is None).
- Introduced a connection lock in BrowserSession to prevent concurrent
connection attempts, ensuring safe CDP client management.
- Improved logging for session reset and connection handling, providing
clearer insights into the browser session state during operations.
- Enhanced error handling when stopping the CDP client and clearing
session manager state on initialization failures.
These changes improve the robustness and reliability of session
management in the browser environment.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Improved CDP client cleanup and connection handling to prevent race
conditions and stale sessions, making browser start/stop more reliable.
- **Bug Fixes**
- Added a connection lock to block concurrent connect attempts.
- Closed CDP WebSocket during reset/stop/kill before clearing state,
with clearer logs.
- Skipped target attach and focus recovery when the CDP client is absent
(browser shutting down).
- On connect failure or duplicate connect, stopped the existing client,
cleared SessionManager, and reset state.
<sup>Written for commit 6c1f772a2d.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
- Added defensive checks in SessionManager to skip target attachment and focus recovery if the browser is shutting down (i.e., _cdp_client_root is None).
- Introduced a connection lock in BrowserSession to prevent concurrent connection attempts, ensuring safe CDP client management.
- Improved logging for session reset and connection handling, providing clearer insights into the browser session state during operations.
- Enhanced error handling when stopping the CDP client and clearing session manager state on initialization failures.
These changes improve the robustness and reliability of session management in the browser environment.
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Prevent UTF-8 encoding errors by sanitizing surrogate characters across
the agent and tools. Centralizes sanitization and applies it to
DOM-derived text and extraction inputs.
- **Bug Fixes**
- Sanitize state_description in get_user_message to avoid encoding
crashes.
- Sanitize content and query in extract() to prevent UTF-8 errors.
- **Refactors**
- Moved sanitize_surrogates to utils and reused it across modules.
- Removed the local _sanitize_surrogates method from prompts.py.
<sup>Written for commit a64c82ef2c.
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 a demo mode that injects a side panel into the browser to stream
live agent logs and state. This lets you follow actions, thoughts,
errors, and results without checking the console.
- **New Features**
- New demo_mode flag in Agent, CodeAgent, and BrowserProfile (default
off).
- In-browser panel injected via CDP with a DemoMode helper;
BrowserSession exposes send_demo_mode_log(); panel renders text safely
(no HTML).
- Agent/CodeAgent now log step start/completion, actions (with params),
LLM responses/thinking, evaluations, memory, partial results, errors,
and final result to the panel; CodeAgent adds a sample output preview
cell.
- Short delay before auto-close to allow reading final messages.
- DOM serializer passes session_id and filters out overlay elements
using a session-specific data-browser-use-exclude-<session_id>
attribute.
- Example added: examples/demo_mode_example.py.
- **Migration**
- Enable with demo_mode=True on Agent/CodeAgent or in BrowserProfile.
- Run with headless=False to see the panel (warning logged if
headless=True).
- No changes needed if you don’t use demo mode.
<sup>Written for commit c29e358b9c.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds an optional demo mode that injects a browser side panel to stream
live agent/code-agent logs, with session-scoped DOM exclusion and
logging hooks across the stack.
>
> - **Demo Mode (browser UI)**:
> - New `DemoMode` helper and injected JS panel streaming logs via
`window` events; persisted per-page, toggleable floating button.
> - `BrowserProfile.demo_mode` flag (default false);
`BrowserSession.demo_mode` lazy helper; `send_demo_mode_log()` API;
auto-injected on start; warns if headless.
> - **Agents Integration**:
> - `Agent` and `CodeAgent` accept `demo_mode`; broadcast step
start/completion, actions (and params), LLM
responses/thinking/evaluations, memory/next goal, errors, and
final/partial results to the panel.
> - Small UX: short delay before auto-close to read final messages;
CodeAgent adds a sample output preview cell.
> - **DOM/Serialization**:
> - Pass `session_id` to `DOMTreeSerializer`; filter elements marked
with session-specific `data-browser-use-exclude-<session_id>` (fallback
to legacy attr); propagation through `DomService`,
`Page.get_element_by_prompt`.
> - **Session/Startup**:
> - Inject demo overlay on connect/start (local or cloud); reset on
session reset.
> - **Example**:
> - `examples/demo_mode_example.py` showcasing `Agent(...,
demo_mode=True)`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c29e358b9c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Resolves#3573
Changed upgrade message from `uv add browser-use@X.X.X` to `uv add
browser-use==X.X.X`
The @ syntax fails with "Expected path to end in a supported file
extension" error.
uv requires PEP 508 format (==) not npm-style (@).
**Example for bug:**
(base) thomaybalazs@Mac browser-use % uv add --dev browser-use@0.9.5
error: Failed to parse: `browser-use@0.9.5`
Caused by: Expected path
(`/Users/thomaybalazs/Projects/browser-use/0.9.5`) to end in a supported
file extension: `.whl`, `.tar.gz`, `.zip`, `.tar.bz2`, `.tar.lz`,
`.tar.lzma`, `.tar.xz`, `.tar.zst`, `.tar`, `.tbz`, `.tgz`, `.tlz`, or
`.txz`
browser-use@0.9.5
^^^^^
(base) thomaybalazs@Mac browser-use % uv add --dev browser-use==0.9.5
Resolved 403 packages in 548ms
Built browser-use @ file:///Users/thomaybalazs/Projects/browser-use
Prepared 1 package in 268ms
Uninstalled 1 package in 1ms
Installed 1 package in 1ms
~ browser-use==0.9.5 (from
file:///Users/thomaybalazs/Projects/browser-use)
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes the upgrade command shown in agent logs to use uv’s PEP 508 syntax
with == instead of @, so copy-pasting the suggestion works without parse
errors.
<sup>Written for commit dc9dbbeddd.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
### Problem:
AttributeError: 'NoneType' object has no attribute
'get_target_id_from_session_id' occurred when the network response
handler ran after browser shutdown or before connection, when
session_manager was None.
### Root Cause:
The global Network.responseReceived callback can fire after
session_manager is cleared during _disconnect_from_browser(), causing a
race condition.
### Solution:
Added a None check before accessing
session_manager.get_target_id_from_session_id() in on_response_received,
returning early if session_manager is None. Added a warning log for
visibility.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Handled None session_manager in DownloadsWatchdog to avoid crashes when
Network.responseReceived fires during browser shutdown or before
connection. We now skip network monitoring and log a warning if
session_manager is missing.
<sup>Written for commit a3e1ed7274.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
- Replace ListPrompt with FuzzyPrompt for real-time search
- Add responsive layout based on terminal width
- Display author names for non-default templates
- Organize templates: defaults, featured, others
- Sort by last modified date within sections
- Remove default pre-selection for cleaner UX
Enhances template discovery with intuitive search and better
organization.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds fuzzy search and a responsive TUI for template selection to make
finding templates faster and clearer. Improves discovery with organized
sections and visible metadata.
- **New Features**
- Real-time fuzzy search replaces the list prompt.
- Responsive choice formatting based on terminal width.
- Shows [FEATURED] and author names (non-default templates).
- Organized into defaults, featured, and others.
- Sorted by last_modified_date within each section (newest first).
- Removed default pre-selection.
<sup>Written for commit 3505fe5d5f.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces a fuzzy-search TUI with responsive choice formatting,
organized sections, and recency sorting for template selection in
`browser_use/init_cmd.py`.
>
> - **CLI (`browser_use/init_cmd.py`)**:
> - Replace list prompt with fuzzy-search prompt for interactive
template selection.
> - Add responsive choice formatting based on terminal width; include
`[FEATURED]` and author (non-default templates).
> - Organize templates into defaults, featured, and others; sort each by
`author.last_modified_date` (newest first).
> - Remove default pre-selection and numeric keybindings; enable
scrollable list (`max_height='70%'`).
> - Introduce `_get_terminal_width` and `_format_choice` helpers.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3505fe5d5f. 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
Added detailed debug and warning logs to DownloadsWatchdog’s
BrowserStateRequestEvent flow to improve traceability and
troubleshooting without changing behavior.
- **New Features**
- Log start and successful completion of BrowserStateRequestEvent
handling.
- Include event_id and target_id (last 4 chars) and truncate URLs to 80
chars in logs.
- Warn and skip when there’s no valid focus or no URL.
<sup>Written for commit 1f758178da.
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
Improved navigation reliability and speed with lifecycle-driven waits
and smarter tab handling. Centralized target/session state in
SessionManager to remove polling and prevent race conditions.
- **New Features**
- Added _navigate_and_wait that waits for networkIdle, falling back to
load (2–4s timeout) with loaderId matching.
- SessionManager now enables Page lifecycle + Network once per session,
discovers targets, updates title/URL via targetInfoChanged, initializes
existing tabs, and stores lifecycle events per session so monitoring is
ready before navigation.
- **Refactors**
- Reuse about:blank tabs using cached target data to avoid extra CDP
calls; fall back to current tab on failures.
- Centralized targets/sessions in SessionManager (Target entity) with
cached tabs/URLs; added get_all_page_sessions and made session retrieval
sync; removed polling; iframe targets included; lazy frame fetch for DOM
builds.
- Only switch tabs when needed; safer target_id handling; removed fixed
post-navigate sleep and tab responsiveness checks; still emit
NavigationCompleteEvent on errors.
- Standardized agent focus to agent_focus_target_id with helpers to get
focused session/target; updated watchdogs/CLI and added safer focus
change handling with an about:blank fallback; added
create_task_with_error_handling for background tasks to avoid unhandled
exceptions.
- Updated cdp-use to 1.4.4 and increased max WebSocket frame size to
200MB to better handle large DOMs.
<sup>Written for commit 315995c092.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
- Introduced a variable to hold exceptions for re-raising outside the try-except block, ensuring proper propagation to the event loop.
- Updated comments for clarity on the exception handling process in background tasks.
- Replace ListPrompt with FuzzyPrompt for real-time search
- Add responsive layout based on terminal width
- Display author names for non-default templates
- Organize templates: defaults, featured, others
- Sort by last modified date within sections
- Remove default pre-selection for cleaner UX
Enhances template discovery with intuitive search and better organization.
- Updated the logging behavior for exceptions in background tasks to log at warning level and re-raise exceptions for better propagation to the event loop's exception handler.
- Enhanced clarity in comments regarding exception retrieval and handling.
- Updated the method of obtaining CDP sessions to utilize the public API, enhancing error handling during session retrieval.
- Added exception handling to ensure graceful failure when sessions cannot be created or retrieved, improving robustness in both the main functionality and tests.
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add debug logging of the raw version info response in session.connect
and a clearer assert message when the CDP URL is missing. This helps
diagnose failures when connecting to existing Chromium browsers via CDP.
<sup>Written for commit a2e81f17d7.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
- Changed the type of the all_frames parameter to allow for None, enabling lazy fetching of cross-origin iframes only when necessary.
- Updated comments to clarify the behavior of all_frames during DOM tree construction.
- Adjusted the structure of event handling for 'networkIdle' and 'load' events to improve readability and maintainability.
- Ensured that logging for page readiness is consistently executed within the event handling logic.
- Updated the `create_task_with_error_handling` calls in `DOMWatchdog` to include the `suppress_exceptions` parameter, improving error management during DOM tree building and screenshot capturing.
- This change allows for better handling of exceptions without interrupting the flow of task execution.