Skip to content

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

Refactor action field descriptions in AgentOutput models

Magnus Müller7b995b7fc123
diff --git a/browser_use/agent/views.py b/browser_use/agent/views.py
index a8ae7f3c4..c816c41f2 100644
--- a/browser_use/agent/views.py
+++ b/browser_use/agent/views.py
@@ -155,7 +155,6 @@ class AgentOutput(BaseModel):
next_goal: str | None = None
action: list[ActionModel] = Field(
...,
- description='List of actions to execute',
json_schema_extra={'min_items': 1}, # Ensure at least one action is provided
)
@@ -208,7 +207,7 @@ class AgentOutput(BaseModel):
__base__=AgentOutputNoThinking,
action=(
list[custom_actions], # type: ignore
- Field(..., description='List of actions to execute', json_schema_extra={'min_items': 1}),
+ Field(..., json_schema_extra={'min_items': 1}),
),
__module__=AgentOutputNoThinking.__module__,
)
@@ -237,7 +236,7 @@ class AgentOutput(BaseModel):
__base__=AgentOutputFlashMode,
action=(
list[custom_actions], # type: ignore
- Field(..., description='List of actions to execute', json_schema_extra={'min_items': 1}),
+ Field(..., json_schema_extra={'min_items': 1}),
),
__module__=AgentOutputFlashMode.__module__,
)
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 4c3b883f0..8e24773e9 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -555,7 +555,7 @@ class Tools(Generic[Context]):
# This action is temporarily disabled as it needs refactoring to use events
@self.registry.action(
- """Extract page data via LLM. Use when on right page, know what to extract. Can't get interactive elements.""",
+ """Extract page data via LLM. Use when on right page, know what to extract. Can't get interactive elements. Don't call again on same page with same query.""",
)
async def extract_structured_data(
query: str,
@@ -967,8 +967,8 @@ You will be given a query and the markdown of a webpage that has been filtered t
@self.registry.action(
"""Execute JS. MUST wrap in IIFE: (function(){...})() or async: (async function(){...})()
-Use when other tools fail or need custom logic.
-
+Use when other tools fail. Limit output. For complex objects use JSON.stringify().
+Don't use comments.
CORRECT: (function(){ try { const el = document.querySelector('#id'); return el ? el.value : 'not found'; } catch(e) { return 'Error: ' + e.message; } })()
WRONG: document.querySelector('#id').value""",
)
diff --git a/browser_use/tools/views.py b/browser_use/tools/views.py
index a019890e6..44fab1347 100644
--- a/browser_use/tools/views.py
+++ b/browser_use/tools/views.py
@@ -6,7 +6,9 @@ from pydantic import BaseModel, ConfigDict, Field
# Action Input Models
class SearchAction(BaseModel):
query: str
- search_engine: str = Field(default='duckduckgo', description='duckduckgo, google, bing')
+ search_engine: str = Field(
+ default='duckduckgo', description='duckduckgo, google, bing (use duckduckgo by default because less captchas)'
+ )
# Backward compatibility alias