Skip to content

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

Merge branch 'main' into feature/sample_images

Magnus Müller23b5a2b8d4e7
diff --cc browser_use/agent/service.py
index 8576a0ab8,b9b035591..05d58fe5c
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@@ -179,9 -179,25 +179,26 @@@ class Agent(Generic[Context, AgentStruc
step_timeout: int = 120,
directly_open_url: bool = True,
include_recent_events: bool = False,
+ sample_images: list[ContentPartTextParam | ContentPartImageParam] | None = None,
**kwargs,
):
+ if llm is None:
+ default_llm_name = CONFIG.DEFAULT_LLM
+ if default_llm_name:
+ try:
+ from browser_use.llm.models import get_llm_by_name
+
+ llm = get_llm_by_name(default_llm_name)
+ except (ImportError, ValueError) as e:
+ # Use the logger that's already imported at the top of the module
+ logger.warning(
+ f'Failed to create default LLM "{default_llm_name}": {e}. Falling back to ChatOpenAI(model="gpt-4.1-mini")'
+ )
+ llm = ChatOpenAI(model='gpt-4.1-mini')
+ else:
+ # No default LLM specified, use the original default
+ llm = ChatOpenAI(model='gpt-4.1-mini')
+
if page_extraction_llm is None:
page_extraction_llm = llm
if available_file_paths is None: