Skip to content

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

Use copy of cached_selector_map to avoid cache being remove

Magnus Müllerf58f25d7d6e6
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index b604f3e93..8b99b36ec 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1520,7 +1520,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
self.browser_session._cached_browser_state_summary is not None
and self.browser_session._cached_browser_state_summary.dom_state is not None
):
- cached_selector_map = self.browser_session._cached_browser_state_summary.dom_state.selector_map
+ cached_selector_map = dict(self.browser_session._cached_browser_state_summary.dom_state.selector_map)
cached_element_hashes = {e.parent_branch_hash() for e in cached_selector_map.values()}
else:
cached_selector_map = {}