Skip to content

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

cleaner logging slightly

Nick Sweeting78ee73c949a0
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index ffb295ec9..15e9288bc 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1580,15 +1580,15 @@ class Agent(Generic[Context, AgentStructuredOutput]):
# Get action name from the action model
action_data = action.model_dump(exclude_unset=True)
action_name = next(iter(action_data.keys())) if action_data else 'unknown'
- action_params = getattr(action, action_name, '') or str(action.model_dump(mode='json'))[:56].replace(
+ action_params = getattr(action, action_name, '') or str(action.model_dump(mode='json'))[:140].replace(
'"', ''
).replace('{', '').replace('}', '').replace("'", '').strip().strip(',')
# Ensure action_params is always a string before checking length
action_params = str(action_params)
- action_params = f'{action_params[:50]}...' if len(action_params) > 54 else action_params
+ action_params = f'{action_params[:122]}...' if len(action_params) > 128 else action_params
time_start = time.time()
- self.logger.info(f'🦾 Executing action {i + 1}/{total_actions}: {cyan}{action_name}({action_params}){reset}...')
+ self.logger.info(f'🦾 {cyan}[ACTION {i + 1}/{total_actions}] {action_name}({action_params})... {reset}')
result = await self.controller.act(
action=action,
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 3e1e22e85..ef9368a84 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -574,13 +574,13 @@ class BrowserSession(BaseModel):
self.logger.debug(f'πŸ”„ AgentFocusChangedEvent received: tab_index={event.tab_index}, url={event.url}')
# Clear cached DOM state since focus changed
- self.logger.debug('πŸ”„ Clearing DOM cache...')
+ # self.logger.debug('πŸ”„ Clearing DOM cache...')
if self._dom_watchdog:
self._dom_watchdog.clear_cache()
- self.logger.debug('πŸ”„ Cleared DOM cache after focus change')
+ # self.logger.debug('πŸ”„ Cleared DOM cache after focus change')
# Clear cached browser state
- self.logger.debug('πŸ”„ Clearing cached browser state...')
+ # self.logger.debug('πŸ”„ Clearing cached browser state...')
self._cached_browser_state_summary = None
self._cached_selector_map.clear()
self.logger.debug('πŸ”„ Cached browser state cleared')
@@ -592,7 +592,7 @@ class BrowserSession(BaseModel):
self.logger.debug(f'πŸ”„ Got {len(targets)} targets')
if 0 <= event.tab_index < len(targets):
target_id = targets[event.tab_index]['targetId']
- self.logger.debug(f'πŸ”„ Getting CDP session for target {target_id}...')
+ # self.logger.debug(f'πŸ”„ Getting CDP session for target {target_id}...')
self.agent_focus = await self.get_or_create_cdp_session(target_id, focus=True)
self.logger.debug(f'πŸ”„ Updated agent focus to tab {event.tab_index} (target {target_id})')
@@ -607,14 +607,15 @@ class BrowserSession(BaseModel):
timeout=2.0,
)
if test_result.get('result', {}).get('value') == 2:
- self.logger.debug('πŸ”„ βœ… Browser is responsive after focus change')
+ # self.logger.debug('πŸ”„ βœ… Browser is responsive after focus change')
+ pass
else:
raise Exception('❌ Failed to execute test JS expression with Page.evaluate')
except Exception as e:
self.logger.error(f'πŸ”„ ❌ Page appears crashed after focus change: {e}')
raise
- self.logger.debug('πŸ”„ AgentFocusChangedEvent handler completed successfully')
+ # self.logger.debug('πŸ”„ AgentFocusChangedEvent handler completed successfully')
async def on_FileDownloadedEvent(self, event: FileDownloadedEvent) -> None:
"""Track downloaded files during this session."""