Skip to content

Agent Zero AI framework

fix: make browser agent compatible with PlayWright 1.50 (#381)

ehl0wr0ldace6dccfca68
diff --git a/prompts/default/browser_agent.system.md b/prompts/default/browser_agent.system.md
index e9f3d7633..963930063 100644
--- a/prompts/default/browser_agent.system.md
+++ b/prompts/default/browser_agent.system.md
@@ -1,7 +1,25 @@
-# important
-do not overdo task
-when told go to website open website and stop
-do not interact unless told to
-waiting for instructions means ending task as done
-accept any cookies do not go to cokkie settings
-in page_summary respond with one paragraph of main content plus brief overview of page elements
\ No newline at end of file
+# Operation instruction
+Keep your tasks solution as simple and straight forward as possible
+Follow instructions as closely as possible
+When told go to website, open the website. If no other instructions: stop there
+Do not interact with the website unless told to
+Always accept all cookies if prompted on the website, NEVER go to browser cookie settings
+In page_summary respond with one paragraph of main content plus an overview of page elements
+If asked specific questions about a website, be as precise and close to the actual page content as possible
+If you are waiting for instructions: you should end the task and mark as done
+
+## Response Format
+Your responses must always be formatted as a JSON object
+The response JSON must contain at least the following fields: "title", "response", "page_summary"
+
+## Response fields
+ * title (type: str) - The ttitle of the current web page
+ * response (type: str) - Your response to your superior's last request
+ * page_summary (type: str) - Summary of the current web page as requested by superior
+
+## Example response
+{
+ "title": "Google Search",
+ "response": "I have succesfully navigated to the response page.",
+ "page_summary": "The page contains a menu bar with ... and a search input field. Under the search field there are two buttons with ... and ..."
+}
diff --git a/python/tools/browser_agent.py b/python/tools/browser_agent.py
index b55a730c0..7697e7a0e 100644
--- a/python/tools/browser_agent.py
+++ b/python/tools/browser_agent.py
@@ -5,13 +5,13 @@ from agent import Agent, InterventionException
import models
from python.helpers.tool import Tool, Response
-from python.helpers import dirty_json, files, rfc_exchange, defer, strings, persist_chat
-from python.helpers.print_style import PrintStyle
+from python.helpers import files, defer, persist_chat
from python.helpers.browser_use import browser_use
from python.extensions.message_loop_start._10_iteration_no import get_iter_no
from pydantic import BaseModel
import uuid
-
+from python.helpers.dirty_json import DirtyJson
+from langchain_core.messages import SystemMessage
class State:
@staticmethod
@@ -83,10 +83,10 @@ class State:
await self._initialize()
class CustomSystemPrompt(browser_use.SystemPrompt):
- def important_rules(self) -> str:
- existing_rules = super().important_rules()
+ def get_system_message(self) -> SystemMessage:
+ existing_rules = super().get_system_message().text()
new_rules = agent.read_prompt("prompts/browser_agent.system.md")
- return f"{existing_rules}\n{new_rules}".strip()
+ return SystemMessage(content=f"{existing_rules}\n{new_rules}".strip())
# Model of task result
class DoneResult(BaseModel):
@@ -183,7 +183,7 @@ class BrowserAgent(Tool):
result = await task.result()
answer = result.final_result()
try:
- answer_data = dirty_json.DirtyJson.parse_string(answer)
+ answer_data = DirtyJson.parse_string(answer)
answer_text = strings.dict_to_text(answer_data) # type: ignore
except Exception as e:
answer_text = answer
diff --git a/requirements.txt b/requirements.txt
index 7bc59dbef..516caaff8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
ansio==0.0.1
beautifulsoup4==4.12.3
-browser-use==0.1.37
+browser-use==0.1.40
docker==7.1.0
duckduckgo-search==6.1.12
faiss-cpu==1.8.0.post1
@@ -10,7 +10,7 @@ flaredantic==0.1.4
GitPython==3.1.43
inputimeout==1.0.4
langchain-anthropic==0.3.3
-langchain-community==0.3.13
+langchain-community==0.3.19
langchain-google-genai==2.0.8
langchain-groq==0.2.2
langchain-huggingface==0.1.2
@@ -22,7 +22,7 @@ lxml_html_clean==0.3.1
markdown==3.7
newspaper3k==0.2.8
paramiko==3.5.0
-playwright==1.49.0
+playwright==1.52.0
pypdf==4.3.1
python-dotenv==1.0.1
sentence-transformers==3.0.1