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
feat(agent): expose max_clickable_elements_length as Agent parameter
Cursor Agent270e418cead0
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.pyindex 5e231c942..1e3261575 100644--- a/browser_use/agent/message_manager/service.py+++ b/browser_use/agent/message_manager/service.py@@ -114,6 +114,7 @@ class MessageManager:include_recent_events: bool = False,sample_images: list[ContentPartTextParam | ContentPartImageParam] | None = None,llm_screenshot_size: tuple[int, int] | None = None,+ max_clickable_elements_length: int = 40000,):self.task = taskself.state = state@@ -127,6 +128,7 @@ class MessageManager:self.include_recent_events = include_recent_eventsself.sample_images = sample_imagesself.llm_screenshot_size = llm_screenshot_size+ self.max_clickable_elements_length = max_clickable_elements_lengthassert max_history_items is None or max_history_items > 5, 'max_history_items must be None or greater than 5'@@ -470,6 +472,7 @@ class MessageManager:include_attributes=self.include_attributes,step_info=step_info,page_filtered_actions=page_filtered_actions,+ max_clickable_elements_length=self.max_clickable_elements_length,sensitive_data=self.sensitive_data_description,available_file_paths=available_file_paths,screenshots=screenshots,diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 6bc7757df..cfb76f507 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -204,6 +204,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):loop_detection_enabled: bool = True,llm_screenshot_size: tuple[int, int] | None = None,message_compaction: MessageCompactionSettings | bool | None = True,+ max_clickable_elements_length: int = 40000,_url_shortening_limit: int = 25,**kwargs,):@@ -409,6 +410,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):loop_detection_window=loop_detection_window,loop_detection_enabled=loop_detection_enabled,message_compaction=message_compaction,+ max_clickable_elements_length=max_clickable_elements_length,)# Token cost service@@ -514,6 +516,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):include_recent_events=self.include_recent_events,sample_images=self.sample_images,llm_screenshot_size=llm_screenshot_size,+ max_clickable_elements_length=self.settings.max_clickable_elements_length,)if self.sensitive_data:diff --git a/browser_use/agent/views.py b/browser_use/agent/views.pyindex b73afc5e1..a42205483 100644--- a/browser_use/agent/views.py+++ b/browser_use/agent/views.py@@ -88,6 +88,7 @@ class AgentSettings(BaseModel):# Loop detection settingsloop_detection_window: int = 20 # Rolling window size for action similarity trackingloop_detection_enabled: bool = True # Whether to enable loop detection nudges+ max_clickable_elements_length: int = 40000 # Max characters for clickable elements in promptclass PageFingerprint(BaseModel):diff --git a/pyproject.toml b/pyproject.tomlindex cad007fae..e73622755 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -2,7 +2,7 @@name = "browser-use"description = "Make websites accessible for AI agents"authors = [{ name = "Gregor Zunic" }]-version = "0.11.10a1"+version = "0.11.10a2"readme = "README.md"requires-python = ">=3.11,<4.0"classifiers = [