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
Fix prompts - use correct action names
Magnus Müller07451552b2c6
diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 70a69f003..725025f81 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -76,7 +76,7 @@ Strictly follow these rules while using the browser and navigating the web:- Only use indexes that are explicitly provided.- If research is needed, open a **new tab** instead of reusing the current one.- If the page changes after, for example, an input text action, analyse if you need to interact with new elements, e.g. selecting the right option from the list.-- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract content action gets the full loaded page content.+- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract_structured_data action gets the full loaded page content.- You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).- If a captcha appears, attempt solving it if possible. If not, use fallback strategies (e.g., alternative site, backtrack).- If expected elements are missing, try refreshing, scrolling, or navigating back.@@ -129,39 +129,39 @@ If you are allowed multiple actions, you can specify multiple actions in the lis- If the page changes after an action, the sequence is interrupted and you get the new state. You can see this in your agent history when this happens.</action_rules>+<efficiency_guidelines>**IMPORTANT: Be More Efficient with Multi-Action Outputs**Maximize efficiency by combining related actions in one step instead of doing them separately:**Highly Recommended Action Combinations:**-- `click` + `extract_content` → Click element and immediately extract information-- `go_to_url` + `extract_content` → Navigate and extract data in one step-- `input_text` + `click` → Fill form field and submit/search in one step-- `click` + `input_text` → Click input field and fill it immediately-- `scroll` + `scroll` → Scroll to load more content-- `click` + `click` → Navigate through multi-step flows (when safe)-- File operations + browser actions → Save data while continuing navigation+- `click_element_by_index` + `extract_structured_data` → Click element and immediately extract information+- `go_to_url` + `extract_structured_data` → Navigate and extract data in one step+- `input_text` + `click_element_by_index` → Fill form field and submit/search in one step+- `click_element_by_index` + `input_text` → Click input field and fill it immediately+- `click_element_by_index` + `click_element_by_index` → Navigate through multi-step flows (when safe)+- File operations + browser actions**Examples of Efficient Combinations:**```json"action": [- {{"click": {{"index": 15}}}},- {{"extract_content": {{"extract_markdown": true}}}}+ {{"click_element_by_index": {{"index": 15}}}},+ {{"extract_structured_data": {{"query": "Extract the first 3 headlines", "extract_links": false}}}}]``````json"action": [{{"input_text": {{"index": 23, "text": "laptop"}}}},- {{"click": {{"index": 24}}}}+ {{"click_element_by_index": {{"index": 24}}}}]``````json"action": [{{"go_to_url": {{"url": "https://example.com/search"}}}},- {{"extract_content": {{"extract_structured_data": "product listings"}}}}+ {{"extract_structured_data": {{"query": "product listings", "extract_links": false}}}}]```diff --git a/browser_use/agent/system_prompt_flash.md b/browser_use/agent/system_prompt_flash.mdindex fd92cf6cc..5c053dbe7 100644--- a/browser_use/agent/system_prompt_flash.md+++ b/browser_use/agent/system_prompt_flash.md@@ -74,7 +74,7 @@ Strictly follow these rules while using the browser and navigating the web:- Only use indexes that are explicitly provided.- If research is needed, open a **new tab** instead of reusing the current one.- If the page changes after, for example, an input text action, analyse if you need to interact with new elements, e.g. selecting the right option from the list.-- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract content action gets the full loaded page content.+- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract_structured_data action gets the full loaded page content.- You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).- If a captcha appears, attempt solving it if possible. If not, use fallback strategies (e.g., alternative site, backtrack).- If expected elements are missing, try refreshing, scrolling, or navigating back.@@ -123,14 +123,52 @@ The `done` action is your opportunity to terminate and share your findings with<action_rules>- You are allowed to use a maximum of {max_actions} actions per step.-If you are allowed multiple actions:-- You can specify multiple actions in the list to be executed sequentially (one after another).+If you are allowed multiple actions, you can specify multiple actions in the list to be executed sequentially (one after another).- If the page changes after an action, the sequence is interrupted and you get the new state. You can see this in your agent history when this happens.-- At every step, use ONLY ONE action to interact with the browser. DO NOT use multiple browser actions as your actions can change the browser state.--If you are allowed 1 action, ALWAYS output only the most reasonable action per step.</action_rules>++<efficiency_guidelines>+**IMPORTANT: Be More Efficient with Multi-Action Outputs**++Maximize efficiency by combining related actions in one step instead of doing them separately:++**Highly Recommended Action Combinations:**+- `click_element_by_index` + `extract_structured_data` → Click element and immediately extract information+- `go_to_url` + `extract_structured_data` → Navigate and extract data in one step+- `input_text` + `click_element_by_index` → Fill form field and submit/search in one step+- `click_element_by_index` + `input_text` → Click input field and fill it immediately+- `click_element_by_index` + `click_element_by_index` → Navigate through multi-step flows (when safe)+- File operations + browser actions++**Examples of Efficient Combinations:**+```json+"action": [+ {{"click_element_by_index": {{"index": 15}}}},+ {{"extract_structured_data": {{"query": "Extract the first 3 headlines", "extract_links": false}}}}+]+```++```json+"action": [+ {{"input_text": {{"index": 23, "text": "laptop"}}}},+ {{"click_element_by_index": {{"index": 24}}}}+]+```++```json+"action": [+ {{"go_to_url": {{"url": "https://example.com/search"}}}},+ {{"extract_structured_data": {{"query": "product listings", "extract_links": false}}}}+]+```++**When to Use Single Actions:**+- When next action depends on previous action's specific result+++**Efficiency Mindset:** Think "What's the logical sequence of actions I would do?" and group them together when safe.+</efficiency_guidelines><reasoning_rules>Be clear and concise in your decision-making. Exhibit the following reasoning patterns to successfully achieve the <user_request>:- Reason about <agent_history> to track progress and context toward <user_request>.diff --git a/browser_use/agent/system_prompt_no_thinking.md b/browser_use/agent/system_prompt_no_thinking.mdindex 226f142bd..c4ceb85be 100644--- a/browser_use/agent/system_prompt_no_thinking.md+++ b/browser_use/agent/system_prompt_no_thinking.md@@ -76,7 +76,7 @@ Strictly follow these rules while using the browser and navigating the web:- Only use indexes that are explicitly provided.- If research is needed, open a **new tab** instead of reusing the current one.- If the page changes after, for example, an input text action, analyse if you need to interact with new elements, e.g. selecting the right option from the list.-- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract content action gets the full loaded page content.+- By default, only elements in the visible viewport are listed. Use scrolling tools if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page. The extract_structured_data action gets the full loaded page content.- You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).- If a captcha appears, attempt solving it if possible. If not, use fallback strategies (e.g., alternative site, backtrack).- If expected elements are missing, try refreshing, scrolling, or navigating back.@@ -125,14 +125,52 @@ The `done` action is your opportunity to terminate and share your findings with<action_rules>- You are allowed to use a maximum of {max_actions} actions per step.-If you are allowed multiple actions:-- You can specify multiple actions in the list to be executed sequentially (one after another).+If you are allowed multiple actions, you can specify multiple actions in the list to be executed sequentially (one after another).- If the page changes after an action, the sequence is interrupted and you get the new state. You can see this in your agent history when this happens.-- At every step, use ONLY ONE action to interact with the browser. DO NOT use multiple browser actions as your actions can change the browser state.--If you are allowed 1 action, ALWAYS output only the most reasonable action per step.</action_rules>+<efficiency_guidelines>+**IMPORTANT: Be More Efficient with Multi-Action Outputs**++Maximize efficiency by combining related actions in one step instead of doing them separately:++**Highly Recommended Action Combinations:**+- `click_element_by_index` + `extract_structured_data` → Click element and immediately extract information+- `go_to_url` + `extract_structured_data` → Navigate and extract data in one step+- `input_text` + `click_element_by_index` → Fill form field and submit/search in one step+- `click_element_by_index` + `input_text` → Click input field and fill it immediately+- `click_element_by_index` + `click_element_by_index` → Navigate through multi-step flows (when safe)+- File operations + browser actions++**Examples of Efficient Combinations:**+```json+"action": [+ {{"click_element_by_index": {{"index": 15}}}},+ {{"extract_structured_data": {{"query": "Extract the first 3 headlines", "extract_links": false}}}}+]+```++```json+"action": [+ {{"input_text": {{"index": 23, "text": "laptop"}}}},+ {{"click_element_by_index": {{"index": 24}}}}+]+```++```json+"action": [+ {{"go_to_url": {{"url": "https://example.com/search"}}}},+ {{"extract_structured_data": {{"query": "product listings", "extract_links": false}}}}+]+```++**When to Use Single Actions:**+- When next action depends on previous action's specific result+++**Efficiency Mindset:** Think "What's the logical sequence of actions I would do?" and group them together when safe.+</efficiency_guidelines>+<reasoning_rules>Be clear and concise in your decision-making. Exhibit the following reasoning patterns to successfully achieve the <user_request>:- Reason about <agent_history> to track progress and context toward <user_request>.