Skip to content

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

Improve logging and action result handling: update messages for new elements detection and adjust success flag in action results so that agent doesn't stop.

mertunsallb8621e108966
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 88996f408..1f30c2a82 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1574,7 +1574,7 @@ class Agent(Generic[Context]):
new_path_hashes = {e.hash.branch_path_hash for e in new_selector_map.values()}
if check_for_new_elements and not new_path_hashes.issubset(cached_path_hashes):
# next action requires index but there are new elements on the page
- msg = f'Something new appeared after action {i} / {len(actions)}'
+ msg = f'Something new appeared after action {i} / {len(actions)}, following actions are NOT executed and should be retried.'
logger.info(msg)
results.append(ActionResult(extracted_content=msg, include_in_memory=True, memory=msg))
break
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index f0320e264..09ffcf8a1 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -223,7 +223,7 @@ class Controller(Generic[Context]):
logger.info(new_tab_msg)
await browser_session.switch_to_tab(-1)
return ActionResult(
- extracted_content=msg, include_in_memory=True, success=True, memory=f'Clicked element {params.index}'
+ extracted_content=msg, include_in_memory=True, success=False, memory=f'Clicked element {params.index}'
)
except Exception as e:
error_msg = str(e)