Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Refactor: Reduce max actions per step to 3

Cursor Agentd1b47eba5080
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.py
index 3e7830e2e..85cd10338 100644
--- a/browser_use/agent/prompts.py
+++ b/browser_use/agent/prompts.py
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
class SystemPrompt:
def __init__(
self,
- max_actions_per_step: int = 4,
+ max_actions_per_step: int = 3,
override_system_message: str | None = None,
extend_system_message: str | None = None,
use_thinking: bool = True,
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 2cc319525..454ead3f9 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -160,7 +160,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
generate_gif: bool | str = False,
available_file_paths: list[str] | None = None,
include_attributes: list[str] | None = None,
- max_actions_per_step: int = 4,
+ max_actions_per_step: int = 3,
use_thinking: bool = True,
flash_mode: bool = False,
demo_mode: bool | None = None,
diff --git a/browser_use/agent/system_prompt_flash.md b/browser_use/agent/system_prompt_flash.md
index c420cd0c6..e2a6927a9 100644
--- a/browser_use/agent/system_prompt_flash.md
+++ b/browser_use/agent/system_prompt_flash.md
@@ -3,6 +3,9 @@ You are an AI agent designed to operate in an iterative loop to automate browser
<user_request>Ultimate objective. Specific tasks: follow each step. Open-ended: plan approach.</user_request>
<browser_state>Elements: [index]<type>text</type>. Only [indexed] are interactive. Indentation=child. *[=new.</browser_state>
<file_system>- PDFs are auto-downloaded to available_file_paths - use read_file to read the doc or scroll and look at screenshot. You have access to persistent file system for progress tracking. Long tasks >10 steps: use todo.md: checklist for subtasks, update with replace_file_str when completing items. When writing CSV, use double quotes for commas. In available_file_paths, you can read downloaded files and user attachment files.</file_system>
+<action_rules>
+You are allowed to use a maximum of {max_actions} actions per step. Always verify that your previous step succeeded before taking consequential actions (submitting forms, navigating to new pages, etc.). If the page changed after an action, check the current state before continuing.
+</action_rules>
<output>You must respond with a valid JSON in this exact format:
{{
"memory": "Up to 5 sentences of specific reasoning about: Was the previous step successful / failed? What do we need to remember from the current state for the task? Plan ahead what are the best next actions. What's the next immediate goal? Depending on the complexity think longer. For example if its opvious to click the start button just say: click start. But if you need to remember more about the step it could be: Step successful, need to remember A, B, C to visit later. Next click on A.",
diff --git a/browser_use/agent/system_prompt_flash_anthropic.md b/browser_use/agent/system_prompt_flash_anthropic.md
index 8e54d950a..c3f260760 100644
--- a/browser_use/agent/system_prompt_flash_anthropic.md
+++ b/browser_use/agent/system_prompt_flash_anthropic.md
@@ -8,6 +8,9 @@ Elements: [index]<type>text</type>. Only [indexed] are interactive. Indentation=
<file_system>
PDFs are auto-downloaded to available_file_paths - use read_file to read the doc or scroll and look at screenshot. You have access to persistent file system for progress tracking and saving data. Long tasks >10 steps: use todo.md: checklist for subtasks, update with replace_file_str when completing items. In available_file_paths, you can read downloaded files and user attachment files.
</file_system>
+<action_rules>
+You are allowed to use a maximum of {max_actions} actions per step. Always verify that your previous step succeeded before taking consequential actions (submitting forms, navigating to new pages, etc.). If the page changed after an action, check the current state before continuing.
+</action_rules>
<output>You must call the AgentOutput tool with the following schema for the arguments:
{{
diff --git a/browser_use/agent/views.py b/browser_use/agent/views.py
index 537f3b184..7871f1807 100644
--- a/browser_use/agent/views.py
+++ b/browser_use/agent/views.py
@@ -42,7 +42,7 @@ class AgentSettings(BaseModel):
override_system_message: str | None = None
extend_system_message: str | None = None
include_attributes: list[str] | None = DEFAULT_INCLUDE_ATTRIBUTES
- max_actions_per_step: int = 4
+ max_actions_per_step: int = 3
use_thinking: bool = True
flash_mode: bool = False # If enabled, disables evaluation_previous_goal and next_goal, and sets use_thinking = False
use_judge: bool = True