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
Merge branch 'main' into local-remote-split
Nick Sweeting032f314a411a
diff --cc browser_use/agent/gif.pyindex 9d5798fdd,a12f322a8..31826efb6--- a/browser_use/agent/gif.py+++ b/browser_use/agent/gif.py@@@ -61,31 -61,22 +61,25 @@@ def create_history_giflogger.warning('No history to create GIF from')return+ # Get all screenshots from history (including None placeholders)+ screenshots = history.screenshots(return_none_if_not_screenshot=True)++ if not screenshots:+ logger.warning('No screenshots found in history')+ return+# Find the first non-placeholder screenshot+ # A screenshot is considered a placeholder if:+ # 1. It's the exact 4px placeholder for about:blank pages, OR+ # 2. It comes from a new tab page (chrome://newtab/, about:blank, etc.)first_real_screenshot = None- for item in history.history:- if not item.state.screenshot:- continue-- # Skip exact placeholder screenshots- if item.state.screenshot == PLACEHOLDER_4PX_SCREENSHOT:- continue-- # Skip screenshots from new tab pages- from browser_use.utils import is_new_tab_page-- if is_new_tab_page(item.state.url):- continue-- # This is a real screenshot from actual web content- first_real_screenshot = item.state.screenshot- break+ for screenshot in screenshots:+ if screenshot and screenshot != PLACEHOLDER_4PX_SCREENSHOT:+ first_real_screenshot = screenshot+ breakif not first_real_screenshot:- logger.warning('No valid screenshots found (all are placeholders)')+ logger.warning('No valid screenshots found (all are placeholders or from new tab pages)')return# Try to load nicer fonts@@@ -173,15 -165,8 +168,15 @@@logger.debug(f'Skipping placeholder screenshot from about:blank page at step {i}')continue+ # Skip screenshots from new tab pages+ from browser_use.utils import is_new_tab_page++ if is_new_tab_page(item.state.url):+ logger.debug(f'Skipping screenshot from new tab page ({item.state.url}) at step {i}')+ continue+# Convert base64 screenshot to PIL Image- img_data = base64.b64decode(item.state.screenshot)+ img_data = base64.b64decode(screenshot)image = Image.open(io.BytesIO(img_data))if show_goals and item.model_output: