Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
remove-multiact-hash-check
Magnus Müllerd42394b2b1cc
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex cc7291d9c..b50d5f893 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -1643,61 +1643,6 @@ class Agent(Generic[Context, AgentStructuredOutput]):self.logger.debug(msg)break- # DOM synchronization check - verify element indexes are still valid AFTER first action- # This prevents stale element detection but doesn't refresh before execution- if action.get_index() is not None and i != 0:- new_browser_state_summary = await self.browser_session.get_browser_state_summary(- include_screenshot=False,- )- new_selector_map = new_browser_state_summary.dom_state.selector_map-- # Detect index change after previous action- orig_target = cached_selector_map.get(action.get_index())- orig_target_hash = orig_target.parent_branch_hash() if orig_target else None-- new_target = new_selector_map.get(action.get_index()) # type: ignore- new_target_hash = new_target.parent_branch_hash() if new_target else None-- def get_remaining_actions_str(actions: list[ActionModel], index: int) -> str:- remaining_actions = []- for remaining_action in actions[index:]:- action_data = remaining_action.model_dump(exclude_unset=True)- action_name = next(iter(action_data.keys())) if action_data else 'unknown'- remaining_actions.append(action_name)- return ', '.join(remaining_actions)-- if orig_target_hash != new_target_hash:- # Get names of remaining actions that won't be executed- remaining_actions_str = get_remaining_actions_str(actions, i)- msg = f'Page changed after action: actions {remaining_actions_str} are not yet executed'- logger.info(msg)- results.append(- ActionResult(- extracted_content=msg,- include_in_memory=True,- long_term_memory=msg,- )- )- break-- # Check for new elements that appeared- new_element_hashes = {e.parent_branch_hash() for e in new_selector_map.values()}- if check_for_new_elements and not new_element_hashes.issubset(cached_element_hashes):- # next action requires index but there are new elements on the page- # log difference in len debug- self.logger.debug(f'New elements: {abs(len(new_element_hashes) - len(cached_element_hashes))}')- remaining_actions_str = get_remaining_actions_str(actions, i)- msg = f'Something new appeared after action {i} / {total_actions}: actions {remaining_actions_str} were not executed'- logger.info(msg)- results.append(- ActionResult(- extracted_content=msg,- include_in_memory=True,- long_term_memory=msg,- )- )- break-# wait between actions (only after first action)if i > 0:await asyncio.sleep(self.browser_profile.wait_between_actions)