Skip to content

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

fix: improved logged CDP URL by just sending the hostname

reformedot9df2804b2824
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index ac8071e2e..d0502ff1a 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -11,6 +11,7 @@ import time
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import Any, Generic, TypeVar
+from urllib.parse import urlparse
from dotenv import load_dotenv
@@ -1039,7 +1040,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
use_validation=self.settings.validate_output,
version=self.version,
source=self.source,
- cdp_url=self.browser_session.cdp_url if self.browser_session else None,
+ cdp_url=urlparse(self.browser_session.cdp_url).hostname if self.browser_session and self.browser_session.cdp_url else None,
action_errors=self.state.history.errors(),
action_history=action_history_data,
urls_visited=self.state.history.urls(),