Skip to content

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

Update sample_images type

zhcn0fc797b9f67c
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index c7d8961ba..2c6e17489 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -18,8 +18,8 @@ from browser_use.filesystem.file_system import FileSystem
from browser_use.llm.messages import (
BaseMessage,
ContentPartTextParam,
+ ContentPartImageParam,
SystemMessage,
- UserMessage,
)
from browser_use.observability import observe_debug
from browser_use.utils import match_url_with_domain_pattern, time_execution_sync
@@ -109,7 +109,7 @@ class MessageManager:
vision_detail_level: Literal['auto', 'low', 'high'] = 'auto',
include_tool_call_examples: bool = False,
include_recent_events: bool = False,
- sample_images: list[UserMessage] | None = None,
+ sample_images: list[ContentPartTextParam | ContentPartImageParam] | None = None,
):
self.task = task
self.state = state
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.py
index 00663aeaa..901e1503d 100644
--- a/browser_use/agent/prompts.py
+++ b/browser_use/agent/prompts.py
@@ -93,7 +93,7 @@ class AgentMessagePrompt:
screenshots: list[str] | None = None,
vision_detail_level: Literal['auto', 'low', 'high'] = 'auto',
include_recent_events: bool = False,
- sample_images: list[UserMessage] | None = None,
+ sample_images: list[ContentPartTextParam | ContentPartImageParam] | None = None,
):
self.browser_state: 'BrowserStateSummary' = browser_state_summary
self.file_system: 'FileSystem | None' = file_system
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index c91a79225..603a59a27 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -24,7 +24,7 @@ from browser_use.agent.cloud_events import (
)
from browser_use.agent.message_manager.utils import save_conversation
from browser_use.llm.base import BaseChatModel
-from browser_use.llm.messages import BaseMessage, UserMessage
+from browser_use.llm.messages import BaseMessage, UserMessage, ContentPartTextParam, ContentPartImageParam
from browser_use.llm.openai.chat import ChatOpenAI
from browser_use.tokens.service import TokenCost
@@ -179,7 +179,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
step_timeout: int = 120,
directly_open_url: bool = True,
include_recent_events: bool = False,
- sample_images: list[UserMessage] | None = None,
+ sample_images: list[ContentPartTextParam | ContentPartImageParam] | None = None,
**kwargs,
):
if page_extraction_llm is None: