Skip to content

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

fix tab not found in list error when human closes active agent ta

Nick Sweeting42f4112fba62
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index e80565788..f4a2e4ec4 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1803,7 +1803,11 @@ class BrowserSession(BaseModel):
except Exception:
bytes_used = None
- tab_idx = self.tabs.index(page)
+ try:
+ tab_idx = self.tabs.index(page)
+ except ValueError:
+ tab_idx = '??'
+
extra_delay = ''
if remaining > 0:
extra_delay = f', waiting +{remaining:.2f}s for all frames to finish'