Skip to content

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

dont dump storage_state if not needed, it makes the browser look glitchy

Nick Sweeting0fea9f46333a
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index a63b023f6..e80565788 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1451,6 +1451,10 @@ class BrowserSession(BaseModel):
"""
Save cookies to the specified path or the configured cookies_file and/or storage_state.
"""
+
+ if not (path or self.browser_profile.storage_state or self.browser_profile.cookies_file):
+ return
+
storage_state = await self.browser_context.storage_state()
cookies = storage_state['cookies']