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
list unexecuted actions
mertunsall6c6907bfc2a8
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex a048769ab..83aecaafc 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -1555,8 +1555,18 @@ class Agent(Generic[Context, AgentStructuredOutput]):new_target = new_selector_map.get(action.get_index()) # type: ignorenew_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:- msg = f'Page changed after action {i} / {total_actions}'+ # 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 {i} / {total_actions}: actions {remaining_actions_str} were not executed'logger.info(msg)results.append(ActionResult(@@ -1571,7 +1581,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):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- msg = f'Something new appeared after action {i} / {total_actions}'+ 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(diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 5d1ba1750..b370b3fde 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -84,6 +84,7 @@ Strictly follow these rules while using the browser and navigating the web:- You can call extract_structured_data on specific pages to gather structured semantic information from the entire page, including parts not currently visible. The results of extract_structured_data are automatically saved to the file system.- Call extract_structured_data only if the information you are looking for is not visible in your <browser_state> otherwise always just use the needed text from the <browser_state>.- If you fill an input field and your action sequence is interrupted, most often something changed e.g. suggestions popped up under the field.+- If the action sequence was interrupted in previous step due to page changes, make sure to complete any remaining actions that were not executed. For example, if you tried to input text and click a search button but the click was not executed because the page changed, you should retry the click action in your next step.- If the <user_request> includes specific page information such as product type, rating, price, location, etc., try to apply filters to be more efficient.- The <user_request> is the ultimate goal. If the user specifies explicit steps, they have always the highest priority.- If you input_text into a field, you might need to press enter, click the search button, or select from dropdown for completion.diff --git a/browser_use/agent/system_prompt_flash.md b/browser_use/agent/system_prompt_flash.mdindex 3f0a0a2fd..2143f017c 100644--- a/browser_use/agent/system_prompt_flash.md+++ b/browser_use/agent/system_prompt_flash.md@@ -82,6 +82,7 @@ Strictly follow these rules while using the browser and navigating the web:- You can call extract_structured_data on specific pages to gather structured semantic information from the entire page, including parts not currently visible. The results of extract_structured_data are automatically saved to the file system.- Call extract_structured_data only if the information you are looking for is not visible in your <browser_state> otherwise always just use the needed text from the <browser_state>.- If you fill an input field and your action sequence is interrupted, most often something changed e.g. suggestions popped up under the field.+- If the action sequence was interrupted in previous step due to page changes, make sure to complete any remaining actions that were not executed. For example, if you tried to input text and click a search button but the click was not executed because the page changed, you should retry the click action in your next step.- If the <user_request> includes specific page information such as product type, rating, price, location, etc., try to apply filters to be more efficient.- The <user_request> is the ultimate goal. If the user specifies explicit steps, they have always the highest priority.- If you input_text into a field, you might need to press enter, click the search button, or select from dropdown for completion.diff --git a/browser_use/agent/system_prompt_no_thinking.md b/browser_use/agent/system_prompt_no_thinking.mdindex 3867493a5..f8ed3314d 100644--- a/browser_use/agent/system_prompt_no_thinking.md+++ b/browser_use/agent/system_prompt_no_thinking.md@@ -84,6 +84,7 @@ Strictly follow these rules while using the browser and navigating the web:- You can call extract_structured_data on specific pages to gather structured semantic information from the entire page, including parts not currently visible. The results of extract_structured_data are automatically saved to the file system.- Call extract_structured_data only if the information you are looking for is not visible in your <browser_state> otherwise always just use the needed text from the <browser_state>.- If you fill an input field and your action sequence is interrupted, most often something changed e.g. suggestions popped up under the field.+- If the action sequence was interrupted in previous step due to page changes, make sure to complete any remaining actions that were not executed. For example, if you tried to input text and click a search button but the click was not executed because the page changed, you should retry the click action in your next step.- If the <user_request> includes specific page information such as product type, rating, price, location, etc., try to apply filters to be more efficient.- The <user_request> is the ultimate goal. If the user specifies explicit steps, they have always the highest priority.- If you input_text into a field, you might need to press enter, click the search button, or select from dropdown for completion.