Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Bugfix to #3702
Alex Mascoloef03559d5183
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex cb96129e1..738d5ae58 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -524,14 +524,15 @@ class Agent(Generic[Context, AgentStructuredOutput]):@propertydef logger(self) -> logging.Logger:"""Get instance-specific logger with task ID in the name"""-- _browser_session_id = self.browser_session.id if self.browser_session else '----'+ # logger may be called in __init__ so we don't assume self.* attributes have been initialized+ _task_id = task_id[-4:] if (task_id := getattr(self, 'task_id', None)) else '----'+ _browser_session_id = browser_session.id[-4:] if (browser_session := getattr(self, 'browser_session', None)) else '----'_current_target_id = (- self.browser_session.agent_focus_target_id[-2:]- if self.browser_session and self.browser_session.agent_focus_target_id+ browser_session.agent_focus_target_id[-2:]+ if (browser_session := getattr(self, 'browser_session', None)) and browser_session.agent_focus_target_idelse '--')- return logging.getLogger(f'browser_use.Agent🅰 {self.task_id[-4:]} ⇢ 🅑 {_browser_session_id[-4:]} 🅣 {_current_target_id}')+ return logging.getLogger(f'browser_use.Agent🅰 {_task_id} ⇢ 🅑 {_browser_session_id} 🅣 {_current_target_id}')@propertydef browser_profile(self) -> BrowserProfile: