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. -->
Previously, when browser launch succeeded after retry using a temporary
directory, the code immediately deleted ALL temporary directories including
the one actively being used by the running browser process. This caused
browser crashes and data corruption when Chrome tried to write to the
deleted user_data_dir during normal operation.
The fix:
- Only clean up unused temporary directories after successful launch
- Preserve the currently used temporary directory until browser cleanup
- Update _temp_dirs_to_cleanup to track only the in-use directory for
proper cleanup during BrowserKillEvent
<!-- 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. -->
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add variable substitution to agent history reruns so you can replay
workflows with different data. Also fix step_interval to represent step
duration and improve delay logging during replay.
- **New Features**
- load_and_rerun accepts a variables dict to replace detected values
(e.g., email, names, dates) across actions, nested dicts, and lists
without mutating the original history.
- Example updated to show reruns with original and substituted values.
- Comprehensive unit tests added for substitution behavior.
- **Bug Fixes**
- Correct step_interval calculation to use step_end_time -
step_start_time (step duration).
- Rerun logs now show the delay source and format (ms/s) for clarity;
tests updated to match the new duration semantics.
<sup>Written for commit d243616550.
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 automatic variable detection from agent history to identify
reusable inputs (emails, names, dates, etc.) and surface them via a
simple API for reruns and integrations.
Exposes Agent.detect_variables(), returning a map of DetectedVariable
with type/format hints.
- **New Features**
- Added variable_detector.py to detect variables using element
attributes and value patterns.
- Introduced Agent.detect_variables() to analyze current history and
return detected variables.
- Added DetectedVariable and VariableMetadata models in agent.views.
- Updated examples/features/rerun_history.py to print detected variables
before rerun.
- Added unit tests covering attribute-based and pattern-based detection,
deduping, and history parsing.
<sup>Written for commit e57f7ac14f.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
Fix KeyError that occurs when using OpenAI reasoning models (o1, o3,
etc.) with temperature=None or frequency_penalty=None.
The code was using 'del' to remove keys that may not exist in
model_params dictionary. Changed to use .pop() with default value for
safe key removal.
Fixes crash scenario:
- ChatOpenAI(model='o1-mini', temperature=None) -> KeyError
Changes:
- Replace 'del model_params[key]' with 'model_params.pop(key, None)'
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Prevent KeyError crashes when using OpenAI reasoning models by safely
removing temperature and frequency_penalty from model_params with
.pop(). Calls like ChatOpenAI(model='o1-mini', temperature=None) no
longer crash.
<sup>Written for commit 0263f05a7e.
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 per-step wait time tracking for Agent history and uses it during
reruns to match original pacing. Each step now records step_interval,
and reruns respect it with a sensible fallback.
- **New Features**
- Added step_interval to StepMetadata to capture time between
consecutive steps (None for the first step).
- rerun_history uses recorded step_interval for per-step delays; delay
is applied before executing each step and falls back to
delay_between_actions when missing.
- Added tests for calculation, serialization, and backward
compatibility.
- **Migration**
- No changes required. Old histories load with step_interval defaulting
to None.
<sup>Written for commit c5d763a8dd.
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 two telemetry flags to AgentEvent to record when a CAPTCHA is
reached and when a task is judged impossible. Updates the judge_trace
example to use ChatBrowserUse and print the judgement when available.
- **New Features**
- Telemetry: Added judge_reached_captcha and judge_impossible_task to
AgentTelemetryEvent and populate them during agent event logging.
- Example: Switched judge_trace to ChatBrowserUse (local base_url) and
print judgement if present.
<sup>Written for commit e62129ba93.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
…ses missing the field
- Fixes validation error when LLM returns {'scroll': {'pages': 3}}
without 'down' field
- Defaults to True (scroll down) when 'down' is missing, which is the
most common case
- Still supports explicit down=False for scrolling up
- Also fixes CDP client compatibility with older cdp-use versions by
making max_ws_frame_size optional
Fixes validation errors with AWS Bedrock Claude and Gemini models
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Set ScrollAction.down default to True to prevent validation errors when
LLMs omit the field and keep scroll-down as the common behavior.
- **Bug Fixes**
- Handle {'scroll': {'pages': N}} without 'down'; defaults to scrolling
down, explicit down=False still works.
- Updated action description to clarify defaults and parameter ranges.
<sup>Written for commit 72233ecc75.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->