Skip to content

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

cap filename length

Nick Sweeting8a05d0f0a14a
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index f8359eeda..ec14ab5e6 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -344,7 +344,7 @@ class Controller(Generic[Context]):
# Create a filename based on the page URL
short_url = re.sub(r'^https?://(?:www\.)?|/$', '', page.url)
- slug = re.sub(r'[^a-zA-Z0-9]+', '-', short_url).strip('-').lower()
+ slug = re.sub(r'[^a-zA-Z0-9]+', '-', short_url).strip('-').lower()[:64]
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
sanitized_filename = f'{slug}_{timestamp}.html'