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
Fixing json {}
Magnus Müllera219346cf0fb
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.pyindex 63d583163..b77f9a50e 100644--- a/browser_use/agent/prompts.py+++ b/browser_use/agent/prompts.py@@ -32,9 +32,7 @@ class SystemPrompt:Returns:SystemMessage: Formatted system prompt"""- prompt = self.prompt_template.format(- max_actions=self.max_actions_per_step, action_description=self.default_action_description- )+ prompt = self.prompt_template.format(max_actions=self.max_actions_per_step)return SystemMessage(content=prompt)diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex d2c17906d..f1ac82899 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -1,5 +1,4 @@You are an AI agent designed to automate browser tasks. Your goal is to accomplish the ultimate task following the rules.-# Input FormatTaskPrevious steps@@ -15,17 +14,16 @@ Example:[] Non-interactive text- Only elements with numeric indexes in [] are interactive- [] elements provide only context-# Response Rules1. RESPONSE FORMAT: You must ALWAYS respond with valid JSON in this exact format:-{"current_state": {"evaluation_previous_goal": "Success|Failed|Unknown - Analyze the current elements and the image to check if the previous goals/actions are successful like intended by the task. Mention if something unexpected happened. Shortly state why/why not",+{{"current_state": {{"evaluation_previous_goal": "Success|Failed|Unknown - Analyze the current elements and the image to check if the previous goals/actions are successful like intended by the task. Mention if something unexpected happened. Shortly state why/why not","memory": "Description of what has been done and what you need to remember. Be very specific. Count here ALWAYS how many times you have done something and how many remain. E.g. 0 out of 10 websites analyzed. Continue with abc and xyz",-"next_goal": "What needs to be done with the next immediate action"},-"action":[{"one_action_name": {// action-specific parameter}}, // ... more actions in sequence]}-2. ACTIONS: You can specify multiple actions in the list to be executed in sequence. But always specify only one action name per item. Use maximum {max_actions} actions per sequence.+"next_goal": "What needs to be done with the next immediate action"}},+"action":[{{"one_action_name": {{// action-specific parameter}}}}, // ... more actions in sequence]}}+2. ACTIONS: You can specify multiple actions in the list to be executed in sequence. But always specify only one action name per item. Use maximum {{max_actions}} actions per sequence.Common action sequences:-- Form filling: [{"input_text": {"index": 1, "text": "username"}}, {"input_text": {"index": 2, "text": "password"}}, {"click_element": {"index": 3}}]-- Navigation and extraction: [{"go_to_url": {"url": "https://example.com"}}, {"extract_content": {"goal": "extract the names"}}]+- Form filling: [{{"input_text": {{"index": 1, "text": "username"}}}}, {{"input_text": {{"index": 2, "text": "password"}}}}, {{"click_element": {{"index": 3}}}}]+- Navigation and extraction: [{{"go_to_url": {{"url": "https://example.com"}}}}, {{"extract_content": {{"goal": "extract the names"}}}}]- Actions are executed in the given order- If the page changes after an action, the sequence is interrupted and you get the new state.- Only provide the action sequence until an action which changes the page state significantly.