Skip to content

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

Validator gets new state

magmueller604aad957d09
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 3fd4cd168..2f4412b84 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -359,15 +359,15 @@ class Agent:
system_msg = (
f'You are a validator of an agent who interacts with a browser. '
f'Validate if the output of last action is what the user wanted and if the task is completed. '
- f'If the task is unclear defined, you can let it pass. '
- f'Task: {self.task}. Return a JSON object with 2 keys: is_valid and reason. '
+ f'If the task is unclear defined, you can let it pass. But if something is missing or the image does not show what was requested dont let it pass.'
+ f'Task to validate: {self.task}. Return a JSON object with 2 keys: is_valid and reason. '
f'is_valid is a boolean that indicates if the output is correct. '
f'reason is a string that explains why it is valid or not.'
f' example: {{"is_valid": false, "reason": "The user wanted to search for "cat photos", but the agent searched for "dog photos" instead."}}'
)
if self.browser_context.session:
- state = self.browser_context.session.cached_state
+ state = await self.browser_context.get_state(use_vision=self.use_vision)
content = AgentMessagePrompt(
state=state,
result=self._last_result,
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index fe6edee7c..3f2cdf2bb 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -501,6 +501,7 @@ class Controller:
for i, action in enumerate(actions):
if changed and action.get_index() is not None:
# next action requires index but there are new elements on the page
+ logger.info(f'Something new appeared after action {i}')
break
results.append(await self.act(action, browser_context))