Skip to content

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

rebuild manually

Nick Sweetingfe113d709423
diff --git a/browser_use/browser/default_action_watchdog.py b/browser_use/browser/default_action_watchdog.py
index dc0fb5c1b..f66e0f792 100644
--- a/browser_use/browser/default_action_watchdog.py
+++ b/browser_use/browser/default_action_watchdog.py
@@ -24,6 +24,13 @@ from browser_use.browser.watchdog_base import BaseWatchdog
if TYPE_CHECKING:
pass
+# Rebuild event models that have forward references to EnhancedDOMTreeNode
+# This must be done after all imports are complete
+ClickElementEvent.model_rebuild()
+TypeTextEvent.model_rebuild()
+ScrollEvent.model_rebuild()
+UploadFileEvent.model_rebuild()
+
class DefaultActionWatchdog(BaseWatchdog):
"""Handles default browser actions like click, type, and scroll using CDP."""
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 119f42909..d75f60ebb 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -40,6 +40,11 @@ from browser_use.utils import time_execution_sync
logger = logging.getLogger(__name__)
+# Rebuild event models that have forward references to EnhancedDOMTreeNode
+# This must be done after all imports are complete
+ClickElementEvent.model_rebuild()
+TypeTextEvent.model_rebuild()
+# Note: ScrollEvent and UploadFileEvent also have node references but are not imported here
Context = TypeVar('Context')