Skip to content

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

fix: Add default=True to ScrollAction.down field to handle LLM responses missing the field

Utkarsha6a557442f65
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 8584a107a..d942a70d7 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1497,9 +1497,16 @@ class BrowserSession(BaseModel):
try:
# Create and store the CDP client for direct CDP communication
- self._cdp_client_root = CDPClient(
- self.cdp_url, max_ws_frame_size=200 * 1024 * 1024
- ) # Use 200MB limit to handle pages with very large DOMs
+ # Try with max_ws_frame_size first (for newer cdp-use versions)
+ # Fall back to without it if the parameter is not supported
+ try:
+ self._cdp_client_root = CDPClient(
+ self.cdp_url, max_ws_frame_size=200 * 1024 * 1024
+ ) # Use 200MB limit to handle pages with very large DOMs
+ except TypeError:
+ # Older cdp-use versions don't support max_ws_frame_size parameter
+ self.logger.debug('CDPClient does not support max_ws_frame_size, using default')
+ self._cdp_client_root = CDPClient(self.cdp_url)
assert self._cdp_client_root is not None
await self._cdp_client_root.start()
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 5712b2bd3..efdd1bdaa 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -780,7 +780,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
raise RuntimeError(str(e))
@self.registry.action(
- """Scroll by pages (down=True/False, pages=0.5-10.0, default 1.0). Use index for scroll containers (dropdowns/custom UI). High pages (10) reaches bottom. Multi-page scrolls sequentially. Viewport-based height, fallback 1000px/page.""",
+ """Scroll by pages. REQUIRED: down=True/False (True=scroll down, False=scroll up, default=True). Optional: pages=0.5-10.0 (default 1.0). Use index for scroll containers (dropdowns/custom UI). High pages (10) reaches bottom. Multi-page scrolls sequentially. Viewport-based height, fallback 1000px/page.""",
param_model=ScrollAction,
)
async def scroll(params: ScrollAction, browser_session: BrowserSession):
diff --git a/browser_use/tools/views.py b/browser_use/tools/views.py
index 48a4d2ff0..71342956c 100644
--- a/browser_use/tools/views.py
+++ b/browser_use/tools/views.py
@@ -71,7 +71,7 @@ class CloseTabAction(BaseModel):
class ScrollAction(BaseModel):
- down: bool = Field(description='down=True=scroll down, down=False scroll up')
+ down: bool = Field(default=True, description='down=True=scroll down, down=False scroll up')
pages: float = Field(default=1.0, description='0.5=half page, 1=full page, 10=to bottom/top')
index: int | None = Field(default=None, description='Optional element index to scroll within specific container')